diff options
author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-11-10 22:37:40 +0000 |
---|---|---|
committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-11-10 22:37:40 +0000 |
commit | 13e1cca6babb6cb5b6e1de4bb775160eb053308c (patch) | |
tree | 984ee95b3af3026abe492f8541073efae98f2190 /networking | |
parent | 6e8eb2d68632ca2cb133f237e5eac060bce70418 (diff) | |
download | busybox-w32-13e1cca6babb6cb5b6e1de4bb775160eb053308c.tar.gz busybox-w32-13e1cca6babb6cb5b6e1de4bb775160eb053308c.tar.bz2 busybox-w32-13e1cca6babb6cb5b6e1de4bb775160eb053308c.zip |
telnetd -b (bind to specific address) support from Iuri Gomes Diniz.
git-svn-id: svn://busybox.net/trunk/busybox@12205 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking')
-rw-r--r-- | networking/telnetd.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/networking/telnetd.c b/networking/telnetd.c index b3d0a1166..d5de8903c 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <unistd.h> | 33 | #include <unistd.h> |
34 | #include <errno.h> | 34 | #include <errno.h> |
35 | #include <netinet/in.h> | 35 | #include <netinet/in.h> |
36 | #include <arpa/inet.h> | ||
36 | #include <fcntl.h> | 37 | #include <fcntl.h> |
37 | #include <stdio.h> | 38 | #include <stdio.h> |
38 | #include <signal.h> | 39 | #include <signal.h> |
@@ -390,13 +391,14 @@ telnetd_main(int argc, char **argv) | |||
390 | #ifndef CONFIG_FEATURE_TELNETD_INETD | 391 | #ifndef CONFIG_FEATURE_TELNETD_INETD |
391 | int on = 1; | 392 | int on = 1; |
392 | int portnbr = 23; | 393 | int portnbr = 23; |
394 | struct in_addr bind_addr = { .s_addr = 0x0 }; | ||
393 | #endif /* CONFIG_FEATURE_TELNETD_INETD */ | 395 | #endif /* CONFIG_FEATURE_TELNETD_INETD */ |
394 | int c; | 396 | int c; |
395 | static const char options[] = | 397 | static const char options[] = |
396 | #ifdef CONFIG_FEATURE_TELNETD_INETD | 398 | #ifdef CONFIG_FEATURE_TELNETD_INETD |
397 | "f:l:"; | 399 | "f:l:"; |
398 | #else /* CONFIG_EATURE_TELNETD_INETD */ | 400 | #else /* CONFIG_EATURE_TELNETD_INETD */ |
399 | "f:l:p:"; | 401 | "f:l:p:b:"; |
400 | #endif /* CONFIG_FEATURE_TELNETD_INETD */ | 402 | #endif /* CONFIG_FEATURE_TELNETD_INETD */ |
401 | int maxlen, w, r; | 403 | int maxlen, w, r; |
402 | 404 | ||
@@ -418,6 +420,10 @@ telnetd_main(int argc, char **argv) | |||
418 | case 'p': | 420 | case 'p': |
419 | portnbr = atoi(optarg); | 421 | portnbr = atoi(optarg); |
420 | break; | 422 | break; |
423 | case 'b': | ||
424 | if (inet_aton(optarg, &bind_addr) == 0) | ||
425 | bb_show_usage(); | ||
426 | break; | ||
421 | #endif /* CONFIG_FEATURE_TELNETD_INETD */ | 427 | #endif /* CONFIG_FEATURE_TELNETD_INETD */ |
422 | default: | 428 | default: |
423 | bb_show_usage(); | 429 | bb_show_usage(); |
@@ -452,9 +458,11 @@ telnetd_main(int argc, char **argv) | |||
452 | #ifdef CONFIG_FEATURE_IPV6 | 458 | #ifdef CONFIG_FEATURE_IPV6 |
453 | sa.sin6_family = AF_INET6; | 459 | sa.sin6_family = AF_INET6; |
454 | sa.sin6_port = htons(portnbr); | 460 | sa.sin6_port = htons(portnbr); |
461 | /* sa.sin6_addr = bind_addr6; */ | ||
455 | #else | 462 | #else |
456 | sa.sin_family = AF_INET; | 463 | sa.sin_family = AF_INET; |
457 | sa.sin_port = htons(portnbr); | 464 | sa.sin_port = htons(portnbr); |
465 | sa.sin_addr = bind_addr; | ||
458 | #endif | 466 | #endif |
459 | 467 | ||
460 | if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { | 468 | if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { |