rt_names: stop allocating 5k in rwdata
[oweals/busybox.git] / networking / udhcp / clientsocket.c
index 5d08421b3109007f0c18fea30f1cf7f8acb5b6a1..541f883b5bfb6570beb4bc2a7ee95c3cb0a3371c 100644 (file)
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
 /*
  * clientsocket.c -- DHCP client socket creation
  *
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <netinet/in.h>
 #include <features.h>
-#if (__GLIBC__ >= 2 && __GLIBC_MINOR >= 1) || defined _NEWLIB_VERSION
+#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined(_NEWLIB_VERSION)
 #include <netpacket/packet.h>
 #include <net/ethernet.h>
 #else
@@ -34,7 +31,6 @@
 #include <linux/if_ether.h>
 #endif
 
-#include "clientsocket.h"
 #include "common.h"
 
 
@@ -43,20 +39,13 @@ int raw_socket(int ifindex)
        int fd;
        struct sockaddr_ll sock;
 
-       DEBUG(LOG_INFO, "Opening raw socket on ifindex %d", ifindex);
-       if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
-               DEBUG(LOG_ERR, "socket call failed: %m");
-               return -1;
-       }
+       DEBUG("Opening raw socket on ifindex %d", ifindex);
+       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) {
-               DEBUG(LOG_ERR, "bind call failed: %m");
-               close(fd);
-               return -1;
-       }
+       xbind(fd, (struct sockaddr *) &sock, sizeof(sock));
 
        return fd;
 }