summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ovsienko <denis@ovsienko.info>2021-03-12 17:30:08 +0000
committerDenis Ovsienko <denis@ovsienko.info>2021-03-12 17:30:08 +0000
commitbb02779a37fdf815da58e8828eb4ce99a4f86580 (patch)
treef46a4066a2c96071546f09d5c9ab7e288336f8cf
parent32962b021d875978a70bfd91e9687684712f608f (diff)
downloadlibpcap-bb02779a37fdf815da58e8828eb4ce99a4f86580.tar.gz
Get DLT_MATCHING_MAX right in gencode.c on NetBSD.
Even though libpcap had DLT_MATCHING_MAX defined to 290 in its "pcap/dlt.h" header, on NetBSD 9.1 gencode.c ended up with the value 275 from /usr/include/net/dlt.h (regardless if the libpcap package, which defined it as 276 in /usr/pkg/include/pcap/dlt.h, was installed). This made the current master branch of tcpdump compiled with the current master branch of libpcap fail some tests, such as: tcpdump: unknown data link type 284 Move the HAVE_NET_PFVAR_H block and add a comment. This solves the problem on NetBSD and does not introduce any immediate regressions on FreeBSD 13.0, Linux or Solaris 11.
-rw-r--r--gencode.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/gencode.c b/gencode.c
index b8e5bf82..efdcb987 100644
--- a/gencode.c
+++ b/gencode.c
@@ -48,6 +48,20 @@
#include "pcap-dos.h"
#endif
+#ifdef HAVE_NET_PFVAR_H
+/*
+ * In NetBSD <net/if.h> includes <net/dlt.h>, which is an older version of
+ * "pcap/dlt.h" with a lower value of DLT_MATCHING_MAX. Include the headers
+ * below before "pcap-int.h", which eventually includes "pcap/dlt.h", which
+ * redefines DLT_MATCHING_MAX from what this version of NetBSD has to what
+ * this version of libpcap has.
+ */
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/pfvar.h>
+#include <net/if_pflog.h>
+#endif /* HAVE_NET_PFVAR_H */
+
#include "pcap-int.h"
#include "extract.h"
@@ -73,13 +87,6 @@
#include <linux/filter.h>
#endif
-#ifdef HAVE_NET_PFVAR_H
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/pfvar.h>
-#include <net/if_pflog.h>
-#endif
-
#ifndef offsetof
#define offsetof(s, e) ((size_t)&((s *)0)->e)
#endif