From: Francois-Xavier Le Bail Date: Tue, 4 Aug 2020 15:24:53 +0000 (+0200) Subject: FR: Update the link-layer dissectors to void functions X-Git-Tag: tcpdump-4.99-bp~291 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/4262b291643c6e42ef3f964f8d5ad150d0b84efb FR: Update the link-layer dissectors to void functions Moreover: Remove trailing "_if" from the protocol name. Add two comments. --- diff --git a/netdissect.h b/netdissect.h index 408cff8a..dde21bc8 100644 --- a/netdissect.h +++ b/netdissect.h @@ -479,7 +479,7 @@ extern void edsa_if_print IF_PRINTER_ARGS; extern void enc_if_print IF_PRINTER_ARGS; extern void ether_if_print IF_PRINTER_ARGS; extern void fddi_if_print IF_PRINTER_ARGS; -extern u_int fr_if_print IF_PRINTER_ARGS; +extern void fr_if_print IF_PRINTER_ARGS; extern void ieee802_11_if_print IF_PRINTER_ARGS; extern void ieee802_11_radio_avs_if_print IF_PRINTER_ARGS; extern void ieee802_11_radio_if_print IF_PRINTER_ARGS; @@ -505,7 +505,7 @@ extern void juniper_pppoe_if_print IF_PRINTER_ARGS; extern void juniper_services_if_print IF_PRINTER_ARGS; extern u_int lane_if_print IF_PRINTER_ARGS; extern u_int ltalk_if_print IF_PRINTER_ARGS; -extern u_int mfr_if_print IF_PRINTER_ARGS; +extern void mfr_if_print IF_PRINTER_ARGS; extern void netanalyzer_if_print IF_PRINTER_ARGS; extern void netanalyzer_transparent_if_print IF_PRINTER_ARGS; extern void nflog_if_print IF_PRINTER_ARGS; diff --git a/print-fr.c b/print-fr.c index f1c69b42..d52e3cef 100644 --- a/print-fr.c +++ b/print-fr.c @@ -212,23 +212,22 @@ fr_hdr_print(netdissect_options *ndo, int length, u_int addr_len, } } -u_int +/* Frame Relay */ +void fr_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 = "fr_if"; - ND_TCHECK_4(p); /* minimum frame header length */ + ndo->ndo_protocol = "fr"; + if (caplen < 4) { /* minimum frame header length */ + nd_print_trunc(ndo); + ndo->ndo_ll_hdr_len += caplen; + return; + } - if ((length = fr_print(ndo, p, length)) == 0) - return (0); - else - return length; -trunc: - nd_print_trunc(ndo); - return caplen; + ndo->ndo_ll_hdr_len += fr_print(ndo, p, length); } u_int @@ -370,23 +369,22 @@ trunc: } -u_int +/* Multi Link Frame Relay (FRF.16) */ +void mfr_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 = "mfr_if"; - ND_TCHECK_2(p); /* minimum frame header length */ + ndo->ndo_protocol = "mfr"; + if (caplen < 2) { /* minimum frame header length */ + nd_print_trunc(ndo); + ndo->ndo_ll_hdr_len += caplen; + return; + } - if ((length = mfr_print(ndo, p, length)) == 0) - return (0); - else - return length; -trunc: - nd_print_trunc(ndo); - return caplen; + ndo->ndo_ll_hdr_len += mfr_print(ndo, p, length); } diff --git a/print.c b/print.c index 414a8955..780a6281 100644 --- a/print.c +++ b/print.c @@ -65,15 +65,6 @@ static const struct uint_printer uint_printers[] = { #if defined(DLT_PFLOG) && defined(HAVE_NET_IF_PFLOG_H) { pflog_if_print, DLT_PFLOG }, #endif -#ifdef DLT_FR - { fr_if_print, DLT_FR }, -#endif -#ifdef DLT_FRELAY - { fr_if_print, DLT_FRELAY }, -#endif -#ifdef DLT_MFR - { mfr_if_print, DLT_MFR }, -#endif #ifdef DLT_LTALK { ltalk_if_print, DLT_LTALK }, #endif @@ -125,6 +116,12 @@ static const struct void_printer void_printers[] = { #endif { ether_if_print, DLT_EN10MB }, { fddi_if_print, DLT_FDDI }, +#ifdef DLT_FR + { fr_if_print, DLT_FR }, +#endif +#ifdef DLT_FRELAY + { fr_if_print, DLT_FRELAY }, +#endif #ifdef DLT_IEEE802_11 { ieee802_11_if_print, DLT_IEEE802_11}, #endif @@ -197,6 +194,9 @@ static const struct void_printer void_printers[] = { #ifdef DLT_JUNIPER_SERVICES { juniper_services_if_print, DLT_JUNIPER_SERVICES }, #endif +#ifdef DLT_MFR + { mfr_if_print, DLT_MFR }, +#endif #ifdef DLT_NETANALYZER { netanalyzer_if_print, DLT_NETANALYZER }, #endif