]> The Tcpdump Group git mirrors - tcpdump/commitdiff
NULL/LOOP: Update the link-layer dissector to a void function
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 7 Feb 2020 17:21:40 +0000 (18:21 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 7 Feb 2020 19:36:34 +0000 (20:36 +0100)
Moreover:
Remove trailing "_if" from protocol name.
Remove a useless ND_TCHECK_4 test (GET_HE_U_4 used).
Remove a no longer used 'trunc' label.
Use uint32_t type for family in null_hdr_print().

netdissect.h
print-null.c
print.c

index 4b42f4a16f71ac5e45c037f9af11c2bcceb05e22..1edfdbdb6b1db7f7e93b3c91c760ddca62397a7c 100644 (file)
@@ -505,7 +505,7 @@ extern u_int mfr_if_print IF_PRINTER_ARGS;
 extern u_int netanalyzer_if_print IF_PRINTER_ARGS;
 extern u_int netanalyzer_transparent_if_print IF_PRINTER_ARGS;
 extern u_int nflog_if_print IF_PRINTER_ARGS;
-extern u_int null_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;
index f730a23f405f96cbd6d54dc9995958fc877504ce..f2ea96e2f73a9ce389bc52e4066c3d1e751838f5 100644 (file)
@@ -55,7 +55,7 @@
 ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
 
 static void
-null_hdr_print(netdissect_options *ndo, u_int family, u_int length)
+null_hdr_print(netdissect_options *ndo, uint32_t family, u_int length)
 {
        if (!ndo->ndo_qflag) {
                ND_PRINT("AF %s (%u)",
@@ -74,18 +74,21 @@ null_hdr_print(netdissect_options *ndo, u_int family, 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
 null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
        u_int length = h->len;
        u_int caplen = h->caplen;
        uint32_t family;
 
-       ndo->ndo_protocol = "null_if";
-       if (caplen < NULL_HDRLEN)
-               goto trunc;
+       ndo->ndo_protocol = "null";
+       if (caplen < NULL_HDRLEN) {
+               ndo->ndo_ll_header_length += caplen;
+               nd_print_trunc(ndo);
+               return;
+       }
+       ndo->ndo_ll_header_length += NULL_HDRLEN;
 
-       ND_TCHECK_4(p);
        family = GET_HE_U_4(p);
 
        /*
@@ -138,8 +141,5 @@ null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
                        ND_DEFAULTPRINT(p, caplen);
        }
 
-       return (NULL_HDRLEN);
-trunc:
-       nd_print_trunc(ndo);
-       return (NULL_HDRLEN);
+       return;
 }
diff --git a/print.c b/print.c
index e82c631ffd107be5e7923bab16c013f0d1e84bab..a4bc1ec21141556086d46cf9a179300fe6640449 100644 (file)
--- a/print.c
+++ b/print.c
@@ -86,10 +86,6 @@ static const struct uint_printer uint_printers[] = {
 #endif
 #ifdef DLT_IP_OVER_FC
        { ipfc_if_print,        DLT_IP_OVER_FC },
-#endif
-       { null_if_print,        DLT_NULL },
-#ifdef DLT_LOOP
-       { null_if_print,        DLT_LOOP },
 #endif
 #ifdef DLT_LANE8023
        { lane_if_print,        DLT_LANE8023 },
@@ -235,6 +231,10 @@ static const struct void_printer void_printers[] = {
 #endif
 #ifdef DLT_BLUETOOTH_HCI_H4_WITH_PHDR
        { bt_if_print,          DLT_BLUETOOTH_HCI_H4_WITH_PHDR},
+#endif
+       { null_if_print,        DLT_NULL },
+#ifdef DLT_LOOP
+       { null_if_print,        DLT_LOOP },
 #endif
        { raw_if_print,         DLT_RAW },
 #ifdef DLT_IPV4