diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-09-14 00:18:47 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-09-14 00:18:47 -0700 |
commit | ecf2cf1f94791f2e2d0c3daf7a50da496b7ec34f (patch) | |
tree | c1d56de7e5b6be4a5e5f3b3ba213446d434744b6 | |
parent | 5dd09155abcc9a80ffdf49ff03e2bff5fb0aa31f (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.c | 3 | ||||
-rw-r--r-- | pcap-int.h | 5 | ||||
-rw-r--r-- | pcap-win32.c | 4 |
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> @@ -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> |