]> The Tcpdump Group git mirrors - tcpdump/commitdiff
IPNET: Update the link-layer dissector to a void function
authorFrancois-Xavier Le Bail <[email protected]>
Sat, 8 Feb 2020 09:42:36 +0000 (10:42 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 8 Feb 2020 09:50:49 +0000 (10:50 +0100)
Moreover:
Remove trailing "_if" from protocol name.
Remove a useless ND_TCHECK_1 test (GET_U_1 is used).
Remove a no longer used 'trunc' label.

netdissect.h
print-ipnet.c
print.c

index b6fe0b51ec25624d41eb6b1bae822a49bddbbc39..76a18425c44e5dd706e9e0e1c4e31a1da3713d0d 100644 (file)
@@ -483,7 +483,7 @@ extern u_int ieee802_15_4_if_print IF_PRINTER_ARGS;
 extern u_int ieee802_15_4_tap_if_print IF_PRINTER_ARGS;
 extern u_int ipfc_if_print IF_PRINTER_ARGS;
 extern u_int ipoib_if_print IF_PRINTER_ARGS;
-extern u_int ipnet_if_print IF_PRINTER_ARGS;
+extern void ipnet_if_print IF_PRINTER_ARGS;
 extern u_int juniper_atm1_if_print IF_PRINTER_ARGS;
 extern u_int juniper_atm2_if_print IF_PRINTER_ARGS;
 extern u_int juniper_chdlc_if_print IF_PRINTER_ARGS;
index 7c6a301b69982740f64e98baafb7edefccc31666..f958d42c032918d705f25aeb4c78cad609bbd480 100644 (file)
@@ -65,9 +65,12 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
 {
        const ipnet_hdr_t *hdr;
 
-       ndo->ndo_protocol = "ipnet";
-       if (caplen < sizeof(ipnet_hdr_t))
-               goto trunc;
+       if (caplen < sizeof(ipnet_hdr_t)) {
+               ndo->ndo_ll_header_length += caplen;
+               nd_print_trunc(ndo);
+               return;
+       }
+       ndo->ndo_ll_header_length += sizeof(ipnet_hdr_t);
 
        if (ndo->ndo_eflag)
                ipnet_hdr_print(ndo, p, length);
@@ -77,7 +80,6 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
        hdr = (const ipnet_hdr_t *)p;
        p += sizeof(ipnet_hdr_t);
 
-       ND_TCHECK_1(hdr->iph_family);
        switch (GET_U_1(hdr->iph_family)) {
 
        case IPH_AF_INET:
@@ -98,8 +100,6 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
                break;
        }
        return;
-trunc:
-       nd_print_trunc(ndo);
 }
 
 /*
@@ -108,13 +108,11 @@ trunc:
  * 'h->len' is the length of the packet off the wire, and 'h->caplen'
  * is the number of bytes actually captured.
  */
-u_int
+void
 ipnet_if_print(netdissect_options *ndo,
                const struct pcap_pkthdr *h, const u_char *p)
 {
-       ndo->ndo_protocol = "ipnet_if";
+       ndo->ndo_protocol = "ipnet";
        ipnet_print(ndo, p, h->len, h->caplen);
-
-       return (sizeof(ipnet_hdr_t));
 }
 #endif /* DLT_IPNET */
diff --git a/print.c b/print.c
index 8543a8b3f7effb8036c4a2686409a31b02d5bb5f..71502c2db7214f4d50b7779b1378cea6539b46e0 100644 (file)
--- a/print.c
+++ b/print.c
@@ -54,9 +54,6 @@ struct void_printer {
 
 static const struct uint_printer uint_printers[] = {
        { ether_if_print,       DLT_EN10MB },
-#ifdef DLT_IPNET
-       { ipnet_if_print,       DLT_IPNET },
-#endif
 #ifdef DLT_IEEE802_15_4
        { ieee802_15_4_if_print, DLT_IEEE802_15_4 },
 #endif
@@ -231,6 +228,9 @@ static const struct void_printer void_printers[] = {
 #endif
 #ifdef DLT_ENC
        { enc_if_print,         DLT_ENC },
+#endif
+#ifdef DLT_IPNET
+       { ipnet_if_print,       DLT_IPNET },
 #endif
        { null_if_print,        DLT_NULL },
 #ifdef DLT_LOOP