summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer2006-12-19 16:31:09 +0000
committerBernhard Reutner-Fischer2006-12-19 16:31:09 +0000
commit28fbd69bf8a0482de2816cc189fdd0e9ed551997 (patch)
treec2d7e7b1e0b9b87748cb74b52dd3599d5500feca
parent359d7ca0e70d4acfc3b7e792bf28f5b5581af8ff (diff)
downloadbusybox-28fbd69bf8a0482de2816cc189fdd0e9ed551997.zip
busybox-28fbd69bf8a0482de2816cc189fdd0e9ed551997.tar.gz
- use xlisten/xsocket some more. Saves .25 kB
-rw-r--r--networking/dnsd.c14
-rw-r--r--networking/udhcp/clientsocket.c12
-rw-r--r--networking/udhcp/dhcpc.c4
-rw-r--r--networking/udhcp/dhcpd.c4
-rw-r--r--networking/udhcp/dhcprelay.c4
-rw-r--r--networking/udhcp/socket.c6
6 files changed, 9 insertions, 35 deletions
diff --git a/networking/dnsd.c b/networking/dnsd.c
index 5e9cf52..6f1ec0e 100644
--- a/networking/dnsd.c
+++ b/networking/dnsd.c
@@ -199,21 +199,21 @@ static int listen_socket(char *iface_addr, int listen_port)
{
struct sockaddr_in a;
char msg[100];
- int s;
- s = xsocket(PF_INET, SOCK_DGRAM, 0);
- if (setsockopt_reuseaddr(s) < 0)
+ int sck;
+ sck = xsocket(PF_INET, SOCK_DGRAM, 0);
+ if (setsockopt_reuseaddr(sck) < 0)
bb_perror_msg_and_die("setsockopt() failed");
memset(&a, 0, sizeof(a));
a.sin_port = htons(listen_port);
a.sin_family = AF_INET;
if (!inet_aton(iface_addr, &a.sin_addr))
bb_perror_msg_and_die("bad iface address");
- xbind(s, (struct sockaddr *)&a, sizeof(a));
- xlisten(s, 50);
+ xbind(sck, (struct sockaddr *)&a, sizeof(a));
+ xlisten(sck, 50);
sprintf(msg, "accepting UDP packets on addr:port %s:%d\n",
iface_addr, (int)listen_port);
log_message(LOG_FILE, msg);
- return s;
+ return sck;
}
/*
@@ -412,8 +412,6 @@ int dnsd_main(int argc, char **argv)
#endif
udps = listen_socket(listen_interface, port);
- if (udps < 0)
- exit(1);
while (1) {
fd_set fdset;
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;