summaryrefslogtreecommitdiff
path: root/networking/udhcp/socket.c
diff options
context:
space:
mode:
authorDenis Vlasenko2006-11-22 23:22:06 +0000
committerDenis Vlasenko2006-11-22 23:22:06 +0000
commit48237b0c88343154d58854020c3a9c8b07c61b10 (patch)
treeb36bc84f22dd797b45c8d665e50e2f6c690e1370 /networking/udhcp/socket.c
parentb40bdb383a6b7a7f0fd36d0b1cc24deb42cd5f0d (diff)
downloadbusybox-48237b0c88343154d58854020c3a9c8b07c61b10.zip
busybox-48237b0c88343154d58854020c3a9c8b07c61b10.tar.gz
introduce setsockopt_reuseaddr(int fd), setsockopt_broadcast(int fd),
use them where appropriate. 200 bytes saved
Diffstat (limited to 'networking/udhcp/socket.c')
-rw-r--r--networking/udhcp/socket.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c
index c19131d..b27dca3 100644
--- a/networking/udhcp/socket.c
+++ b/networking/udhcp/socket.c
@@ -93,7 +93,6 @@ int listen_socket(uint32_t ip, int port, char *inf)
struct ifreq interface;
int fd;
struct sockaddr_in addr;
- int n = 1;
DEBUG("Opening listen socket on 0x%08x:%d %s", ip, port, inf);
fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
@@ -107,17 +106,17 @@ int listen_socket(uint32_t ip, int port, char *inf)
addr.sin_port = htons(port);
addr.sin_addr.s_addr = ip;
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) == -1) {
+ if (setsockopt_reuseaddr(fd) == -1) {
close(fd);
return -1;
}
- if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (char *) &n, sizeof(n)) == -1) {
+ if (setsockopt_broadcast(fd) == -1) {
close(fd);
return -1;
}
strncpy(interface.ifr_name, inf, IFNAMSIZ);
- if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE,(char *)&interface, sizeof(interface)) < 0) {
+ if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, (char *)&interface, sizeof(interface)) < 0) {
close(fd);
return -1;
}