2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2009, 2010 Daniel Borkmann.
4 * Subject to the GPL, version 2.
10 #include <linux/filter.h>
16 extern void bpf_dump_op_table(void);
17 extern void bpf_dump_all(struct sock_fprog
*bpf
);
18 extern int __bpf_validate(const struct sock_fprog
*bpf
);
19 extern uint32_t bpf_run_filter(const struct sock_fprog
*bpf
, uint8_t *packet
,
21 extern void bpf_attach_to_sock(int sock
, struct sock_fprog
*bpf
);
22 extern void bpf_detach_from_sock(int sock
);
23 extern int enable_kernel_bpf_jit_compiler(void);
24 extern void bpf_parse_rules(char *rulefile
, struct sock_fprog
*bpf
, uint32_t link_type
);
25 #ifdef __WITH_TCPDUMP_LIKE_FILTER
26 extern void bpf_try_compile(const char *rulefile
, struct sock_fprog
*bpf
,
29 static inline void bpf_try_compile(const char *rulefile
, struct sock_fprog
*bpf
,
32 panic("Cannot open file %s!\n", rulefile
);
36 static inline void bpf_release(struct sock_fprog
*bpf
)
41 #define BPF_CLASS(code) ((code) & 0x07)
51 #define BPF_SIZE(code) ((code) & 0x18)
56 #define BPF_MODE(code) ((code) & 0xe0)
64 #define BPF_OP(code) ((code) & 0xf0)
83 #define BPF_SRC(code) ((code) & 0x08)
87 /* ret - BPF_K and BPF_X also apply */
88 #define BPF_RVAL(code) ((code) & 0x18)
91 #define BPF_MISCOP(code) ((code) & 0xf8)
96 # define SKF_AD_OFF (-0x1000)
98 #ifndef SKF_AD_PROTOCOL
99 # define SKF_AD_PROTOCOL 0
101 #ifndef SKF_AD_PKTTYPE
102 # define SKF_AD_PKTTYPE 4
104 #ifndef SKF_AD_IFINDEX
105 # define SKF_AD_IFINDEX 8
107 #ifndef SKF_AD_NLATTR
108 # define SKF_AD_NLATTR 12
110 #ifndef SKF_AD_NLATTR_NEST
111 # define SKF_AD_NLATTR_NEST 16
114 # define SKF_AD_MARK 20
117 # define SKF_AD_QUEUE 24
119 #ifndef SKF_AD_HATYPE
120 # define SKF_AD_HATYPE 28
122 #ifndef SKF_AD_RXHASH
123 # define SKF_AD_RXHASH 32
126 # define SKF_AD_CPU 36
128 #ifndef SKF_AD_VLAN_TAG
129 # define SKF_AD_VLAN_TAG 44
131 #ifndef SKF_AD_VLAN_TAG_PRESENT
132 # define SKF_AD_VLAN_TAG_PRESENT 48
134 #ifndef SKF_AD_PAY_OFFSET
135 # define SKF_AD_PAY_OFFSET 52