summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2020-08-02 12:51:01 +0200
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2020-08-02 22:10:04 +0200
commit8cda025aed3073427241b9ebfecc55c956ab05f1 (patch)
tree517a0ac483add661085bc4563cee72591d81b362
parent770b67da7640cb64fa54fb615084d3c369270368 (diff)
downloadtcpdump-8cda025aed3073427241b9ebfecc55c956ab05f1.tar.gz
SLL: Update the link-layer dissectors to void functions
Moreover: Fix two probably copy & paste errors (s/SLL_HDR_LEN/SLL2_HDR_LEN/). Remove trailing "_if" from the protocol name.
-rw-r--r--netdissect.h4
-rw-r--r--print-sll.c34
-rw-r--r--print.c12
3 files changed, 29 insertions, 21 deletions
diff --git a/netdissect.h b/netdissect.h
index 97ace620..6b2d2b3c 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -521,8 +521,8 @@ extern void prism_if_print IF_PRINTER_ARGS;
extern void raw_if_print IF_PRINTER_ARGS;
extern void sl_bsdos_if_print IF_PRINTER_ARGS;
extern void sl_if_print IF_PRINTER_ARGS;
-extern u_int sll_if_print IF_PRINTER_ARGS;
-extern u_int sll2_if_print IF_PRINTER_ARGS;
+extern void sll_if_print IF_PRINTER_ARGS;
+extern void sll2_if_print IF_PRINTER_ARGS;
extern void sunatm_if_print IF_PRINTER_ARGS;
extern void symantec_if_print IF_PRINTER_ARGS;
extern u_int token_if_print IF_PRINTER_ARGS;
diff --git a/print-sll.c b/print-sll.c
index fe529efa..38db4520 100644
--- a/print-sll.c
+++ b/print-sll.c
@@ -211,7 +211,7 @@ sll_print(netdissect_options *ndo, const struct sll_header *sllp, 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
sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
@@ -222,7 +222,7 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
int llc_hdrlen;
u_int hdrlen;
- ndo->ndo_protocol = "sll_if";
+ ndo->ndo_protocol = "sll";
if (caplen < SLL_HDR_LEN) {
/*
* XXX - this "can't happen" because "pcap-linux.c" always
@@ -230,7 +230,8 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
* cooked socket capture.
*/
nd_print_trunc(ndo);
- return (caplen);
+ ndo->ndo_ll_hdr_len += caplen;
+ return;
}
sllp = (const struct sll_header *)p;
@@ -254,7 +255,9 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
* This is an packet with a radiotap header;
* just dissect the payload as such.
*/
- return (SLL_HDR_LEN + ieee802_11_radio_print(ndo, p, length, caplen));
+ ndo->ndo_ll_hdr_len += SLL_HDR_LEN;
+ ndo->ndo_ll_hdr_len += ieee802_11_radio_print(ndo, p, length, caplen);
+ return;
}
ether_type = GET_BE_U_2(sllp->sll_protocol);
@@ -304,7 +307,8 @@ recurse:
if (caplen < 4) {
ndo->ndo_protocol = "vlan";
nd_print_trunc(ndo);
- return (hdrlen + caplen);
+ ndo->ndo_ll_hdr_len += hdrlen + caplen;
+ return;
}
if (ndo->ndo_eflag) {
uint16_t tag = GET_BE_U_2(p);
@@ -334,7 +338,7 @@ recurse:
}
}
- return (hdrlen);
+ ndo->ndo_ll_hdr_len += hdrlen;
}
static void
@@ -399,7 +403,7 @@ sll2_print(netdissect_options *ndo, const struct sll2_header *sllp, 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
sll2_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char *p)
{
u_int caplen = h->caplen;
@@ -414,7 +418,7 @@ sll2_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
char ifname[IF_NAMESIZE];
#endif
- ndo->ndo_protocol = "sll2_if";
+ ndo->ndo_protocol = "sll2";
if (caplen < SLL2_HDR_LEN) {
/*
* XXX - this "can't happen" because "pcap-linux.c" always
@@ -422,7 +426,8 @@ sll2_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
* cooked socket capture.
*/
nd_print_trunc(ndo);
- return (caplen);
+ ndo->ndo_ll_hdr_len += caplen;
+ return;
}
sllp = (const struct sll2_header *)p;
@@ -455,7 +460,9 @@ sll2_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
* This is an packet with a radiotap header;
* just dissect the payload as such.
*/
- return (SLL_HDR_LEN + ieee802_11_radio_print(ndo, p, length, caplen));
+ ndo->ndo_ll_hdr_len += SLL2_HDR_LEN;
+ ndo->ndo_ll_hdr_len += ieee802_11_radio_print(ndo, p, length, caplen);
+ return;
}
ether_type = GET_BE_U_2(sllp->sll2_protocol);
@@ -505,7 +512,8 @@ recurse:
if (caplen < 4) {
ndo->ndo_protocol = "vlan";
nd_print_trunc(ndo);
- return (hdrlen + caplen);
+ ndo->ndo_ll_hdr_len += hdrlen + caplen;
+ return;
}
if (ndo->ndo_eflag) {
uint16_t tag = GET_BE_U_2(p);
@@ -529,11 +537,11 @@ recurse:
if (ethertype_print(ndo, ether_type, p, length, caplen, NULL, NULL) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
- sll2_print(ndo, sllp, length + SLL_HDR_LEN);
+ sll2_print(ndo, sllp, length + SLL2_HDR_LEN);
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
}
}
- return (hdrlen);
+ ndo->ndo_ll_hdr_len += hdrlen;
}
diff --git a/print.c b/print.c
index e5f39649..b783e40d 100644
--- a/print.c
+++ b/print.c
@@ -69,12 +69,6 @@ static const struct uint_printer uint_printers[] = {
{ pflog_if_print, DLT_PFLOG },
#endif
{ token_if_print, DLT_IEEE802 },
-#ifdef DLT_LINUX_SLL
- { sll_if_print, DLT_LINUX_SLL },
-#endif
-#ifdef DLT_LINUX_SLL2
- { sll2_if_print, DLT_LINUX_SLL2 },
-#endif
#ifdef DLT_FR
{ fr_if_print, DLT_FR },
#endif
@@ -240,6 +234,12 @@ static const struct void_printer void_printers[] = {
{ sl_bsdos_if_print, DLT_SLIP_BSDOS },
#endif
{ sl_if_print, DLT_SLIP },
+#ifdef DLT_LINUX_SLL
+ { sll_if_print, DLT_LINUX_SLL },
+#endif
+#ifdef DLT_LINUX_SLL2
+ { sll2_if_print, DLT_LINUX_SLL2 },
+#endif
#ifdef DLT_SUNATM
{ sunatm_if_print, DLT_SUNATM },
#endif