Date: Sat, 18 Aug 2007 03:04:35 GMT From: Matus Harvan <mharvan@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 125285 for review Message-ID: <200708180304.l7I34Z1L051722@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=125285 Change 125285 by mharvan@mharvan_bike-planet on 2007/08/18 03:03:36 tcp plugin uses TCP_CATCHALL, i.e., listens on all unused ports Affected files ... .. //depot/projects/soc2007/mharvan-mtund/mtund.src/mtund.c#5 edit .. //depot/projects/soc2007/mharvan-mtund/mtund.src/plugin_tcp.c#13 edit Differences ... ==== //depot/projects/soc2007/mharvan-mtund/mtund.src/mtund.c#5 (text+ko) ==== @@ -1191,13 +1191,7 @@ /* pl = load_plugin("./plugin_udp.so"); */ /* pl->name = "udp_catchall_1234"; */ pl = load_plugin("./plugin_tcp.so"); - pl->name = "tcp_25"; - pl = load_plugin("./plugin_tcp.so"); - pl->name = "tcp_80"; - pl = load_plugin("./plugin_tcp.so"); - pl->name = "tcp_110"; -/* pl = load_plugin("./plugin_tcp.so"); */ -/* pl->name = "tcp_catchall_1234"; */ + pl->name = "tcp_1234"; pl = load_plugin("./plugin_icmp.so"); pl->name = "icmp"; ==== //depot/projects/soc2007/mharvan-mtund/mtund.src/plugin_tcp.c#13 (text+ko) ==== @@ -12,11 +12,15 @@ #include <unistd.h> #include <event.h> +#include <netinet/in.h> +#include <netinet/tcp.h> + #include "mtund.h" #include "plugin.h" #define MAXTMPCONNS 10 #define TEMP_CONN_TIMEOUT 5 +#define USE_TCP_CATCHALL 1 enum { CONN_STATUS_FREE, /* connection not in use */ @@ -283,9 +287,17 @@ data->tmpconns[i].data = data; } data->conn = NULL; - + if (server) { data->conns->fd = tcp_listen(port); + /* enable TCP_CATCHALL */ + if (USE_TCP_CATCHALL != 0) { + int soval = 1; + if (0 != setsockopt(data->conns->fd, IPPROTO_TCP, + TCP_CATCHALL, &soval, sizeof(soval))) + warnx("setsockopt(TCP_CATCHALL) failed\n"); + } + event_set(&data->conns->ev, data->conns->fd, EV_PERSIST | EV_READ, plugin_accept_new_conn, data->conns); if (data->conns->fd != -1) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708180304.l7I34Z1L051722>