#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>
* 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.
/* 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);
}
# 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>
#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);
= 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);
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)
/* Install kernel level filter if possible */
-#ifdef SO_ATTACH_FILTER
#ifdef USHRT_MAX
if (handle->fcode.bf_len > USHRT_MAX) {
/*
if (err == -2)
/* Fatal error */
return -1;
-#endif /* SO_ATTACH_FILTER */
/*
* If we're filtering in userland, there's nothing to do;
return ifr.ifr_hwaddr.sa_family;
}
-#ifdef SO_ATTACH_FILTER
static int
fix_program(pcap_t *handle, struct sock_fprog *fcode)
{
return -1;
return 0;
}
-#endif
int
pcap_set_protocol_linux(pcap_t *p, int protocol)