diff options
author | Rob Landley <rob@landley.net> | 2005-11-11 01:37:40 +0300 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2005-11-11 01:37:40 +0300 |
commit | 64a5f96780a6a507c577629a5697cdbb53f7bc9b (patch) | |
tree | 984ee95b3af3026abe492f8541073efae98f2190 /networking/telnetd.c | |
parent | 990025a7d971bbbdd982d2d070d3e47628d0fac0 (diff) |
telnetd -b (bind to specific address) support from Iuri Gomes Diniz.
Diffstat (limited to 'networking/telnetd.c')
-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 @@ #include <unistd.h> #include <errno.h> #include <netinet/in.h> +#include <arpa/inet.h> #include <fcntl.h> #include <stdio.h> #include <signal.h> @@ -390,13 +391,14 @@ telnetd_main(int argc, char **argv) #ifndef CONFIG_FEATURE_TELNETD_INETD int on = 1; int portnbr = 23; + struct in_addr bind_addr = { .s_addr = 0x0 }; #endif /* CONFIG_FEATURE_TELNETD_INETD */ int c; static const char options[] = #ifdef CONFIG_FEATURE_TELNETD_INETD "f:l:"; #else /* CONFIG_EATURE_TELNETD_INETD */ - "f:l:p:"; + "f:l:p:b:"; #endif /* CONFIG_FEATURE_TELNETD_INETD */ int maxlen, w, r; @@ -418,6 +420,10 @@ telnetd_main(int argc, char **argv) case 'p': portnbr = atoi(optarg); break; + case 'b': + if (inet_aton(optarg, &bind_addr) == 0) + bb_show_usage(); + break; #endif /* CONFIG_FEATURE_TELNETD_INETD */ default: bb_show_usage(); @@ -452,9 +458,11 @@ telnetd_main(int argc, char **argv) #ifdef CONFIG_FEATURE_IPV6 sa.sin6_family = AF_INET6; sa.sin6_port = htons(portnbr); + /* sa.sin6_addr = bind_addr6; */ #else sa.sin_family = AF_INET; sa.sin_port = htons(portnbr); + sa.sin_addr = bind_addr; #endif if (bind(master_fd, (struct sockaddr *) &sa, sizeof(sa)) < 0) { |