aboutsummaryrefslogtreecommitdiff
path: root/pcap/bpf.h
diff options
context:
space:
mode:
Diffstat (limited to 'pcap/bpf.h')
-rw-r--r--pcap/bpf.h38
1 files changed, 28 insertions, 10 deletions
diff --git a/pcap/bpf.h b/pcap/bpf.h
index 95ea2abc..f8132582 100644
--- a/pcap/bpf.h
+++ b/pcap/bpf.h
@@ -79,7 +79,15 @@
#if !defined(_NET_BPF_H_) && !defined(_NET_BPF_H_INCLUDED) && !defined(_BPF_H_) && !defined(_H_BPF) && !defined(lib_pcap_bpf_h)
#define lib_pcap_bpf_h
+/* u_char, u_short and u_int */
+#if defined(_WIN32)
+ #include <winsock2.h>
+#elif defined(HAVE_SYS_TYPES_H)
+ #include <sys/types.h>
+#endif
+
#include <pcap/funcattrs.h>
+#include <pcap/dlt.h>
#ifdef __cplusplus
extern "C" {
@@ -117,10 +125,6 @@ struct bpf_program {
struct bpf_insn *bf_insns;
};
-#include <pcap/dlt.h>
-
-#ifndef __LINUX_FILTER_H__
-
/*
* The instruction encodings.
*
@@ -241,8 +245,6 @@ struct bpf_program {
/* 0xf0 reserved */
/* 0xf8 reserved */
-#endif /* __LINUX_FILTER_H__ */
-
/*
* The instruction data structure.
*/
@@ -253,19 +255,35 @@ struct bpf_insn {
bpf_u_int32 k;
};
-#ifndef __LINUX_FILTER_H__
-
/*
* Macros for insn array initializers.
+ *
+ * In case somebody's included <linux/filter.h>, or something else that
+ * gives the kernel's definitions of BPF statements, get rid of its
+ * definitions, so we can supply ours instead. If some kernel's
+ * definitions aren't *binary-compatible* with what BPF has had
+ * since it first sprung from the brows of Van Jacobson and Steve
+ * McCanne, that kernel should be fixed.
*/
+#ifdef BPF_STMT
+#undef BPF_STMT
+#endif
#define BPF_STMT(code, k) { (u_short)(code), 0, 0, k }
+#ifdef BPF_JUMP
+#undef BPF_JUMP
+#endif
#define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k }
-#endif /* __LINUX_FILTER_H__ */
-
+PCAP_AVAILABLE_0_4
PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
+
+PCAP_AVAILABLE_0_6
PCAP_API int bpf_validate(const struct bpf_insn *f, int len);
+
+PCAP_AVAILABLE_0_4
PCAP_API char *bpf_image(const struct bpf_insn *, int);
+
+PCAP_AVAILABLE_0_6
PCAP_API void bpf_dump(const struct bpf_program *, int);
/*