svn commit: trunk/busybox/networking/udhcp

vda at busybox.net vda at busybox.net
Mon Oct 27 12:56:58 UTC 2008


Author: vda
Date: 2008-10-27 05:56:58 -0700 (Mon, 27 Oct 2008)
New Revision: 23816

Log:
udhcp: simplify SO_BINDTODEVICE call



Modified:
   trunk/busybox/networking/udhcp/common.h
   trunk/busybox/networking/udhcp/socket.c


Changeset:
Modified: trunk/busybox/networking/udhcp/common.h
===================================================================
--- trunk/busybox/networking/udhcp/common.h	2008-10-27 12:37:22 UTC (rev 23815)
+++ trunk/busybox/networking/udhcp/common.h	2008-10-27 12:56:58 UTC (rev 23816)
@@ -91,8 +91,8 @@
 void udhcp_sp_setup(void) FAST_FUNC;
 int udhcp_sp_fd_set(fd_set *rfds, int extra_fd) FAST_FUNC;
 int udhcp_sp_read(const fd_set *rfds) FAST_FUNC;
+int udhcp_read_interface(const char *interface, int *ifindex, uint32_t *addr, uint8_t *arp) FAST_FUNC;
 int udhcp_raw_socket(int ifindex) FAST_FUNC;
-int udhcp_read_interface(const char *interface, int *ifindex, uint32_t *addr, uint8_t *arp) FAST_FUNC;
 int udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf) FAST_FUNC;
 /* Returns 1 if no reply received */
 int arpping(uint32_t test_ip, uint32_t from_ip, uint8_t *from_mac, const char *interface) FAST_FUNC;

Modified: trunk/busybox/networking/udhcp/socket.c
===================================================================
--- trunk/busybox/networking/udhcp/socket.c	2008-10-27 12:37:22 UTC (rev 23815)
+++ trunk/busybox/networking/udhcp/socket.c	2008-10-27 12:56:58 UTC (rev 23816)
@@ -88,7 +88,6 @@
 int FAST_FUNC udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf)
 {
 	int fd;
-	struct ifreq interface;
 	struct sockaddr_in addr;
 
 	DEBUG("Opening listen socket on *:%d %s", port, inf);
@@ -98,8 +97,8 @@
 	if (setsockopt_broadcast(fd) == -1)
 		bb_perror_msg_and_die("SO_BROADCAST");
 
-	strncpy(interface.ifr_name, inf, IFNAMSIZ);
-	if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &interface, sizeof(interface)) == -1)
+	/* NB: bug 1032 says this doesn't work on ethernet aliases (ethN:M) */
+	if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &inf, strlen(inf) + 1) == -1)
 		bb_perror_msg_and_die("SO_BINDTODEVICE");
 
 	memset(&addr, 0, sizeof(addr));




More information about the busybox-cvs mailing list