Changeset 3306 in MondoRescue
- Timestamp:
- Jul 2, 2014, 10:34:07 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/networking/udhcp/dhcpc.c
r3232 r3306 26 26 #include "dhcpc.h" 27 27 28 #include <netinet/if_ether.h> 28 #include <asm/types.h> 29 #if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined(_NEWLIB_VERSION) 30 # include <netpacket/packet.h> 31 # include <net/ethernet.h> 32 #else 33 # include <linux/if_packet.h> 34 # include <linux/if_ether.h> 35 #endif 29 36 #include <linux/filter.h> 30 #include <linux/if_packet.h>31 37 32 38 /* "struct client_config_t client_config" is in bb_common_bufsiz1 */ … … 837 843 struct ip_udp_dhcp_packet packet; 838 844 uint16_t check; 845 #ifdef PACKET_AUXDATA 839 846 unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))]; 847 struct cmsghdr *cmsg; 848 #endif 840 849 struct iovec iov; 841 850 struct msghdr msg; 842 struct cmsghdr *cmsg; 843 851 852 #ifdef PACKET_AUXDATA 844 853 /* used to use just safe_read(fd, &packet, sizeof(packet)) 845 854 * but we need to check for TP_STATUS_CSUMNOTREADY :( … … 863 872 break; 864 873 } 874 #else 875 memset(&packet, 0, sizeof(packet)); 876 bytes = safe_read(fd, &packet, sizeof(packet)); 877 if (bytes < 0) { 878 log1("Packet read error, ignoring"); 879 /* NB: possible down interface, etc. Caller should pause. */ 880 return bytes; /* returns -1 */ 881 } 882 #endif 865 883 866 884 if (bytes < (int) (sizeof(packet.ip) + sizeof(packet.udp))) { … … 898 916 } 899 917 918 #ifdef PACKET_AUXDATA 900 919 for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { 901 920 if (cmsg->cmsg_level == SOL_PACKET … … 911 930 } 912 931 } 932 #endif 913 933 914 934 /* verify UDP checksum. IP header has to be modified for this */ … … 922 942 return -2; 923 943 } 944 #ifdef PACKET_AUXDATA 924 945 skip_udp_sum_check: 946 #endif 925 947 926 948 if (packet.data.cookie != htonl(DHCP_MAGIC)) { … … 1033 1055 } 1034 1056 1057 #ifdef PACKET_AUXDATA 1035 1058 if (setsockopt(fd, SOL_PACKET, PACKET_AUXDATA, 1036 1059 &const_int_1, sizeof(int)) < 0 … … 1039 1062 log1("Can't set PACKET_AUXDATA on raw socket"); 1040 1063 } 1064 #else 1065 sock.sll_family = AF_PACKET; 1066 sock.sll_protocol = htons(ETH_P_IP); 1067 sock.sll_ifindex = ifindex; 1068 xbind(fd, (struct sockaddr *) &sock, sizeof(sock)); 1069 #endif 1041 1070 1042 1071 log1("Created raw socket");
Note:
See TracChangeset
for help on using the changeset viewer.