From: Francois-Xavier Le Bail Date: Thu, 6 Aug 2020 09:22:56 +0000 (+0200) Subject: PPP: Update the link-layer dissectors to void functions X-Git-Tag: tcpdump-4.99-bp~289 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/496c43c10b94112b5a2d0634d55d85e58e3f6722 PPP: Update the link-layer dissectors to void functions Moreover: Remove trailing "_if" from some protocol names. Update the outputs of two tests accordingly. --- diff --git a/netdissect.h b/netdissect.h index 6e966262..ea914d5b 100644 --- a/netdissect.h +++ b/netdissect.h @@ -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; diff --git a/print-ppp.c b/print-ppp.c index dbd5283a..94ed9d50 100644 --- a/print-ppp.c +++ b/print-ppp.c @@ -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 b79aaf8b..87a44231 100644 --- 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 diff --git a/tests/heapoverflow-ppp_hdlc_if_print.out b/tests/heapoverflow-ppp_hdlc_if_print.out index bce95263..0c60bf55 100644 --- a/tests/heapoverflow-ppp_hdlc_if_print.out +++ b/tests/heapoverflow-ppp_hdlc_if_print.out @@ -1 +1 @@ - 1 05:27:12.808464432 [|ppp_hdlc_if] + 1 05:27:12.808464432 [|ppp_hdlc] diff --git a/tests/pktap-heap-overflow.out b/tests/pktap-heap-overflow.out index 97ca7fca..78c1687a 100644 --- a/tests/pktap-heap-overflow.out +++ b/tests/pktap-heap-overflow.out @@ -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]