diff options
author | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2020-02-07 18:21:40 +0100 |
---|---|---|
committer | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2020-02-07 20:36:34 +0100 |
commit | 717095ab66fd1930248b6a3069ed275281214898 (patch) | |
tree | a1c5808b20f0ba91b60a369fcee608b9bdeb8e29 | |
parent | 92a263b1b36bd33612baa63b9e9ed0a41e07f05f (diff) | |
download | tcpdump-717095ab66fd1930248b6a3069ed275281214898.tar.gz |
NULL/LOOP: Update the link-layer dissector to a void function
Moreover:
Remove trailing "_if" from protocol name.
Remove a useless ND_TCHECK_4 test (GET_HE_U_4 used).
Remove a no longer used 'trunc' label.
Use uint32_t type for family in null_hdr_print().
-rw-r--r-- | netdissect.h | 2 | ||||
-rw-r--r-- | print-null.c | 20 | ||||
-rw-r--r-- | print.c | 8 |
3 files changed, 15 insertions, 15 deletions
diff --git a/netdissect.h b/netdissect.h index 4b42f4a1..1edfdbdb 100644 --- a/netdissect.h +++ b/netdissect.h @@ -505,7 +505,7 @@ extern u_int mfr_if_print IF_PRINTER_ARGS; extern u_int netanalyzer_if_print IF_PRINTER_ARGS; extern u_int netanalyzer_transparent_if_print IF_PRINTER_ARGS; extern u_int nflog_if_print IF_PRINTER_ARGS; -extern u_int null_if_print IF_PRINTER_ARGS; +extern void null_if_print IF_PRINTER_ARGS; extern u_int pflog_if_print IF_PRINTER_ARGS; extern u_int pktap_if_print IF_PRINTER_ARGS; extern u_int ppi_if_print IF_PRINTER_ARGS; diff --git a/print-null.c b/print-null.c index f730a23f..f2ea96e2 100644 --- a/print-null.c +++ b/print-null.c @@ -55,7 +55,7 @@ ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff)) static void -null_hdr_print(netdissect_options *ndo, u_int family, u_int length) +null_hdr_print(netdissect_options *ndo, uint32_t family, u_int length) { if (!ndo->ndo_qflag) { ND_PRINT("AF %s (%u)", @@ -74,18 +74,21 @@ null_hdr_print(netdissect_options *ndo, u_int family, u_int length) * 'h->len' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */ -u_int +void null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p) { u_int length = h->len; u_int caplen = h->caplen; uint32_t family; - ndo->ndo_protocol = "null_if"; - if (caplen < NULL_HDRLEN) - goto trunc; + ndo->ndo_protocol = "null"; + if (caplen < NULL_HDRLEN) { + ndo->ndo_ll_header_length += caplen; + nd_print_trunc(ndo); + return; + } + ndo->ndo_ll_header_length += NULL_HDRLEN; - ND_TCHECK_4(p); family = GET_HE_U_4(p); /* @@ -138,8 +141,5 @@ null_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char ND_DEFAULTPRINT(p, caplen); } - return (NULL_HDRLEN); -trunc: - nd_print_trunc(ndo); - return (NULL_HDRLEN); + return; } @@ -87,10 +87,6 @@ static const struct uint_printer uint_printers[] = { #ifdef DLT_IP_OVER_FC { ipfc_if_print, DLT_IP_OVER_FC }, #endif - { null_if_print, DLT_NULL }, -#ifdef DLT_LOOP - { null_if_print, DLT_LOOP }, -#endif #ifdef DLT_LANE8023 { lane_if_print, DLT_LANE8023 }, #endif @@ -236,6 +232,10 @@ static const struct void_printer void_printers[] = { #ifdef DLT_BLUETOOTH_HCI_H4_WITH_PHDR { bt_if_print, DLT_BLUETOOTH_HCI_H4_WITH_PHDR}, #endif + { null_if_print, DLT_NULL }, +#ifdef DLT_LOOP + { null_if_print, DLT_LOOP }, +#endif { raw_if_print, DLT_RAW }, #ifdef DLT_IPV4 { raw_if_print, DLT_IPV4 }, |