]> The Tcpdump Group git mirrors - libpcap/commitdiff
Fix multiple declaration of bpf_ functions 752/head
authorbleader <[email protected]>
Fri, 10 Aug 2018 08:46:41 +0000 (10:46 +0200)
committerbleader <[email protected]>
Thu, 30 Aug 2018 09:05:10 +0000 (11:05 +0200)
pcap.h will include pcap/pcap.h and pcap/bpf.h that both defines the
bpf_filter and bpf_validate functions.

In most cases this won't be an issue, most people are using the libpcap
as a system library, gcc preprocessor will therefore disable part of the
warnings according to the `3` in
https://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html

In case libpcap is included in a project that actually have more warning
(-Wredundant-decls), and also using local headers we end up having quite
a lot of warning.

pcap/bpf.h
pcap/pcap.h

index 1a953a9b71d8947acf88db787fddcb1d914078b7..742a3428e1fbc879e558f4a2d42fd8213d7f945c 100644 (file)
@@ -254,9 +254,20 @@ struct bpf_aux_data {
 #define BPF_STMT(code, k) { (u_short)(code), 0, 0, k }
 #define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k }
 
-PCAP_API int bpf_validate(const struct bpf_insn *, int);
-PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
+/*
+ * On at least some versions of NetBSD and QNX, we don't want to declare
+ * bpf_filter() here, as it's also be declared in <net/bpf.h>, with a
+ * different signature, but, on other BSD-flavored UN*Xes, it's not
+ * declared in <net/bpf.h>, so we *do* want to declare it here, so it's
+ * declared when we build pcap-bpf.c.
+ */
+#if !defined(__NetBSD__) && !defined(__QNX__)
+  PCAP_API u_int       bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
+#endif
 extern u_int bpf_filter_with_aux_data(const struct bpf_insn *, const u_char *, u_int, u_int, const struct bpf_aux_data *);
+PCAP_API int   bpf_validate(const struct bpf_insn *f, int len);
+PCAP_API char  *bpf_image(const struct bpf_insn *, int);
+PCAP_API void  bpf_dump(const struct bpf_program *, int);
 
 /*
  * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
index f7ef643e1ff0936b00430cb9a54a21d621922ff4..e13e7ee2f7996a2d2adb36de4405676ced41b7e8 100644 (file)
@@ -513,20 +513,6 @@ PCAP_API void      pcap_freealldevs(pcap_if_t *);
  */
 PCAP_API const char *pcap_lib_version(void);
 
-/*
- * On at least some versions of NetBSD and QNX, we don't want to declare
- * bpf_filter() here, as it's also be declared in <net/bpf.h>, with a
- * different signature, but, on other BSD-flavored UN*Xes, it's not
- * declared in <net/bpf.h>, so we *do* want to declare it here, so it's
- * declared when we build pcap-bpf.c.
- */
-#if !defined(__NetBSD__) && !defined(__QNX__)
-  PCAP_API u_int       bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
-#endif
-PCAP_API int   bpf_validate(const struct bpf_insn *f, int len);
-PCAP_API char  *bpf_image(const struct bpf_insn *, int);
-PCAP_API void  bpf_dump(const struct bpf_program *, int);
-
 #if defined(_WIN32)
 
   /*