Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/networking/udhcp/clientsocket.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/networking/udhcp/clientsocket.c
r821 r1770 1 /* vi: set sw=4 ts=4: */ 1 2 /* 2 3 * clientsocket.c -- DHCP client socket creation … … 21 22 */ 22 23 23 #include <sys/types.h>24 #include <sys/socket.h>25 #include <unistd.h>26 #include <netinet/in.h>27 24 #include <features.h> 28 #if ( __GLIBC__ >= 2 && __GLIBC_MINOR >= 1) || defined _NEWLIB_VERSION25 #if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined(_NEWLIB_VERSION) 29 26 #include <netpacket/packet.h> 30 27 #include <net/ethernet.h> … … 35 32 #endif 36 33 37 #include "clientsocket.h"38 34 #include "common.h" 39 35 … … 44 40 struct sockaddr_ll sock; 45 41 46 DEBUG(LOG_INFO, "Opening raw socket on ifindex %d", ifindex); 47 if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { 48 DEBUG(LOG_ERR, "socket call failed: %m"); 49 return -1; 50 } 42 DEBUG("Opening raw socket on ifindex %d", ifindex); 43 fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)); 51 44 52 45 sock.sll_family = AF_PACKET; 53 46 sock.sll_protocol = htons(ETH_P_IP); 54 47 sock.sll_ifindex = ifindex; 55 if (bind(fd, (struct sockaddr *) &sock, sizeof(sock)) < 0) { 56 DEBUG(LOG_ERR, "bind call failed: %m"); 57 close(fd); 58 return -1; 59 } 48 xbind(fd, (struct sockaddr *) &sock, sizeof(sock)); 60 49 61 50 return fd;
Note:
See TracChangeset
for help on using the changeset viewer.