summaryrefslogtreecommitdiff
path: root/common/lpf.c
diff options
context:
space:
mode:
authorTomek Mrugalski <tomek@isc.org>2011-05-10 14:27:56 +0000
committerTomek Mrugalski <tomek@isc.org>2011-05-10 14:27:56 +0000
commit9369bdc12134dcad9fc5362bc479cf689a37e06d (patch)
treee40b4208e0b848eed0847a1c5291200ca425e4ca /common/lpf.c
parentc6455252e8cd83262b624cead85c731ad318b43f (diff)
downloadisc-dhcp-9369bdc12134dcad9fc5362bc479cf689a37e06d.tar.gz
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]
Diffstat (limited to 'common/lpf.c')
-rw-r--r--common/lpf.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/common/lpf.c b/common/lpf.c
index f727b7cc..16eecc95 100644
--- a/common/lpf.c
+++ b/common/lpf.c
@@ -36,6 +36,7 @@
#include <linux/filter.h>
#include <linux/if_ether.h>
#include <netinet/in_systm.h>
+#include <net/if_packet.h>
#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;