]> The Tcpdump Group git mirrors - tcpdump/commitdiff
PKTAP: Update the link-layer dissector to a void function
authorFrancois-Xavier Le Bail <[email protected]>
Sat, 28 Mar 2020 09:40:28 +0000 (10:40 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 28 Mar 2020 09:44:30 +0000 (10:44 +0100)
Moreover:
Remove trailing "_if" from protocol name.
Update the output of a test accordingly.

netdissect.h
print-pktap.c
print.c
tests/pktap-heap-overflow.out

index b7dafa59e113f1de4c1f5d9b9463bcd04c947efe..401d62d72da5d914522d4ee650f8c3ff7be61ef0 100644 (file)
@@ -509,7 +509,7 @@ extern u_int netanalyzer_transparent_if_print IF_PRINTER_ARGS;
 extern u_int nflog_if_print IF_PRINTER_ARGS;
 extern void null_if_print IF_PRINTER_ARGS;
 extern u_int pflog_if_print IF_PRINTER_ARGS;
-extern u_int pktap_if_print IF_PRINTER_ARGS;
+extern void pktap_if_print IF_PRINTER_ARGS;
 extern void ppi_if_print IF_PRINTER_ARGS;
 extern u_int ppp_bsdos_if_print IF_PRINTER_ARGS;
 extern u_int ppp_hdlc_if_print IF_PRINTER_ARGS;
index 182378ef775882b6264d764076fd72958a9352e2..b38ad6419b783c08fe3c55de0398a617c363078f 100644 (file)
@@ -95,7 +95,7 @@ pktap_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
  * 'h->len' is the length of the packet off the wire, and 'h->caplen'
  * is the number of bytes actually captured.
  */
-u_int
+void
 pktap_if_print(netdissect_options *ndo,
                const struct pcap_pkthdr *h, const u_char *p)
 {
@@ -106,10 +106,11 @@ pktap_if_print(netdissect_options *ndo,
        const pktap_header_t *hdr;
        struct pcap_pkthdr nhdr;
 
-       ndo->ndo_protocol = "pktap_if";
+       ndo->ndo_protocol = "pktap";
        if (caplen < sizeof(pktap_header_t)) {
                nd_print_trunc(ndo);
-               return (caplen);
+               ndo->ndo_ll_header_length += caplen;
+               return;
        }
        hdr = (const pktap_header_t *)p;
        dlt = GET_LE_U_4(hdr->pkt_dlt);
@@ -123,11 +124,13 @@ pktap_if_print(netdissect_options *ndo,
                 * be expanded in the future)?
                 */
                nd_print_trunc(ndo);
-               return (caplen);
+               ndo->ndo_ll_header_length += caplen;
+               return;
        }
        if (caplen < hdrlen) {
                nd_print_trunc(ndo);
-               return (caplen);
+               ndo->ndo_ll_header_length += caplen;
+               return;
        }
 
        if (ndo->ndo_eflag)
@@ -166,6 +169,7 @@ pktap_if_print(netdissect_options *ndo,
                break;
        }
 
-       return (hdrlen);
+       ndo->ndo_ll_header_length += hdrlen;
+       return;
 }
 #endif /* DLT_PKTAP */
diff --git a/print.c b/print.c
index 97d0a4c20a450b56539609a0ca1bb7f142c710ad..4f5de270ce12baa857dd287aac1adce29ab0d69e 100644 (file)
--- a/print.c
+++ b/print.c
@@ -173,9 +173,6 @@ static const struct uint_printer uint_printers[] = {
 #ifdef DLT_JUNIPER_CHDLC
        { juniper_chdlc_if_print,       DLT_JUNIPER_CHDLC },
 #endif
-#ifdef DLT_PKTAP
-       { pktap_if_print,       DLT_PKTAP },
-#endif
 #ifdef DLT_IEEE802_11_RADIO
        { ieee802_11_radio_if_print,    DLT_IEEE802_11_RADIO },
 #endif
@@ -233,6 +230,9 @@ static const struct void_printer void_printers[] = {
 #ifdef DLT_LOOP
        { null_if_print,        DLT_LOOP },
 #endif
+#ifdef DLT_PKTAP
+       { pktap_if_print,       DLT_PKTAP },
+#endif
 #ifdef DLT_PPI
        { ppi_if_print,         DLT_PPI },
 #endif
index 247886b58d261ac38e258e0a3ada0cbfe4c62a1d..97ca7fca1bc8ea3e9f59264638c02fcffe9610b9 100644 (file)
@@ -1,2 +1,2 @@
-    1  05:27:35.808464432  [|pktap_if]
+    1  05:27:35.808464432  [|pktap]
     2  05:27:12.808595504  [|ppp_hdlc_if]