]> The Tcpdump Group git mirrors - libpcap/commitdiff
Handle older kernels that don't define PACKET_RESERVE.
authorGuy Harris <[email protected]>
Mon, 4 Apr 2011 16:57:18 +0000 (09:57 -0700)
committerGuy Harris <[email protected]>
Mon, 4 Apr 2011 16:57:18 +0000 (09:57 -0700)
pcap-linux.c

index 638b1c00f02328a103086600a13ddf6dd21c07ff..8e394f4feed164fbdc9927c8e0cdfb1c53b010fa 100644 (file)
@@ -3196,12 +3196,16 @@ create_ring(pcap_t *handle, int *status)
                *status = PCAP_ERROR;
                return -1;
        }
                *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;
        }
        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
        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