Open sgeto opened 7 years ago
They should be (re)moved or better guarded. So for example #ifndef BPF_MAJOR_VERSION should say #if !defined (BPF_MAJOR_VERSION) && defined (PCAP_DONT_INCLUDE_PCAP_BPF_H)
Update: Didn't work as expected: https://ci.appveyor.com/project/sgeto/npcap/build/0.10.1 ðŸ˜
bpf.h actually has a note about this:
* We do not check for BPF_MAJOR_VERSION, as that's defined by
* <linux/filter.h>, which is directly or indirectly included in some
* programs that also include pcap.h, and <linux/filter.h> doesn't
* define stuff we need.
*
* This also provides our own multiple-include protection.
*/
#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
I modified Packet32.h to #ifndef lib_pcap_bpf_h
and that fixed it well enough for now.
The stuff at the beginning of libpcap's pcap/bpf.h, in the master branch, is currently
/*
* This is libpcap's cut-down version of bpf.h; it includes only
* the stuff needed for the code generator and the userland BPF
* interpreter, and the libpcap APIs for setting filters, etc..
*
* "pcap-bpf.c" will include the native OS version, as it deals with
* the OS's BPF implementation.
*
* At least two programs found by Google Code Search explicitly includes
* <pcap/bpf.h> (even though <pcap.h>/<pcap/pcap.h> includes it for you),
* so moving that stuff to <pcap/pcap.h> would break the build for some
* programs.
*/
/*
* If we've already included <net/bpf.h>, don't re-define this stuff.
* We assume BSD-style multiple-include protection in <net/bpf.h>,
* which is true of all but the oldest versions of FreeBSD and NetBSD,
* or Tru64 UNIX-style multiple-include protection (or, at least,
* Tru64 UNIX 5.x-style; I don't have earlier versions available to check),
* or AIX-style multiple-include protection (or, at least, AIX 5.x-style;
* I don't have earlier versions available to check), or QNX-style
* multiple-include protection (as per GitHub pull request #394).
*
* We trust that they will define structures and macros and types in
* a fashion that's source-compatible and binary-compatible with our
* definitions.
*
* We do not check for BPF_MAJOR_VERSION, as that's defined by
* <linux/filter.h>, which is directly or indirectly included in some
* programs that also include pcap.h, and <linux/filter.h> doesn't
* define stuff we need. We *do* protect against <linux/filter.h>
* defining various macros for BPF code itself; <linux/filter.h> says
*
* Try and keep these values and structures similar to BSD, especially
* the BPF code definitions which need to match so you can share filters
*
* so we trust that it will define them in a fashion that's source-compatible
* and binary-compatible with our definitions.
*
* This also provides our own multiple-include protection.
*/
#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
The bit about <linux/filter.h> is
#ifndef __LINUX_FILTER_H__
and
#endif
around a bunch of the definitions of the macros for BPF instructions.
Perhaps libpcap's pcap/bpf.h should protect against Packet32.h being included first.
Some of the bpf* definitions stolen from libpcap and not really guarded by BPF_MAJOR_VERSION in Packet32.h are also available in pcap/bpf.
They should be (re)moved or better guarded. So for example
#ifndef BPF_MAJOR_VERSION
should say#if !defined (BPF_MAJOR_VERSION) && defined (PCAP_DONT_INCLUDE_PCAP_BPF_H)