From: Guy Harris Date: Mon, 3 Feb 2014 04:14:26 +0000 (-0800) Subject: Use the new libpcap for NFLOG definitions and declarations. X-Git-Tag: tcpdump-4.6.0~238 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/b485483022cddbb9d21845e9c3b465f6cd882676 Use the new libpcap for NFLOG definitions and declarations. Use the header file for information about LINKTYPE_NFLOG files. Don't build the NFLOG printer if we don't have that header file. Fix some checks for pcap/XXX.h header files to look for "tcpdump-stdinc.h" rather than , so that we don't fail to find that header. --- diff --git a/config.h.in b/config.h.in index 81da0ced..a3ae3ac4 100644 --- a/config.h.in +++ b/config.h.in @@ -106,6 +106,9 @@ /* define if libpcap has pcap_list_datalinks() */ #undef HAVE_PCAP_LIST_DATALINKS +/* Define to 1 if you have the header file. */ +#undef HAVE_PCAP_NFLOG_H + /* Define to 1 if you have the `pcap_setdirection' function. */ #undef HAVE_PCAP_SETDIRECTION diff --git a/configure b/configure index f857b8da..114edcd6 100755 --- a/configure +++ b/configure @@ -7308,7 +7308,7 @@ savedcppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $V_INCLS" for ac_header in pcap/bluetooth.h do : - ac_fn_c_check_header_compile "$LINENO" "pcap/bluetooth.h" "ac_cv_header_pcap_bluetooth_h" "#include + ac_fn_c_check_header_compile "$LINENO" "pcap/bluetooth.h" "ac_cv_header_pcap_bluetooth_h" "#include \"tcpdump-stdinc.h\" " if test "x$ac_cv_header_pcap_bluetooth_h" = xyes; then : cat >>confdefs.h <<_ACEOF @@ -7319,9 +7319,22 @@ fi done +for ac_header in pcap/nflog.h +do : + ac_fn_c_check_header_compile "$LINENO" "pcap/nflog.h" "ac_cv_header_pcap_nflog_h" "#include \"tcpdump-stdinc.h\" +" +if test "x$ac_cv_header_pcap_nflog_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PCAP_NFLOG_H 1 +_ACEOF + +fi + +done + for ac_header in pcap/usb.h do : - ac_fn_c_check_header_compile "$LINENO" "pcap/usb.h" "ac_cv_header_pcap_usb_h" "#include + ac_fn_c_check_header_compile "$LINENO" "pcap/usb.h" "ac_cv_header_pcap_usb_h" "#include \"tcpdump-stdinc.h\" " if test "x$ac_cv_header_pcap_usb_h" = xyes; then : cat >>confdefs.h <<_ACEOF diff --git a/configure.in b/configure.in index b2443afa..e347d512 100644 --- a/configure.in +++ b/configure.in @@ -986,8 +986,9 @@ fi # savedcppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $V_INCLS" -AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include ]) -AC_CHECK_HEADERS(pcap/usb.h,,,[#include ]) +AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "tcpdump-stdinc.h"]) +AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "tcpdump-stdinc.h"]) +AC_CHECK_HEADERS(pcap/usb.h,,,[#include "tcpdump-stdinc.h"]) CPPFLAGS="$savedcppflags" AC_PROG_RANLIB diff --git a/print-nflog.c b/print-nflog.c index 8e7cd30b..f53b48e6 100644 --- a/print-nflog.c +++ b/print-nflog.c @@ -37,25 +37,8 @@ #include "netdissect.h" #include "interface.h" -/* - * Structure of an NFLOG header and TLV parts, as described at - * http://www.tcpdump.org/linktypes/LINKTYPE_NFLOG.html - */ -typedef struct nflog_hdr { - u_int8_t nflog_family; /* adress family */ - u_int8_t nflog_version; /* version */ - u_int16_t nflog_rid; /* resource ID */ -} nflog_hdr_t; - -typedef struct nflog_tlv { - u_int16_t tlv_length; /* tlv length */ - u_int16_t tlv_type; /* tlv type */ - void* tlv_value; /* tlv value */ -} nflog_tlv_t; - -#ifdef DLT_NFLOG - -#define NFULA_PAYLOAD 9 +#if defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H) +#include static const struct tok nflog_values[] = { { AF_INET, "IPv4" }, @@ -139,7 +122,7 @@ nflog_if_print(struct netdissect_options *ndo, switch (hdr->nflog_family) { case AF_INET: - ip_print(ndo, p, length); + ip_print(ndo, p, length); break; #ifdef INET6 @@ -161,4 +144,4 @@ nflog_if_print(struct netdissect_options *ndo, return h_size; } -#endif /* DLT_NFLOG */ +#endif /* defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H) */ diff --git a/tcpdump.c b/tcpdump.c index 19d7f2b4..1e3d906d 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -341,7 +341,7 @@ static const struct ndo_printer ndo_printers[] = { #ifdef DLT_NETANALYZER_TRANSPARENT { netanalyzer_transparent_if_print, DLT_NETANALYZER_TRANSPARENT }, #endif -#ifdef DLT_NFLOG +#if defined(DLT_NFLOG) && defined(HAVE_PCAP_NFLOG_H) { nflog_if_print, DLT_NFLOG}, #endif { NULL, 0 },