summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2020-08-01 14:05:59 +0200
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2020-08-06 22:36:16 +0200
commit0c93b15d38b3f63047344fcb2ea920e73498bb3d (patch)
treef35738ae5f17b87357aecbe5b4927910ac392143
parent6855c11117b46c93c5ea83b2a9436e67f4dae254 (diff)
downloadtcpdump-0c93b15d38b3f63047344fcb2ea920e73498bb3d.tar.gz
Rework "Update more link-layer dissectors to void functions"
It's a follow-up to commit 81dbf4a0b05092760d0ff0cdd48c692e4769ba99. There is no need to update ether_print(), ether_common_print() and ether_switch_tag_print() to void functions: back to u_int functions. There is also no need to add a flag parameter to ether_print(), ether_common_print() and ether_switch_tag_print(): Remove it.
-rw-r--r--netdissect.h4
-rw-r--r--print-bcm-li.c2
-rw-r--r--print-brcmtag.c9
-rw-r--r--print-dsa.c8
-rw-r--r--print-ether.c71
-rw-r--r--print-geneve.c2
-rw-r--r--print-gre.c2
-rw-r--r--print-juniper.c9
-rw-r--r--print-lane.c2
-rw-r--r--print-llc.c2
-rw-r--r--print-nsh.c2
-rw-r--r--print-openflow-1.0.c2
-rw-r--r--print-otv.c2
-rw-r--r--print-vxlan-gpe.c2
-rw-r--r--print-vxlan.c2
15 files changed, 53 insertions, 68 deletions
diff --git a/netdissect.h b/netdissect.h
index efcf6633..3da175da 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -582,8 +582,8 @@ extern void eapol_print(netdissect_options *, const u_char *);
extern void egp_print(netdissect_options *, const u_char *, u_int);
extern void eigrp_print(netdissect_options *, const u_char *, u_int);
extern void esp_print(netdissect_options *, const u_char *, u_int, const u_char *, u_int, int, u_int);
-extern void ether_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), const u_char *, u_int);
-extern void ether_switch_tag_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), u_int, u_int);
+extern u_int ether_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), const u_char *);
+extern u_int ether_switch_tag_print(netdissect_options *, const u_char *, u_int, u_int, void (*)(netdissect_options *, const u_char *), u_int);
extern int ethertype_print(netdissect_options *, u_short, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *);
extern u_int fddi_print(netdissect_options *, const u_char *, u_int, u_int);
extern void forces_print(netdissect_options *, const u_char *, u_int);
diff --git a/print-bcm-li.c b/print-bcm-li.c
index 32214127..0233c3cb 100644
--- a/print-bcm-li.c
+++ b/print-bcm-li.c
@@ -95,7 +95,7 @@ bcm_li_print(netdissect_options *ndo, const u_char *p, u_int length)
switch (pkt_type) {
case BCM_LI_PKT_TYPE_ETHERNET:
- ether_print(ndo, bp, length, length, NULL, NULL, FALSE);
+ ether_print(ndo, bp, length, length, NULL, NULL);
break;
case BCM_LI_PKT_TYPE_IPV4:
ip_print(ndo, bp, length);
diff --git a/print-brcmtag.c b/print-brcmtag.c
index 61521365..1e0c5884 100644
--- a/print-brcmtag.c
+++ b/print-brcmtag.c
@@ -118,9 +118,9 @@ brcm_tag_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
u_int length = h->len;
ndo->ndo_protocol = "brcm-tag";
- ndo->ndo_ll_hdr_len += 0;
- ether_switch_tag_print(ndo, p, length, caplen,
- brcm_tag_print, BRCM_TAG_LEN, TRUE);
+ ndo->ndo_ll_hdr_len +=
+ ether_switch_tag_print(ndo, p, length, caplen,
+ brcm_tag_print, BRCM_TAG_LEN);
}
void
@@ -148,5 +148,6 @@ brcm_tag_prepend_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
/*
* Now print the Ethernet frame following it.
*/
- ether_print(ndo, p, length, caplen, NULL, NULL, TRUE);
+ ndo->ndo_ll_hdr_len +=
+ ether_print(ndo, p, length, caplen, NULL, NULL);
}
diff --git a/print-dsa.c b/print-dsa.c
index aec58f48..e45dc53f 100644
--- a/print-dsa.c
+++ b/print-dsa.c
@@ -203,8 +203,8 @@ dsa_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
u_int length = h->len;
ndo->ndo_protocol = "dsa";
- ndo->ndo_ll_hdr_len += 0;
- ether_switch_tag_print(ndo, p, length, caplen, dsa_tag_print, DSA_LEN, TRUE);
+ ndo->ndo_ll_hdr_len +=
+ ether_switch_tag_print(ndo, p, length, caplen, dsa_tag_print, DSA_LEN);
}
void
@@ -214,6 +214,6 @@ edsa_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
u_int length = h->len;
ndo->ndo_protocol = "edsa";
- ndo->ndo_ll_hdr_len += 0;
- ether_switch_tag_print(ndo, p, length, caplen, edsa_tag_print, EDSA_LEN, TRUE);
+ ndo->ndo_ll_hdr_len +=
+ ether_switch_tag_print(ndo, p, length, caplen, edsa_tag_print, EDSA_LEN);
}
diff --git a/print-ether.c b/print-ether.c
index e6753946..7a1b42e0 100644
--- a/print-ether.c
+++ b/print-ether.c
@@ -133,13 +133,13 @@ ether_type_print(netdissect_options *ndo, uint16_t type)
* switch chips, and extra encapsulation header information before
* printing Ethernet header information (such as a LANE ID for ATM LANE).
*/
-static void
+static u_int
ether_common_print(netdissect_options *ndo, const u_char *p, u_int length,
u_int caplen,
void (*print_switch_tag)(netdissect_options *ndo, const u_char *),
u_int switch_tag_len,
void (*print_encap_header)(netdissect_options *ndo, const u_char *),
- const u_char *encap_header_arg, u_int do_incr_ll_hdr_len)
+ const u_char *encap_header_arg)
{
const struct ether_header *ehp;
u_int orig_length;
@@ -151,15 +151,11 @@ ether_common_print(netdissect_options *ndo, const u_char *p, u_int length,
if (caplen < ETHER_HDRLEN + switch_tag_len) {
nd_print_trunc(ndo);
- if (do_incr_ll_hdr_len)
- ndo->ndo_ll_hdr_len += caplen;
- return;
+ return caplen;
}
if (length < ETHER_HDRLEN + switch_tag_len) {
nd_print_trunc(ndo);
- if (do_incr_ll_hdr_len)
- ndo->ndo_ll_hdr_len += length;
- return;
+ return length;
}
if (print_encap_header != NULL)
@@ -230,14 +226,10 @@ recurse:
/* Payload is encrypted; print it as raw data. */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
- if (do_incr_ll_hdr_len)
- ndo->ndo_ll_hdr_len += hdrlen;
- return;
+ return hdrlen;
} else if (ret > 0) {
/* Problem printing the header; just quit. */
- if (do_incr_ll_hdr_len)
- ndo->ndo_ll_hdr_len += ret;
- return;
+ return ret;
} else {
/*
* Keep processing type/length fields.
@@ -266,16 +258,12 @@ recurse:
if (caplen < 4) {
ndo->ndo_protocol = "vlan";
nd_print_trunc(ndo);
- if (do_incr_ll_hdr_len)
- ndo->ndo_ll_hdr_len += hdrlen + caplen;
- return;
+ return hdrlen + caplen;
}
if (length < 4) {
ndo->ndo_protocol = "vlan";
nd_print_trunc(ndo);
- if (do_incr_ll_hdr_len)
- ndo->ndo_ll_hdr_len += hdrlen + length;
- return;
+ return hdrlen + length;
}
if (ndo->ndo_eflag) {
uint16_t tag = GET_BE_U_2(p);
@@ -358,15 +346,11 @@ recurse:
} else if (length_type == ETHERTYPE_ARISTA) {
if (caplen < 2) {
ND_PRINT("[|arista]");
- if (do_incr_ll_hdr_len)
- ndo->ndo_ll_hdr_len += hdrlen + caplen;
- return;
+ return hdrlen + caplen;
}
if (length < 2) {
ND_PRINT("[|arista]");
- if (do_incr_ll_hdr_len)
- ndo->ndo_ll_hdr_len += hdrlen + length;
- return;
+ return hdrlen + length;
}
ether_type_print(ndo, length_type);
ND_PRINT(", length %u: ", orig_length);
@@ -417,9 +401,7 @@ recurse:
ND_DEFAULTPRINT(p, caplen);
}
}
- if (do_incr_ll_hdr_len)
- ndo->ndo_ll_hdr_len += hdrlen;
- return;
+ return hdrlen;
}
/*
@@ -431,14 +413,14 @@ recurse:
*
* FIXME: caplen can and should be derived from ndo->ndo_snapend and p.
*/
-void
+u_int
ether_switch_tag_print(netdissect_options *ndo, const u_char *p, u_int length,
u_int caplen,
void (*print_switch_tag)(netdissect_options *, const u_char *),
- u_int switch_tag_len, u_int do_incr_ll_hdr_len)
+ u_int switch_tag_len)
{
- ether_common_print(ndo, p, length, caplen, print_switch_tag,
- switch_tag_len, NULL, NULL, do_incr_ll_hdr_len);
+ return ether_common_print(ndo, p, length, caplen, print_switch_tag,
+ switch_tag_len, NULL, NULL);
}
/*
@@ -449,15 +431,15 @@ ether_switch_tag_print(netdissect_options *ndo, const u_char *p, u_int length,
*
* FIXME: caplen can and should be derived from ndo->ndo_snapend and p.
*/
-void
+u_int
ether_print(netdissect_options *ndo,
const u_char *p, u_int length, u_int caplen,
void (*print_encap_header)(netdissect_options *ndo, const u_char *),
- const u_char *encap_header_arg, u_int do_incr_ll_hdr_len)
+ const u_char *encap_header_arg)
{
ndo->ndo_protocol = "ether";
- ether_common_print(ndo, p, length, caplen, NULL, 0,
- print_encap_header, encap_header_arg, do_incr_ll_hdr_len);
+ return ether_common_print(ndo, p, length, caplen, NULL, 0,
+ print_encap_header, encap_header_arg);
}
/*
@@ -471,9 +453,8 @@ ether_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
const u_char *p)
{
ndo->ndo_protocol = "ether";
- ndo->ndo_ll_hdr_len += 0;
-
- ether_print(ndo, p, h->len, h->caplen, NULL, NULL, TRUE);
+ ndo->ndo_ll_hdr_len +=
+ ether_print(ndo, p, h->len, h->caplen, NULL, NULL);
}
/*
@@ -498,10 +479,11 @@ netanalyzer_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h,
nd_print_trunc(ndo);
return;
}
- ndo->ndo_ll_hdr_len += 4;
/* Skip the pseudo-header. */
- ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL, TRUE);
+ ndo->ndo_ll_hdr_len += 4;
+ ndo->ndo_ll_hdr_len +=
+ ether_print(ndo, p + 4, h->len - 4, h->caplen - 4, NULL, NULL);
}
/*
@@ -529,10 +511,11 @@ netanalyzer_transparent_if_print(netdissect_options *ndo,
nd_print_trunc(ndo);
return;
}
- ndo->ndo_ll_hdr_len += 12;
/* Skip the pseudo-header, preamble, and SOF. */
- ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL, TRUE);
+ ndo->ndo_ll_hdr_len += 12;
+ ndo->ndo_ll_hdr_len +=
+ ether_print(ndo, p + 12, h->len - 12, h->caplen - 12, NULL, NULL);
}
/*
diff --git a/print-geneve.c b/print-geneve.c
index d3e5e87e..0b7ff6e5 100644
--- a/print-geneve.c
+++ b/print-geneve.c
@@ -232,7 +232,7 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
if (ethertype_print(ndo, prot, bp, len, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL) == 0) {
if (prot == ETHERTYPE_TEB)
- ether_print(ndo, bp, len, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL, FALSE);
+ ether_print(ndo, bp, len, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
else
ND_PRINT("geneve-proto-0x%x", prot);
}
diff --git a/print-gre.c b/print-gre.c
index 53c418fb..09b2be11 100644
--- a/print-gre.c
+++ b/print-gre.c
@@ -224,7 +224,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
isoclns_print(ndo, bp, len);
break;
case ETHERTYPE_TEB:
- ether_print(ndo, bp, len, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL, FALSE);
+ ether_print(ndo, bp, len, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
break;
default:
ND_PRINT("gre-proto-0x%x", prot);
diff --git a/print-juniper.c b/print-juniper.c
index 0061b2ba..e668d0e7 100644
--- a/print-juniper.c
+++ b/print-juniper.c
@@ -709,7 +709,7 @@ juniper_pppoe_if_print(netdissect_options *ndo,
p+=l2info.header_len;
/* this DLT contains nothing but raw ethernet frames */
- ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL, FALSE);
+ ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
ndo->ndo_ll_hdr_len += l2info.header_len;
}
#endif
@@ -730,8 +730,9 @@ juniper_ether_if_print(netdissect_options *ndo,
p+=l2info.header_len;
/* this DLT contains nothing but raw Ethernet frames */
- ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL, TRUE);
- ndo->ndo_ll_hdr_len += l2info.header_len;
+ ndo->ndo_ll_hdr_len +=
+ l2info.header_len +
+ ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
}
#endif
@@ -1127,7 +1128,7 @@ juniper_atm2_if_print(netdissect_options *ndo,
if (l2info.direction != JUNIPER_BPF_PKT_IN && /* ether-over-1483 encaps ? */
/* use EXTRACT_, not GET_ (not packet buffer pointer) */
(EXTRACT_BE_U_4(l2info.cookie) & ATM2_GAP_COUNT_MASK)) {
- ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL, FALSE);
+ ether_print(ndo, p, l2info.length, l2info.caplen, NULL, NULL);
ndo->ndo_ll_hdr_len += l2info.header_len;
return;
}
diff --git a/print-lane.c b/print-lane.c
index 09f92c06..0dc7f25c 100644
--- a/print-lane.c
+++ b/print-lane.c
@@ -113,5 +113,5 @@ lane_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen)
* Now print the encapsulated frame, under the assumption
* that it's an Ethernet frame.
*/
- ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2, FALSE);
+ ether_print(ndo, p, length, caplen, lane_hdr_print, p - 2);
}
diff --git a/print-llc.c b/print-llc.c
index c4422d94..750a8ccd 100644
--- a/print-llc.c
+++ b/print-llc.c
@@ -525,7 +525,7 @@ snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
/*
* What remains is an Ethernet packet.
*/
- ether_print(ndo, p, length, caplen, NULL, NULL, FALSE);
+ ether_print(ndo, p, length, caplen, NULL, NULL);
return (1);
case PID_RFC2684_802_5_FCS:
diff --git a/print-nsh.c b/print-nsh.c
index 70e962df..17d62569 100644
--- a/print-nsh.c
+++ b/print-nsh.c
@@ -170,7 +170,7 @@ nsh_print(netdissect_options *ndo, const u_char *bp, u_int len)
ip6_print(ndo, bp, next_len);
break;
case 0x3:
- ether_print(ndo, bp, next_len, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL, FALSE);
+ ether_print(ndo, bp, next_len, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
break;
default:
ND_PRINT("ERROR: unknown-next-protocol");
diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c
index 51ed38ef..71d8a7c1 100644
--- a/print-openflow-1.0.c
+++ b/print-openflow-1.0.c
@@ -1128,7 +1128,7 @@ of10_packet_data_print(netdissect_options *ndo,
ND_TCHECK_LEN(cp, len);
ndo->ndo_vflag -= 3;
ND_PRINT(", frame decoding below\n");
- ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL, FALSE);
+ ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL);
ndo->ndo_vflag += 3;
return cp + len;
diff --git a/print-otv.c b/print-otv.c
index f578d89e..dbcef9f6 100644
--- a/print-otv.c
+++ b/print-otv.c
@@ -67,7 +67,7 @@ otv_print(netdissect_options *ndo, const u_char *bp, u_int len)
ND_TCHECK_1(bp);
bp += 1;
- ether_print(ndo, bp, len - OTV_HDR_LEN, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL, FALSE);
+ ether_print(ndo, bp, len - OTV_HDR_LEN, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
return;
trunc:
diff --git a/print-vxlan-gpe.c b/print-vxlan-gpe.c
index eb885824..d7a80f25 100644
--- a/print-vxlan-gpe.c
+++ b/print-vxlan-gpe.c
@@ -92,7 +92,7 @@ vxlan_gpe_print(netdissect_options *ndo, const u_char *bp, u_int len)
ip6_print(ndo, bp, len - VXLAN_GPE_HDR_LEN);
break;
case 0x3:
- ether_print(ndo, bp, len - VXLAN_GPE_HDR_LEN, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL, FALSE);
+ ether_print(ndo, bp, len - VXLAN_GPE_HDR_LEN, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
break;
case 0x4:
nsh_print(ndo, bp, len - VXLAN_GPE_HDR_LEN);
diff --git a/print-vxlan.c b/print-vxlan.c
index 3d8c76c3..d2b896b0 100644
--- a/print-vxlan.c
+++ b/print-vxlan.c
@@ -65,7 +65,7 @@ vxlan_print(netdissect_options *ndo, const u_char *bp, u_int len)
ND_PRINT("flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags);
ND_PRINT("vni %u\n", vni);
- ether_print(ndo, bp, len - VXLAN_HDR_LEN, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL, FALSE);
+ ether_print(ndo, bp, len - VXLAN_HDR_LEN, ND_BYTES_AVAILABLE_AFTER(bp), NULL, NULL);
return;