diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-04-01 19:10:36 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-04-01 19:10:36 +0000 |
commit | 3ce5169de28ddad622c2a365d19c516810997ecd (patch) | |
tree | b1f94d06f1747f36d8c880ec1160ae7abc151408 | |
parent | a955398f69e1ae6270f952f5b382394fd1fb372e (diff) | |
download | busybox-w32-3ce5169de28ddad622c2a365d19c516810997ecd.tar.gz busybox-w32-3ce5169de28ddad622c2a365d19c516810997ecd.tar.bz2 busybox-w32-3ce5169de28ddad622c2a365d19c516810997ecd.zip |
udpsvd: next part of ipsvd applets (not working yet)
git-svn-id: svn://busybox.net/trunk/busybox@18297 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | include/applets.h | 1 | ||||
-rw-r--r-- | include/usage.h | 5 | ||||
-rw-r--r-- | ipsvd/Config.in | 8 | ||||
-rw-r--r-- | ipsvd/Kbuild | 1 | ||||
-rw-r--r-- | ipsvd/tcpsvd.c | 11 |
5 files changed, 19 insertions, 7 deletions
diff --git a/include/applets.h b/include/applets.h index 8073c15e1..386f4b110 100644 --- a/include/applets.h +++ b/include/applets.h | |||
@@ -311,6 +311,7 @@ USE_TTY(APPLET(tty, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | |||
311 | //USE_TUNE2FS(APPLET(tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 311 | //USE_TUNE2FS(APPLET(tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
312 | USE_APP_UDHCPC(APPLET(udhcpc, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 312 | USE_APP_UDHCPC(APPLET(udhcpc, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
313 | USE_APP_UDHCPD(APPLET(udhcpd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) | 313 | USE_APP_UDHCPD(APPLET(udhcpd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) |
314 | USE_UDPSVD(APPLET(udpsvd, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | ||
314 | USE_UMOUNT(APPLET(umount, _BB_DIR_BIN, _BB_SUID_NEVER)) | 315 | USE_UMOUNT(APPLET(umount, _BB_DIR_BIN, _BB_SUID_NEVER)) |
315 | USE_UNAME(APPLET(uname, _BB_DIR_BIN, _BB_SUID_NEVER)) | 316 | USE_UNAME(APPLET(uname, _BB_DIR_BIN, _BB_SUID_NEVER)) |
316 | USE_UNCOMPRESS(APPLET(uncompress, _BB_DIR_BIN, _BB_SUID_NEVER)) | 317 | USE_UNCOMPRESS(APPLET(uncompress, _BB_DIR_BIN, _BB_SUID_NEVER)) |
diff --git a/include/usage.h b/include/usage.h index e1fbf7599..cec2dd766 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -3348,6 +3348,11 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when | |||
3348 | "\n-E Do not set up TCP-related environment variables" \ | 3348 | "\n-E Do not set up TCP-related environment variables" \ |
3349 | "\n-v Verbose" | 3349 | "\n-v Verbose" |
3350 | 3350 | ||
3351 | #define udpsvd_trivial_usage \ | ||
3352 | "TODO" | ||
3353 | #define udpsvd_full_usage \ | ||
3354 | "TODO" | ||
3355 | |||
3351 | #define tftp_trivial_usage \ | 3356 | #define tftp_trivial_usage \ |
3352 | "[OPTION]... HOST [PORT]" | 3357 | "[OPTION]... HOST [PORT]" |
3353 | #define tftp_full_usage \ | 3358 | #define tftp_full_usage \ |
diff --git a/ipsvd/Config.in b/ipsvd/Config.in index fb2931d07..8522ef9eb 100644 --- a/ipsvd/Config.in +++ b/ipsvd/Config.in | |||
@@ -9,6 +9,12 @@ config TCPSVD | |||
9 | bool "tcpsvd" | 9 | bool "tcpsvd" |
10 | default n | 10 | default n |
11 | help | 11 | help |
12 | tcpsvd listens on a port and runs a program for each new connection | 12 | tcpsvd listens on a tcp port and runs a program for each new connection |
13 | |||
14 | config UDPSVD | ||
15 | bool "udpsvd" | ||
16 | default n | ||
17 | help | ||
18 | udpsvd listens on a udp port and runs a program for each new connection | ||
13 | 19 | ||
14 | endmenu | 20 | endmenu |
diff --git a/ipsvd/Kbuild b/ipsvd/Kbuild index 8050921b0..9eda63d20 100644 --- a/ipsvd/Kbuild +++ b/ipsvd/Kbuild | |||
@@ -6,3 +6,4 @@ | |||
6 | 6 | ||
7 | lib-y:= | 7 | lib-y:= |
8 | lib-$(CONFIG_TCPSVD) += tcpsvd.o ipsvd_perhost.o | 8 | lib-$(CONFIG_TCPSVD) += tcpsvd.o ipsvd_perhost.o |
9 | lib-$(CONFIG_UDPSVD) += udpsvd.o | ||
diff --git a/ipsvd/tcpsvd.c b/ipsvd/tcpsvd.c index 2a3cd3b01..197edca4e 100644 --- a/ipsvd/tcpsvd.c +++ b/ipsvd/tcpsvd.c | |||
@@ -126,7 +126,6 @@ int tcpsvd_main(int argc, char **argv) | |||
126 | socklen_t sockadr_size; | 126 | socklen_t sockadr_size; |
127 | uint16_t local_port = local_port; | 127 | uint16_t local_port = local_port; |
128 | uint16_t remote_port; | 128 | uint16_t remote_port; |
129 | unsigned port; | ||
130 | char *local_hostname = NULL; | 129 | char *local_hostname = NULL; |
131 | char *remote_hostname = (char*)""; /* "" used if no -h */ | 130 | char *remote_hostname = (char*)""; /* "" used if no -h */ |
132 | char *local_ip = local_ip; | 131 | char *local_ip = local_ip; |
@@ -221,8 +220,8 @@ int tcpsvd_main(int argc, char **argv) | |||
221 | if (max_per_host) | 220 | if (max_per_host) |
222 | ipsvd_perhost_init(cmax); | 221 | ipsvd_perhost_init(cmax); |
223 | 222 | ||
224 | port = bb_lookup_port(argv[1], "tcp", 0); | 223 | local_port = bb_lookup_port(argv[1], "tcp", 0); |
225 | sock = create_and_bind_stream_or_die(argv[0], port); | 224 | sock = create_and_bind_stream_or_die(argv[0], local_port); |
226 | xlisten(sock, backlog); | 225 | xlisten(sock, backlog); |
227 | /* ndelay_off(sock); - it is the default I think? */ | 226 | /* ndelay_off(sock); - it is the default I think? */ |
228 | 227 | ||
@@ -238,7 +237,7 @@ int tcpsvd_main(int argc, char **argv) | |||
238 | 237 | ||
239 | if (verbose) { | 238 | if (verbose) { |
240 | /* we do it only for ":port" cosmetics... oh well */ | 239 | /* we do it only for ":port" cosmetics... oh well */ |
241 | len_and_sockaddr *lsa = xhost2sockaddr(argv[0], port); | 240 | len_and_sockaddr *lsa = xhost2sockaddr(argv[0], local_port); |
242 | char *addr = xmalloc_sockaddr2dotted(&lsa->sa, lsa->len); | 241 | char *addr = xmalloc_sockaddr2dotted(&lsa->sa, lsa->len); |
243 | 242 | ||
244 | printf("%s: info: listening on %s", applet_name, addr); | 243 | printf("%s: info: listening on %s", applet_name, addr); |
@@ -246,7 +245,7 @@ int tcpsvd_main(int argc, char **argv) | |||
246 | #ifndef SSLSVD | 245 | #ifndef SSLSVD |
247 | if (option_mask32 & OPT_u) | 246 | if (option_mask32 & OPT_u) |
248 | printf(", uid %u, gid %u", | 247 | printf(", uid %u, gid %u", |
249 | (unsigned)ugid.uid, (unsigned)ugid.uid); | 248 | (unsigned)ugid.uid, (unsigned)ugid.gid); |
250 | #endif | 249 | #endif |
251 | puts(", starting"); | 250 | puts(", starting"); |
252 | } | 251 | } |
@@ -356,7 +355,7 @@ int tcpsvd_main(int argc, char **argv) | |||
356 | sockadr_size = sizeof(sock_adr); | 355 | sockadr_size = sizeof(sock_adr); |
357 | if (getsockopt(conn, SOL_IP, SO_ORIGINAL_DST, &sock_adr.sa, &sockadr_size) == 0) { | 356 | if (getsockopt(conn, SOL_IP, SO_ORIGINAL_DST, &sock_adr.sa, &sockadr_size) == 0) { |
358 | char *ip = xmalloc_sockaddr2dotted_noport(&sock_adr.sa, sockadr_size); | 357 | char *ip = xmalloc_sockaddr2dotted_noport(&sock_adr.sa, sockadr_size); |
359 | port = get_nport(&sock_adr.sa); | 358 | unsigned port = get_nport(&sock_adr.sa); |
360 | port = ntohs(port); | 359 | port = ntohs(port); |
361 | xsetenv("TCPORIGDSTIP", ip); | 360 | xsetenv("TCPORIGDSTIP", ip); |
362 | xsetenv("TCPORIGDSTPORT", utoa(port)); | 361 | xsetenv("TCPORIGDSTPORT", utoa(port)); |