From: Tomek Mrugalski Date: Tue, 10 May 2011 14:38:58 +0000 (+0000) Subject: Linux Packet Filter interface improvement. sockaddr_pkt structure is used, X-Git-Tag: v4_2_2b1~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9e5f130f6a68ecc0173a81002d674d3cb2a6a565;p=thirdparty%2Fdhcp.git Linux Packet Filter interface improvement. sockaddr_pkt structure is used, rather than sockaddr. Packet ethertype is now forced to ETH_P_IP. [ISC-Bugs #18975] --- diff --git a/RELNOTES b/RELNOTES index 5d2a1e7c3..a33da14c1 100644 --- a/RELNOTES +++ b/RELNOTES @@ -111,6 +111,10 @@ work on other platforms. Please report any problems and suggested fixes to [ISC-Bugs #19615] update the includes in dhcpctl/dhcpctl.3 to be more correct [ISC-Bugs #20676] update dhcpd.conf.5 to include the RFC numbers for DDNS +- Linux Packet Filter interface improvement. sockaddr_pkt structure is used, + rather than sockaddr. Packet etherType is now forced to ETH_P_IP. + [ISC-Bugs #18975] + Changes since 4.2.1rc1 - None diff --git a/common/lpf.c b/common/lpf.c index f727b7cc5..16eecc958 100644 --- a/common/lpf.c +++ b/common/lpf.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "includes/netinet/ip.h" #include "includes/netinet/udp.h" #include "includes/netinet/if_ether.h" @@ -294,7 +295,7 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) double hh [16]; double ih [1536 / sizeof (double)]; unsigned char *buf = (unsigned char *)ih; - struct sockaddr sa; + struct sockaddr_pkt sa; int result; int fudge; @@ -318,12 +319,14 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) /* For some reason, SOCK_PACKET sockets can't be connected, so we have to do a sentdo every time. */ memset (&sa, 0, sizeof sa); - sa.sa_family = AF_PACKET; - strncpy (sa.sa_data, - (const char *)interface -> ifp, sizeof sa.sa_data); + sa.spkt_family = AF_PACKET; + strncpy ((char *)sa.spkt_device, + (const char *)interface -> ifp, sizeof sa.spkt_device); + sa.spkt_protocol = htons(ETH_P_IP); result = sendto (interface -> wfdesc, - buf + fudge, ibufp + len - fudge, 0, &sa, sizeof sa); + buf + fudge, ibufp + len - fudge, 0, + (const struct sockaddr *)&sa, sizeof sa); if (result < 0) log_error ("send_packet: %m"); return result;