]> The Tcpdump Group git mirrors - libpcap/commitdiff
Don't check for PF_PACKET or SO_ATTACH_FILTER.
authorGuy Harris <[email protected]>
Tue, 18 Feb 2020 22:37:55 +0000 (14:37 -0800)
committerGuy Harris <[email protected]>
Tue, 18 Feb 2020 22:37:55 +0000 (14:37 -0800)
If we're building for Linux, we require 2.6.27 or later, and they have
PF_PACKET and SO_ATTACH_FILTER.

gencode.c
pcap-linux.c

index 040a553157163355b9ecc9a33276432e7a2bab22..b56f6f116e1c48c0d40e25e8cf5d18db0e6c453b 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -67,7 +67,7 @@
 #include "grammar.h"
 #include "scanner.h"
 
-#if defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER)
+#if defined(linux)
 #include <linux/types.h>
 #include <linux/if_packet.h>
 #include <linux/filter.h>
@@ -8302,9 +8302,9 @@ gen_inbound(compiler_state_t *cstate, int dir)
                 * with newer capture APIs, allowing it to be saved
                 * in pcapng files.
                 */
-#if defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER)
+#if defined(linux)
                /*
-                * This is Linux with PF_PACKET support.
+                * This is Linux; we assume it has PF_PACKET support.
                 * If this is a *live* capture, we can look at
                 * special meta-data in the filter expression;
                 * if it's a savefile, we can't.
@@ -8322,11 +8322,11 @@ gen_inbound(compiler_state_t *cstate, int dir)
                        /* to filter on inbound traffic, invert the match */
                        gen_not(b0);
                }
-#else /* defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER) */
+#else /* defined(linux) */
                bpf_error(cstate, "inbound/outbound not supported on %s",
                    pcap_datalink_val_to_description_or_dlt(cstate->linktype));
                /*NOTREACHED*/
-#endif /* defined(linux) && defined(PF_PACKET) && defined(SO_ATTACH_FILTER) */
+#endif /* defined(linux) */
        }
        return (b0);
 }
index cf00729776f3d6ff2a5d89587b32d51a4bb8b8c7..d80bed55a23276896b7f3d5ff5445aec29c53f9f 100644 (file)
 # define HAVE_TPACKET3
 #endif /* TPACKET3_HDRLEN */
 
-#ifdef SO_ATTACH_FILTER
 #include <linux/types.h>
 #include <linux/filter.h>
-#endif
 
 #ifdef HAVE_LINUX_NET_TSTAMP_H
 #include <linux/net_tstamp.h>
@@ -322,7 +320,6 @@ static int  iface_ethtool_get_ts_info(const char *device, pcap_t *handle,
 #endif
 static int     iface_get_offload(pcap_t *handle);
 
-#ifdef SO_ATTACH_FILTER
 static int     fix_program(pcap_t *handle, struct sock_fprog *fcode);
 static int     fix_offset(pcap_t *handle, struct bpf_insn *p);
 static int     set_kernel_filter(pcap_t *handle, struct sock_fprog *fcode);
@@ -332,7 +329,6 @@ static struct sock_filter   total_insn
        = BPF_STMT(BPF_RET | BPF_K, 0);
 static struct sock_fprog       total_fcode
        = { 1, &total_insn };
-#endif /* SO_ATTACH_FILTER */
 
 static int     iface_dsa_get_proto_info(const char *device, pcap_t *handle);
 
@@ -4376,11 +4372,9 @@ static int
 pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter)
 {
        struct pcap_linux *handlep;
-#ifdef SO_ATTACH_FILTER
        struct sock_fprog       fcode;
        int                     can_filter_in_kernel;
        int                     err = 0;
-#endif
        int                     n, offset;
 
        if (!handle)
@@ -4407,7 +4401,6 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter)
 
        /* Install kernel level filter if possible */
 
-#ifdef SO_ATTACH_FILTER
 #ifdef USHRT_MAX
        if (handle->fcode.bf_len > USHRT_MAX) {
                /*
@@ -4539,7 +4532,6 @@ pcap_setfilter_linux(pcap_t *handle, struct bpf_program *filter)
        if (err == -2)
                /* Fatal error */
                return -1;
-#endif /* SO_ATTACH_FILTER */
 
        /*
         * If we're filtering in userland, there's nothing to do;
@@ -5842,7 +5834,6 @@ iface_get_arptype(int fd, const char *device, char *ebuf)
        return ifr.ifr_hwaddr.sa_family;
 }
 
-#ifdef SO_ATTACH_FILTER
 static int
 fix_program(pcap_t *handle, struct sock_fprog *fcode)
 {
@@ -6143,7 +6134,6 @@ reset_kernel_filter(pcap_t *handle)
                return -1;
        return 0;
 }
-#endif
 
 int
 pcap_set_protocol_linux(pcap_t *p, int protocol)