]> The Tcpdump Group git mirrors - tcpdump/commitdiff
PPP: Update the link-layer dissectors to void functions
authorFrancois-Xavier Le Bail <[email protected]>
Thu, 6 Aug 2020 09:22:56 +0000 (11:22 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Thu, 6 Aug 2020 14:25:52 +0000 (16:25 +0200)
Moreover:
Remove trailing "_if" from some protocol names.
Update the outputs of two tests accordingly.

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

index 6e96626259ff991e2eba5df63e107f0c68849d3b..ea914d5b6ebc29ef96960638584de926b6d0e4ec 100644 (file)
@@ -512,9 +512,9 @@ extern void null_if_print IF_PRINTER_ARGS;
 extern u_int pflog_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;
-extern u_int ppp_if_print IF_PRINTER_ARGS;
+extern void ppp_bsdos_if_print IF_PRINTER_ARGS;
+extern void ppp_hdlc_if_print IF_PRINTER_ARGS;
+extern void ppp_if_print IF_PRINTER_ARGS;
 extern void pppoe_if_print IF_PRINTER_ARGS;
 extern void prism_if_print IF_PRINTER_ARGS;
 extern void raw_if_print IF_PRINTER_ARGS;
index dbd5283a947cd92ef194c304b803622f1ed4c9f7..94ed9d5051fb6400339b6ace693a52b8ee417819 100644 (file)
@@ -1631,18 +1631,20 @@ trunc:
 
 
 /* PPP I/F printer */
-u_int
+void
 ppp_if_print(netdissect_options *ndo,
              const struct pcap_pkthdr *h, const u_char *p)
 {
        u_int length = h->len;
        u_int caplen = h->caplen;
 
-       ndo->ndo_protocol = "ppp_if";
+       ndo->ndo_protocol = "ppp";
        if (caplen < PPP_HDRLEN) {
                nd_print_trunc(ndo);
-               return (caplen);
+               ndo->ndo_ll_hdr_len += caplen;
+               return;
        }
+       ndo->ndo_ll_hdr_len += PPP_HDRLEN;
 
 #if 0
        /*
@@ -1687,8 +1689,6 @@ ppp_if_print(netdissect_options *ndo,
 #endif
 
        ppp_print(ndo, p, length);
-
-       return (0);
 }
 
 /*
@@ -1700,7 +1700,7 @@ ppp_if_print(netdissect_options *ndo,
  *
  * This handles, for example, DLT_PPP_SERIAL in NetBSD.
  */
-u_int
+void
 ppp_hdlc_if_print(netdissect_options *ndo,
                   const struct pcap_pkthdr *h, const u_char *p)
 {
@@ -1709,10 +1709,11 @@ ppp_hdlc_if_print(netdissect_options *ndo,
        u_int proto;
        u_int hdrlen = 0;
 
-       ndo->ndo_protocol = "ppp_hdlc_if";
+       ndo->ndo_protocol = "ppp_hdlc";
        if (caplen < 2) {
                nd_print_trunc(ndo);
-               return (caplen);
+               ndo->ndo_ll_hdr_len += caplen;
+               return;
        }
 
        switch (GET_U_1(p)) {
@@ -1720,7 +1721,8 @@ ppp_hdlc_if_print(netdissect_options *ndo,
        case PPP_ADDRESS:
                if (caplen < 4) {
                        nd_print_trunc(ndo);
-                       return (caplen);
+                       ndo->ndo_ll_hdr_len += caplen;
+                       return;
                }
 
                if (ndo->ndo_eflag)
@@ -1741,12 +1743,14 @@ ppp_hdlc_if_print(netdissect_options *ndo,
 
        case CHDLC_UNICAST:
        case CHDLC_BCAST:
-               return (chdlc_if_print(ndo, h, p));
+               ndo->ndo_ll_hdr_len += chdlc_if_print(ndo, h, p);
+               return;
 
        default:
                if (caplen < 4) {
                        nd_print_trunc(ndo);
-                       return (caplen);
+                       ndo->ndo_ll_hdr_len += caplen;
+                       return;
                }
 
                if (ndo->ndo_eflag)
@@ -1765,14 +1769,14 @@ ppp_hdlc_if_print(netdissect_options *ndo,
                break;
        }
 
-       return (hdrlen);
+       ndo->ndo_ll_hdr_len += hdrlen;
 }
 
 #define PPP_BSDI_HDRLEN 24
 
 /* BSD/OS specific PPP printer */
-u_int
-ppp_bsdos_if_print(netdissect_options *ndo _U_,
+void
+ppp_bsdos_if_print(netdissect_options *ndo,
                    const struct pcap_pkthdr *h _U_, const u_char *p _U_)
 {
        u_int hdrlength;
@@ -1784,10 +1788,11 @@ ppp_bsdos_if_print(netdissect_options *ndo _U_,
        const u_char *q;
        u_int i;
 
-       ndo->ndo_protocol = "ppp_bsdos_if";
+       ndo->ndo_protocol = "ppp_bsdos";
        if (caplen < PPP_BSDI_HDRLEN) {
                nd_print_trunc(ndo);
-               return (caplen);
+               ndo->ndo_ll_hdr_len += caplen;
+               return;
        }
 
        hdrlength = 0;
@@ -1927,5 +1932,5 @@ printx:
 #else /* __bsdi */
        hdrlength = 0;
 #endif /* __bsdi__ */
-       return (hdrlength);
+       ndo->ndo_ll_hdr_len += hdrlength;
 }
diff --git a/print.c b/print.c
index b79aaf8b41bdec602557fb2631435254bf7e9c62..87a442318891f04f6eece001f2ffa2d790085d6e 100644 (file)
--- a/print.c
+++ b/print.c
@@ -64,16 +64,6 @@ static const struct uint_printer uint_printers[] = {
 #endif
 #ifdef DLT_LTALK
        { ltalk_if_print,       DLT_LTALK },
-#endif
-       { ppp_if_print,         DLT_PPP },
-#ifdef DLT_PPP_WITHDIRECTION
-       { ppp_if_print,         DLT_PPP_WITHDIRECTION },
-#endif
-#ifdef DLT_PPP_BSDOS
-       { ppp_bsdos_if_print,   DLT_PPP_BSDOS },
-#endif
-#ifdef DLT_PPP_SERIAL
-       { ppp_hdlc_if_print,    DLT_PPP_SERIAL },
 #endif
        { NULL,                 0 },
 };
@@ -213,6 +203,16 @@ static const struct void_printer void_printers[] = {
 #ifdef DLT_PPI
        { ppi_if_print,         DLT_PPI },
 #endif
+#ifdef DLT_PPP_BSDOS
+       { ppp_bsdos_if_print,   DLT_PPP_BSDOS },
+#endif
+#ifdef DLT_PPP_SERIAL
+       { ppp_hdlc_if_print,    DLT_PPP_SERIAL },
+#endif
+       { ppp_if_print,         DLT_PPP },
+#ifdef DLT_PPP_WITHDIRECTION
+       { ppp_if_print,         DLT_PPP_WITHDIRECTION },
+#endif
 #ifdef DLT_PPP_ETHER
        { pppoe_if_print,       DLT_PPP_ETHER },
 #endif
index bce9526357af2a29d83120d0c15739d8ce4b8fe5..0c60bf5558f541b43cb9504f33e60773af86f96c 100644 (file)
@@ -1 +1 @@
-    1  05:27:12.808464432  [|ppp_hdlc_if]
+    1  05:27:12.808464432  [|ppp_hdlc]
index 97ca7fca1bc8ea3e9f59264638c02fcffe9610b9..78c1687a868fc3f26c1f114bb76a2ade0aee09f3 100644 (file)
@@ -1,2 +1,2 @@
     1  05:27:35.808464432  [|pktap]
-    2  05:27:12.808595504  [|ppp_hdlc_if]
+    2  05:27:12.808595504  [|ppp_hdlc]