svn commit: trunk/busybox: include networking

landley at busybox.net landley at busybox.net
Thu Nov 10 22:37:48 UTC 2005


Author: landley
Date: 2005-11-10 14:37:40 -0800 (Thu, 10 Nov 2005)
New Revision: 12205

Log:
telnetd -b (bind to specific address) support from Iuri Gomes Diniz.


Modified:
   trunk/busybox/include/usage.h
   trunk/busybox/networking/telnetd.c


Changeset:
Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2005-11-10 15:09:21 UTC (rev 12204)
+++ trunk/busybox/include/usage.h	2005-11-10 22:37:40 UTC (rev 12205)
@@ -2951,6 +2951,7 @@
 	"Telnetd listens for incoming TELNET connections on PORT.\n" \
 	"Options:\n" \
 	"\t-p PORT\tlisten for connections on PORT (default 23)\n" \
+	"\t-b ADDR\tlisten for connections on ADDR (default 0.0.0.0)\n"\
 	"\t-l LOGIN\texec LOGIN on connect (default /bin/sh)\n" \
 	"\t-f issue_file\tDisplay issue_file instead of /etc/issue"
 #endif

Modified: trunk/busybox/networking/telnetd.c
===================================================================
--- trunk/busybox/networking/telnetd.c	2005-11-10 15:09:21 UTC (rev 12204)
+++ trunk/busybox/networking/telnetd.c	2005-11-10 22:37:40 UTC (rev 12205)
@@ -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 @@
 #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 @@
 			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 @@
 #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) {




More information about the busybox-cvs mailing list