]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Merge pull request #492 from vel21ripn/nflog-print
authorMichael Richardson <[email protected]>
Sat, 29 Feb 2020 23:39:13 +0000 (18:39 -0500)
committerGitHub <[email protected]>
Sat, 29 Feb 2020 23:39:13 +0000 (18:39 -0500)
Print attributes from NFLOG message

1  2 
print-nflog.c

diff --cc print-nflog.c
index d10f85398145ec121edbed14748a061afe890e9c,8a6ce4a50a60b8dfc81018394afcd3cf00a47234..9ed283c330937b4f8e11300eacc63dc165b760b8
@@@ -107,33 -44,42 +107,42 @@@ static const struct tok nflog_values[] 
        { 0,                    NULL }
  };
  
 -static inline void
 +static void
  nflog_hdr_print(netdissect_options *ndo, const nflog_hdr_t *hdr, u_int length)
  {
 -      ND_PRINT((ndo, "version %d, resource ID %d", hdr->nflog_version, ntohs(hdr->nflog_rid)));
 +      ND_PRINT("version %u, resource ID %u",
 +          GET_U_1(hdr->nflog_version), GET_BE_U_2(hdr->nflog_rid));
  
        if (!ndo->ndo_qflag) {
 -              ND_PRINT((ndo,", family %s (%d)",
 -                                                tok2str(nflog_values, "Unknown",
 -                                                                hdr->nflog_family),
 -                                                hdr->nflog_family));
 +              ND_PRINT(", family %s (%u)",
 +                       tok2str(nflog_values, "Unknown",
 +                               GET_U_1(hdr->nflog_family)),
 +                       GET_U_1(hdr->nflog_family));
                } else {
 -              ND_PRINT((ndo,", %s",
 -                                                tok2str(nflog_values,
 -                                                                "Unknown NFLOG (0x%02x)",
 -                                                                hdr->nflog_family)));
 +              ND_PRINT(", %s",
 +                       tok2str(nflog_values,
 +                               "Unknown NFLOG (0x%02x)",
 +                       GET_U_1(hdr->nflog_family)));
                }
  
 -      ND_PRINT((ndo, ", length %u: ", length));
 +      ND_PRINT(", length %u: ", length);
  }
  
+ static char *hook_names[] = { "PRE","IN","FWD","OUT","POST" };
+ static const char *hook2txt(int hook) {
+   if(hook >= sizeof(hook_names)/sizeof(hook_names[0])) return "UNK";
+   return hook_names[hook];
+ }
  u_int
  nflog_if_print(netdissect_options *ndo,
                           const struct pcap_pkthdr *h, const u_char *p)
  {
        const nflog_hdr_t *hdr = (const nflog_hdr_t *)p;
 -      const nflog_tlv_t *tlv;
        uint16_t size;
+       uint16_t hw_hdrlen = 0;
+       uint16_t hw_addrlen = 0;
        uint16_t h_size = sizeof(nflog_hdr_t);
        u_int caplen = h->caplen;
        u_int length = h->len;