]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-nflog.c
gre: add support for MikroTik Ethernet-over-IP hack.
[tcpdump] / print-nflog.c
index 83222da692eef917bae7b21f7458c5e692ed4dcd..bbe4ccfcc761b847d7e6043dc14e95dfc455cd94 100644 (file)
@@ -103,11 +103,19 @@ typedef struct nflog_timestamp {
 #define NFULA_HWHEADER                 16      /* skbuff's MAC-layer header */
 #define NFULA_HWLEN                    17      /* length of skbuff's MAC-layer header */
 
+/*
+ * Define two constants specifically for the two AF code points from the
+ * LINKTYPE_NFLOG specification above and use these constants instead of
+ * AF_INET and AF_INET6.  This is the only way to dissect the "wire" encoding
+ * correctly because some BSD systems define AF_INET6 differently from Linux
+ * (see af.h) and Haiku defines both AF_INET and AF_INET6 differently from
+ * Linux.
+ */
+#define NFLOG_AF_INET   2
+#define NFLOG_AF_INET6 10
 static const struct tok nflog_values[] = {
-       { AF_INET,              "IPv4" },
-#ifdef AF_INET6
-       { AF_INET6,             "IPv6" },
-#endif /*AF_INET6*/
+       { NFLOG_AF_INET,        "IPv4" },
+       { NFLOG_AF_INET6,       "IPv6" },
        { 0,                    NULL }
 };
 
@@ -145,10 +153,10 @@ nflog_if_print(netdissect_options *ndo,
        ndo->ndo_protocol = "nflog";
        if (caplen < NFLOG_HDR_LEN) {
                nd_print_trunc(ndo);
-               ndo->ndo_ll_header_length += caplen;
+               ndo->ndo_ll_hdr_len += caplen;
                return;
        }
-       ndo->ndo_ll_header_length += NFLOG_HDR_LEN;
+       ndo->ndo_ll_hdr_len += NFLOG_HDR_LEN;
 
        ND_TCHECK_SIZE(hdr);
        if (GET_U_1(hdr->nflog_version) != 0) {
@@ -205,15 +213,13 @@ nflog_if_print(netdissect_options *ndo,
 
        switch (GET_U_1(hdr->nflog_family)) {
 
-       case AF_INET:
+       case NFLOG_AF_INET:
                ip_print(ndo, p, length);
                break;
 
-#ifdef AF_INET6
-       case AF_INET6:
+       case NFLOG_AF_INET6:
                ip6_print(ndo, p, length);
                break;
-#endif /* AF_INET6 */
 
        default:
                if (!ndo->ndo_eflag)
@@ -225,12 +231,11 @@ nflog_if_print(netdissect_options *ndo,
                break;
        }
 
-       ndo->ndo_ll_header_length += h_size - NFLOG_HDR_LEN;
+       ndo->ndo_ll_hdr_len += h_size - NFLOG_HDR_LEN;
        return;
 trunc:
        nd_print_trunc(ndo);
-       ndo->ndo_ll_header_length += h_size - NFLOG_HDR_LEN;
-       return;
+       ndo->ndo_ll_hdr_len += h_size - NFLOG_HDR_LEN;
 }
 
 #endif /* DLT_NFLOG */