diff options
author | Bernhard Reutner-Fischer | 2006-12-19 16:31:09 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer | 2006-12-19 16:31:09 +0000 |
commit | 28fbd69bf8a0482de2816cc189fdd0e9ed551997 (patch) | |
tree | c2d7e7b1e0b9b87748cb74b52dd3599d5500feca /networking/udhcp | |
parent | 359d7ca0e70d4acfc3b7e792bf28f5b5581af8ff (diff) | |
download | busybox-28fbd69bf8a0482de2816cc189fdd0e9ed551997.zip busybox-28fbd69bf8a0482de2816cc189fdd0e9ed551997.tar.gz |
- use xlisten/xsocket some more. Saves .25 kB
Diffstat (limited to 'networking/udhcp')
-rw-r--r-- | networking/udhcp/clientsocket.c | 12 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 4 | ||||
-rw-r--r-- | networking/udhcp/dhcpd.c | 4 | ||||
-rw-r--r-- | networking/udhcp/dhcprelay.c | 4 | ||||
-rw-r--r-- | networking/udhcp/socket.c | 6 |
5 files changed, 3 insertions, 27 deletions
diff --git a/networking/udhcp/clientsocket.c b/networking/udhcp/clientsocket.c index b8803f0..541f883 100644 --- a/networking/udhcp/clientsocket.c +++ b/networking/udhcp/clientsocket.c @@ -40,20 +40,12 @@ int raw_socket(int ifindex) struct sockaddr_ll sock; DEBUG("Opening raw socket on ifindex %d", ifindex); - fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)); - if (fd < 0) { - bb_perror_msg("socket"); - return -1; - } + fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)); sock.sll_family = AF_PACKET; sock.sll_protocol = htons(ETH_P_IP); sock.sll_ifindex = ifindex; - if (bind(fd, (struct sockaddr *) &sock, sizeof(sock)) < 0) { - bb_perror_msg("bind"); - close(fd); - return -1; - } + xbind(fd, (struct sockaddr *) &sock, sizeof(sock)); return fd; } diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 71315ff..e042da8 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -278,10 +278,6 @@ int udhcpc_main(int argc, char *argv[]) fd = listen_socket(INADDR_ANY, CLIENT_PORT, client_config.interface); else fd = raw_socket(client_config.ifindex); - if (fd < 0) { - bb_perror_msg("FATAL: cannot listen on socket"); - return 0; - } } max_fd = udhcp_sp_fd_set(&rfds, fd); diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 7438036..7d0b8fa 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c @@ -70,10 +70,6 @@ int udhcpd_main(int argc, char *argv[]) if (server_socket < 0) { server_socket = listen_socket(INADDR_ANY, SERVER_PORT, server_config.interface); - if (server_socket < 0) { - bb_perror_msg("FATAL: cannot create server socket"); - return 2; - } } max_sock = udhcp_sp_fd_set(&rfds, server_socket); diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index e3a8168..0527394 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c @@ -169,7 +169,6 @@ static int init_sockets(char **client, int num_clients, /* talk to real server on bootps */ fds[0] = listen_socket(htonl(INADDR_ANY), 67, server); - if (fds[0] < 0) return -1; *max_socket = fds[0]; /* array starts at 1 since server is 0 */ @@ -178,7 +177,6 @@ static int init_sockets(char **client, int num_clients, for (i=1; i < num_clients; i++) { /* listen for clients on bootps */ fds[i] = listen_socket(htonl(INADDR_ANY), 67, client[i-1]); - if (fds[i] < 0) return -1; if (fds[i] > *max_socket) *max_socket = fds[i]; } @@ -321,8 +319,6 @@ int dhcprelay_main(int argc, char **argv) signal(SIGINT, dhcprelay_signal_handler); num_sockets = init_sockets(clients, num_sockets, argv[2], fds, &max_socket); - if (num_sockets == -1) - bb_perror_msg_and_die("init_sockets() failed"); if (read_interface(argv[2], NULL, &gw_ip, NULL) == -1) return 1; diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c index 9ea2002..8138f5a 100644 --- a/networking/udhcp/socket.c +++ b/networking/udhcp/socket.c @@ -95,11 +95,7 @@ int listen_socket(uint32_t ip, int port, char *inf) struct sockaddr_in addr; DEBUG("Opening listen socket on 0x%08x:%d %s", ip, port, inf); - fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (fd < 0) { - bb_perror_msg("socket"); - return -1; - } + fd = xsocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; |