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
,
30 struct sock_fprog
*bpf __maybe_unused
,
31 uint32_t link_type __maybe_unused
)
33 panic("Cannot open file %s!\n", rulefile
);
37 static inline void bpf_release(struct sock_fprog
*bpf
)
42 #define BPF_CLASS(code) ((code) & 0x07)
52 #define BPF_SIZE(code) ((code) & 0x18)
57 #define BPF_MODE(code) ((code) & 0xe0)
65 #define BPF_OP(code) ((code) & 0xf0)
84 #define BPF_SRC(code) ((code) & 0x08)
88 /* ret - BPF_K and BPF_X also apply */
89 #define BPF_RVAL(code) ((code) & 0x18)
92 #define BPF_MISCOP(code) ((code) & 0xf8)
97 # define SKF_AD_OFF (-0x1000)
99 #ifndef SKF_AD_PROTOCOL
100 # define SKF_AD_PROTOCOL 0
102 #ifndef SKF_AD_PKTTYPE
103 # define SKF_AD_PKTTYPE 4
105 #ifndef SKF_AD_IFINDEX
106 # define SKF_AD_IFINDEX 8
108 #ifndef SKF_AD_NLATTR
109 # define SKF_AD_NLATTR 12
111 #ifndef SKF_AD_NLATTR_NEST
112 # define SKF_AD_NLATTR_NEST 16
115 # define SKF_AD_MARK 20
118 # define SKF_AD_QUEUE 24
120 #ifndef SKF_AD_HATYPE
121 # define SKF_AD_HATYPE 28
123 #ifndef SKF_AD_RXHASH
124 # define SKF_AD_RXHASH 32
127 # define SKF_AD_CPU 36
129 #ifndef SKF_AD_VLAN_TAG
130 # define SKF_AD_VLAN_TAG 44
132 #ifndef SKF_AD_VLAN_TAG_PRESENT
133 # define SKF_AD_VLAN_TAG_PRESENT 48
135 #ifndef SKF_AD_PAY_OFFSET
136 # define SKF_AD_PAY_OFFSET 52