From: Guy Harris Date: Mon, 4 Apr 2011 16:57:18 +0000 (-0700) Subject: Handle older kernels that don't define PACKET_RESERVE. X-Git-Tag: libpcap-1.2.1~66 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/dad71a62725eb07eb2470abfca1420aaa7299432?ds=sidebyside Handle older kernels that don't define PACKET_RESERVE. --- diff --git a/pcap-linux.c b/pcap-linux.c index 638b1c00..8e394f4f 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -3196,12 +3196,16 @@ create_ring(pcap_t *handle, int *status) *status = PCAP_ERROR; return -1; } +#ifdef PACKET_RESERVE len = sizeof(tp_reserve); if (getsockopt(handle->fd, SOL_PACKET, PACKET_RESERVE, &tp_reserve, &len) < 0) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "getsockopt: %s", pcap_strerror(errno)); *status = PCAP_ERROR; return -1; } +#else + tp_reserve = 0; /* older kernel, reserve not supported */ +#endif maclen = (sk_type == SOCK_DGRAM) ? 0 : MAX_LINKHEADER_SIZE; /* XXX: in the kernel maclen is calculated from * LL_ALLOCATED_SPACE(dev) and vnet_hdr.hdr_len