]> The Tcpdump Group git mirrors - tcpdump/commitdiff
PPPoE: Update the link-layer dissector to a void function
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 31 Jul 2020 18:36:17 +0000 (20:36 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 31 Jul 2020 18:40:07 +0000 (20:40 +0200)
Moreover:
Add a length check.
Fix a return.
Use nd_print_trunc().
Remove trailing "_if" from the protocol name.
Style.

netdissect.h
print-pppoe.c
print.c

index 6c384439c61c5bb41c550166a9c8c99332482c01..2c2ad06163a40008dbcd2bcc8dcaf12c0996dec4 100644 (file)
@@ -516,7 +516,7 @@ 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 u_int pppoe_if_print IF_PRINTER_ARGS;
+extern void pppoe_if_print IF_PRINTER_ARGS;
 extern u_int prism_if_print IF_PRINTER_ARGS;
 extern void raw_if_print IF_PRINTER_ARGS;
 extern void sl_bsdos_if_print IF_PRINTER_ARGS;
index 28b80fc831fad29635dba8b893ea186f75bc3176..9452b19eeef6b8319d32d6c2c607d4c280e5c74f 100644 (file)
@@ -86,24 +86,29 @@ static const struct tok pppoetag2str[] = {
 #define PPPOE_HDRLEN 6
 #define MAXTAGPRINT 80
 
-u_int
+void
 pppoe_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
 {
-       ndo->ndo_protocol = "pppoe_if";
-       return (pppoe_print(ndo, p, h->len));
+       ndo->ndo_protocol = "pppoe";
+       ndo->ndo_ll_hdr_len += pppoe_print(ndo, p, h->len);
 }
 
 u_int
 pppoe_print(netdissect_options *ndo, const u_char *bp, u_int length)
 {
        uint16_t pppoe_ver, pppoe_type, pppoe_code, pppoe_sessionid;
-       u_int pppoe_length;
+       u_int pppoe_length, caplen;
        const u_char *pppoe_packet, *pppoe_payload;
 
        ndo->ndo_protocol = "pppoe";
+       caplen = ndo->ndo_snapend - bp;
+       if (caplen < PPPOE_HDRLEN) {
+               nd_print_trunc(ndo);
+               return caplen;
+       }
        if (length < PPPOE_HDRLEN) {
-               ND_PRINT("truncated-pppoe %u", length);
-               return (length);
+               nd_print_trunc(ndo);
+               return length;
        }
        length -= PPPOE_HDRLEN;
        pppoe_packet = bp;
@@ -192,7 +197,7 @@ pppoe_print(netdissect_options *ndo, const u_char *bp, u_int length)
                        p += tag_len;
                        /* p points to next tag */
                }
-               return (0);
+               return PPPOE_HDRLEN;
        } else {
                /* PPPoE data */
                ND_PRINT(" ");
@@ -201,5 +206,5 @@ pppoe_print(netdissect_options *ndo, const u_char *bp, u_int length)
 
 trunc:
        nd_print_trunc(ndo);
-       return (PPPOE_HDRLEN);
+       return PPPOE_HDRLEN;
 }
diff --git a/print.c b/print.c
index 7f644e084b89c7301ab64f17764849b942be4501..0eef3bb0dc42dfc4ec4512c2eb4670c8da3f6872 100644 (file)
--- a/print.c
+++ b/print.c
@@ -80,9 +80,6 @@ static const struct uint_printer uint_printers[] = {
 #ifdef DLT_HDLC
        { chdlc_if_print,       DLT_HDLC },
 #endif
-#ifdef DLT_PPP_ETHER
-       { pppoe_if_print,       DLT_PPP_ETHER },
-#endif
 #if defined(DLT_PFLOG) && defined(HAVE_NET_IF_PFLOG_H)
        { pflog_if_print,       DLT_PFLOG },
 #endif
@@ -228,6 +225,9 @@ static const struct void_printer void_printers[] = {
 #endif
 #ifdef DLT_PPI
        { ppi_if_print,         DLT_PPI },
+#endif
+#ifdef DLT_PPP_ETHER
+       { pppoe_if_print,       DLT_PPP_ETHER },
 #endif
        { raw_if_print,         DLT_RAW },
 #ifdef DLT_IPV4