]> The Tcpdump Group git mirrors - tcpdump/commitdiff
PPI: Update the link-layer dissector to a void function
authorFrancois-Xavier Le Bail <[email protected]>
Sat, 28 Mar 2020 07:38:04 +0000 (08:38 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 28 Mar 2020 07:50:00 +0000 (08:50 +0100)
Moreover:
Merge ppi_if_print() and ppi_print() in one function.
Remove two useless ND_TCHECK_ tests (GET_ used).
Remove a no longer used 'trunc' label.

netdissect.h
print-ppi.c
print.c

index 4fbfad67b62feaa27162b074ba5037022a7bed5a..b7dafa59e113f1de4c1f5d9b9463bcd04c947efe 100644 (file)
@@ -510,7 +510,7 @@ 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 u_int ppi_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;
 extern u_int ppp_if_print IF_PRINTER_ARGS;
index 04aa1893228ccb3a21e51e88a3efa6505a4b6e95..977542650c83e9b26ad1a9a5f87138d89e9376e6 100644 (file)
@@ -57,9 +57,15 @@ ppi_header_print(netdissect_options *ndo, const u_char *bp, u_int length)
        ND_PRINT(", length %u: ", length);
 }
 
-static u_int
-ppi_print(netdissect_options *ndo,
-         const struct pcap_pkthdr *h, const u_char *p)
+/*
+ * This is the top level routine of the printer.  'p' points
+ * to the ether header of the packet, 'h->ts' is the timestamp,
+ * 'h->len' is the length of the packet off the wire, and 'h->caplen'
+ * is the number of bytes actually captured.
+ */
+void
+ppi_if_print(netdissect_options *ndo,
+            const struct pcap_pkthdr *h, const u_char *p)
 {
        if_printer_t printer;
        const ppi_header_t *hdr;
@@ -73,18 +79,19 @@ ppi_print(netdissect_options *ndo,
        ndo->ndo_protocol = "ppi";
        if (caplen < sizeof(ppi_header_t)) {
                nd_print_trunc(ndo);
-               return (caplen);
+               ndo->ndo_ll_header_length += caplen;
+               return;
        }
 
        hdr = (const ppi_header_t *)p;
-       ND_TCHECK_2(hdr->ppi_len);
        len = GET_LE_U_2(hdr->ppi_len);
        if (len < sizeof(ppi_header_t) || len > 65532) {
                /* It MUST be between 8 and 65,532 inclusive (spec 3.1.3) */
                ND_PRINT(" [length %u < %zu or > 65532]", len,
                         sizeof(ppi_header_t));
                nd_print_invalid(ndo);
-               return (caplen);
+               ndo->ndo_ll_header_length += caplen;
+               return;
        }
        if (caplen < len) {
                /*
@@ -92,9 +99,9 @@ ppi_print(netdissect_options *ndo,
                 * bother.
                 */
                nd_print_trunc(ndo);
-               return (caplen);
+               ndo->ndo_ll_header_length += caplen;
+               return;
        }
-       ND_TCHECK_4(hdr->ppi_dlt);
        dlt = GET_LE_U_4(hdr->ppi_dlt);
 
        if (ndo->ndo_eflag)
@@ -122,22 +129,7 @@ ppi_print(netdissect_options *ndo,
                        ND_DEFAULTPRINT(p, caplen);
                hdrlen = 0;
        }
-       return (len + hdrlen);
-trunc:
-       return (caplen);
-}
-
-/*
- * This is the top level routine of the printer.  'p' points
- * to the ether header of the packet, 'h->ts' is the timestamp,
- * 'h->len' is the length of the packet off the wire, and 'h->caplen'
- * is the number of bytes actually captured.
- */
-u_int
-ppi_if_print(netdissect_options *ndo,
-            const struct pcap_pkthdr *h, const u_char *p)
-{
-       ndo->ndo_protocol = "ppi_if";
-       return (ppi_print(ndo, h, p));
+       ndo->ndo_ll_header_length += len + hdrlen;
+       return;
 }
 #endif /* DLT_PPI */
diff --git a/print.c b/print.c
index 71502c2db7214f4d50b7779b1378cea6539b46e0..97d0a4c20a450b56539609a0ca1bb7f142c710ad 100644 (file)
--- a/print.c
+++ b/print.c
@@ -63,9 +63,6 @@ static const struct uint_printer uint_printers[] = {
 #ifdef DLT_IEEE802_15_4_TAP
        { ieee802_15_4_tap_if_print, DLT_IEEE802_15_4_TAP },
 #endif
-#ifdef DLT_PPI
-       { ppi_if_print,         DLT_PPI },
-#endif
 #ifdef DLT_NETANALYZER
        { netanalyzer_if_print, DLT_NETANALYZER },
 #endif
@@ -235,6 +232,9 @@ static const struct void_printer void_printers[] = {
        { null_if_print,        DLT_NULL },
 #ifdef DLT_LOOP
        { null_if_print,        DLT_LOOP },
+#endif
+#ifdef DLT_PPI
+       { ppi_if_print,         DLT_PPI },
 #endif
        { raw_if_print,         DLT_RAW },
 #ifdef DLT_IPV4