git: 6d1c946e9168 - main - libpcap: Make pcap/bpf.h a wrapper around system net/bpf.h
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 16 Feb 2023 15:42:10 UTC
The branch main has been updated by jrm (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=6d1c946e916845d01062e146aad5395410da1e54 commit 6d1c946e916845d01062e146aad5395410da1e54 Author: Joseph Mingrone <jrm@FreeBSD.org> AuthorDate: 2023-02-13 22:06:51 +0000 Commit: Joseph Mingrone <jrm@FreeBSD.org> CommitDate: 2023-02-16 15:37:51 +0000 libpcap: Make pcap/bpf.h a wrapper around system net/bpf.h In the past, we modified pcap/pcap.h to include the system net/bpf.h rather than libpcap's own pcap/bpf.h. However, starting around 1.10.2, libpcap requires a few extern functions defined in pcap/bpf.h to build. Simply reverting that local change and pulling in pcap/bpf.h is not a solution, because some ports with '#include <pcap.h>' such as mail/spamd and net/xprobe require the system net/bpf.h to be pulled in. To accommodate both requirements, make pcap/bpf.h a wrapper around the system net/bpf.h, but retain the extern function definitions. This is in preparation for libpcap 1.10.3. Approved by: cy, philip, emaste, delphij (earlier revision) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38575 --- contrib/libpcap/pcap/bpf.h | 16 ++++++++++++++++ contrib/libpcap/pcap/pcap.h | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/contrib/libpcap/pcap/bpf.h b/contrib/libpcap/pcap/bpf.h index 9d748952a0e5..1c9d0f56a01a 100644 --- a/contrib/libpcap/pcap/bpf.h +++ b/contrib/libpcap/pcap/bpf.h @@ -74,6 +74,18 @@ extern "C" { #endif +/* + * In the past, we modified pcap/pcap.h to include the system net/bpf.h, + * rather than this file. However, starting around 1.10.2, libpcap requires + * the extern functions defined here to build. Simply reverting that local + * change is not a solution, because some ports with '#include <pcap.h>' + * such as mail/spamd and net/xprobe require the system net/bpf.h to be + * pulled in. To accommodate both requirements, make this header a wrapper + * around the system net/bpf.h, but keep the extern function definitions. + */ +#if defined(__FreeBSD__) +#include <net/bpf.h> +#else /* BSD style release date */ #define BPF_RELEASE 199606 @@ -244,13 +256,17 @@ struct bpf_insn { #define BPF_STMT(code, k) { (u_short)(code), 0, 0, k } #define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k } +#endif /* defined(__FreeBSD__) */ + 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); +#if !defined(__FreeBSD__) /* * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST). */ #define BPF_MEMWORDS 16 +#endif #ifdef __cplusplus } diff --git a/contrib/libpcap/pcap/pcap.h b/contrib/libpcap/pcap/pcap.h index a2d6003cdf61..4e30e77812ef 100644 --- a/contrib/libpcap/pcap/pcap.h +++ b/contrib/libpcap/pcap/pcap.h @@ -85,7 +85,10 @@ #endif /* _WIN32/MSDOS/UN*X */ #include <pcap/socket.h> /* for SOCKET, as the active-mode rpcap APIs use it */ -#include <net/bpf.h> + +#ifndef PCAP_DONT_INCLUDE_PCAP_BPF_H +#include <pcap/bpf.h> +#endif #include <stdio.h>