summaryrefslogtreecommitdiff
path: root/common/lpf.c
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2015-04-15 12:46:52 -0700
committerShawn Routhier <sar@isc.org>2015-04-15 12:46:52 -0700
commit1c0b7d66b67f85c96f62d94896ad6403fffc79dc (patch)
tree68a1a1931d1aabf3498c2d476f0e329c9db6a991 /common/lpf.c
parent20c0fdc783818e264c467995904bcd1156913cdd (diff)
downloadisc-dhcp-1c0b7d66b67f85c96f62d94896ad6403fffc79dc.tar.gz
[master] Expand use of #ifdef PACKET_AUXDATA to cover allocating cmsgbuf
Most of the use of tpacket_auxdata was alredy protected by PACKET_AUXDATA this patch covers trying to find the proper size for the cmsgbuf.
Diffstat (limited to 'common/lpf.c')
-rw-r--r--common/lpf.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/common/lpf.c b/common/lpf.c
index cd430dd7..7889b6bb 100644
--- a/common/lpf.c
+++ b/common/lpf.c
@@ -368,17 +368,30 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
unsigned char ibuf [1536];
unsigned bufix = 0;
unsigned paylen;
- unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))];
struct iovec iov = {
.iov_base = ibuf,
.iov_len = sizeof ibuf,
};
+#ifdef PACKET_AUXDATA
+ /*
+ * We only need cmsgbuf if we are getting the aux data and we
+ * only get the auxdata if it is actually defined
+ */
+ unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))];
struct msghdr msg = {
.msg_iov = &iov,
.msg_iovlen = 1,
.msg_control = cmsgbuf,
.msg_controllen = sizeof(cmsgbuf),
};
+#else
+ struct msghdr msg = {
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ .msg_control = NULL,
+ .msg_controllen = 0,
+ };
+#endif /* PACKET_AUXDATA */
length = recvmsg (interface->rfdesc, &msg, 0);
if (length <= 0)
@@ -422,7 +435,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
}
}
-#endif
+#endif /* PACKET_AUXDATA */
bufix = 0;
/* Decode the physical header... */