aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2020-02-08 10:42:36 +0100
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2020-02-08 10:50:49 +0100
commit59cad18b62c33b93ce2a6386941cb6b16b044bab (patch)
tree687502c3e6026d9af7c56da348a6533dc0aee076
parentc3f8e04764b5f9dcb424722aaeee9598e705faed (diff)
downloadtcpdump-59cad18b62c33b93ce2a6386941cb6b16b044bab.tar.gz
IPNET: Update the link-layer dissector to a void function
Moreover: Remove trailing "_if" from protocol name. Remove a useless ND_TCHECK_1 test (GET_U_1 is used). Remove a no longer used 'trunc' label.
-rw-r--r--netdissect.h2
-rw-r--r--print-ipnet.c18
-rw-r--r--print.c6
3 files changed, 12 insertions, 14 deletions
diff --git a/netdissect.h b/netdissect.h
index b6fe0b51..76a18425 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -483,7 +483,7 @@ extern u_int ieee802_15_4_if_print IF_PRINTER_ARGS;
extern u_int ieee802_15_4_tap_if_print IF_PRINTER_ARGS;
extern u_int ipfc_if_print IF_PRINTER_ARGS;
extern u_int ipoib_if_print IF_PRINTER_ARGS;
-extern u_int ipnet_if_print IF_PRINTER_ARGS;
+extern void ipnet_if_print IF_PRINTER_ARGS;
extern u_int juniper_atm1_if_print IF_PRINTER_ARGS;
extern u_int juniper_atm2_if_print IF_PRINTER_ARGS;
extern u_int juniper_chdlc_if_print IF_PRINTER_ARGS;
diff --git a/print-ipnet.c b/print-ipnet.c
index 7c6a301b..f958d42c 100644
--- a/print-ipnet.c
+++ b/print-ipnet.c
@@ -65,9 +65,12 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
{
const ipnet_hdr_t *hdr;
- ndo->ndo_protocol = "ipnet";
- if (caplen < sizeof(ipnet_hdr_t))
- goto trunc;
+ if (caplen < sizeof(ipnet_hdr_t)) {
+ ndo->ndo_ll_header_length += caplen;
+ nd_print_trunc(ndo);
+ return;
+ }
+ ndo->ndo_ll_header_length += sizeof(ipnet_hdr_t);
if (ndo->ndo_eflag)
ipnet_hdr_print(ndo, p, length);
@@ -77,7 +80,6 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
hdr = (const ipnet_hdr_t *)p;
p += sizeof(ipnet_hdr_t);
- ND_TCHECK_1(hdr->iph_family);
switch (GET_U_1(hdr->iph_family)) {
case IPH_AF_INET:
@@ -98,8 +100,6 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
break;
}
return;
-trunc:
- nd_print_trunc(ndo);
}
/*
@@ -108,13 +108,11 @@ trunc:
* 'h->len' is the length of the packet off the wire, and 'h->caplen'
* is the number of bytes actually captured.
*/
-u_int
+void
ipnet_if_print(netdissect_options *ndo,
const struct pcap_pkthdr *h, const u_char *p)
{
- ndo->ndo_protocol = "ipnet_if";
+ ndo->ndo_protocol = "ipnet";
ipnet_print(ndo, p, h->len, h->caplen);
-
- return (sizeof(ipnet_hdr_t));
}
#endif /* DLT_IPNET */
diff --git a/print.c b/print.c
index 8543a8b3..71502c2d 100644
--- a/print.c
+++ b/print.c
@@ -54,9 +54,6 @@ struct void_printer {
static const struct uint_printer uint_printers[] = {
{ ether_if_print, DLT_EN10MB },
-#ifdef DLT_IPNET
- { ipnet_if_print, DLT_IPNET },
-#endif
#ifdef DLT_IEEE802_15_4
{ ieee802_15_4_if_print, DLT_IEEE802_15_4 },
#endif
@@ -232,6 +229,9 @@ static const struct void_printer void_printers[] = {
#ifdef DLT_ENC
{ enc_if_print, DLT_ENC },
#endif
+#ifdef DLT_IPNET
+ { ipnet_if_print, DLT_IPNET },
+#endif
{ null_if_print, DLT_NULL },
#ifdef DLT_LOOP
{ null_if_print, DLT_LOOP },