aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-09-14 00:18:47 -0700
committerGuy Harris <guy@alum.mit.edu>2015-09-14 00:18:47 -0700
commitecf2cf1f94791f2e2d0c3daf7a50da496b7ec34f (patch)
treec1d56de7e5b6be4a5e5f3b3ba213446d434744b6
parent5dd09155abcc9a80ffdf49ff03e2bff5fb0aa31f (diff)
Avoid collisions between pcap/bpf.h and Packet32.h structure definitions.
In most cases, avoid Packet32.h's definition of BPF structures, which are different from pcap/bpf.h's definitions, by defining BPF_MAJOR_VERSION before including it. In the cases where we *do* need Packet32.h's definitions, define PCAP_DONT_INCLUDE_PCAP_BPF_H to make sure pcap/bpf.h doesn't get included and define them, and include <Packet32.h> before pcap-int.h, *without* BPF_MAJOR_VERSION being defined, so that it defines those structures. For pcap-win32.h, also include pcap/dlt.h, so we get the DLT_ values defined.
-rwxr-xr-x[-rw-r--r--]fad-win32.c3
-rw-r--r--pcap-int.h5
-rw-r--r--pcap-win32.c4
3 files changed, 10 insertions, 2 deletions
diff --git a/fad-win32.c b/fad-win32.c
index 4f36ad2b..7b050570 100644..100755
--- a/fad-win32.c
+++ b/fad-win32.c
@@ -35,9 +35,10 @@
#include "config.h"
#endif
+#define PCAP_DONT_INCLUDE_PCAP_BPF_H
#include <pcap.h>
-#include <pcap-int.h>
#include <Packet32.h>
+#include <pcap-int.h>
#include <errno.h>
diff --git a/pcap-int.h b/pcap-int.h
index 655c19d9..8abbf254 100644
--- a/pcap-int.h
+++ b/pcap-int.h
@@ -41,6 +41,11 @@ extern "C" {
#endif
#ifdef _WIN32
+/*
+ * Make sure Packet32.h doesn't define BPF structures that we've
+ * probably already defined as a result of including <pcap/pcap.h>.
+ */
+#define BPF_MAJOR_VERSION
#include <Packet32.h>
extern CRITICAL_SECTION g_PcapCompileCriticalSection;
#endif /* _WIN32 */
diff --git a/pcap-win32.c b/pcap-win32.c
index 63ba6302..ed754600 100644
--- a/pcap-win32.c
+++ b/pcap-win32.c
@@ -31,8 +31,10 @@
*
*/
-#include <pcap-int.h>
+#define PCAP_DONT_INCLUDE_PCAP_BPF_H
#include <Packet32.h>
+#include <pcap-int.h>
+#include <pcap/dlt.h>
#ifdef __MINGW32__
#ifdef __MINGW64__
#include <ntddndis.h>