summaryrefslogtreecommitdiffstats
path: root/contrib/tcpdump/print-sll.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2017-02-10 07:22:12 +0000
committerglebius <glebius@FreeBSD.org>2017-02-10 07:22:12 +0000
commitad0c9114e00a9a30168e0c13c17d8f65571aa67f (patch)
treecb3a133c7e3d0cba63195c130f2f7543735cd2a1 /contrib/tcpdump/print-sll.c
parent84761e71d50647a6c1a71f36b39a73c2fbe8c558 (diff)
downloadFreeBSD-src-ad0c9114e00a9a30168e0c13c17d8f65571aa67f.zip
FreeBSD-src-ad0c9114e00a9a30168e0c13c17d8f65571aa67f.tar.gz
Merge r309649, r313048, r313083, r313104:
tcpdump 4.9.0
Diffstat (limited to 'contrib/tcpdump/print-sll.c')
-rw-r--r--contrib/tcpdump/print-sll.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/contrib/tcpdump/print-sll.c b/contrib/tcpdump/print-sll.c
index 1f5f600..6148569 100644
--- a/contrib/tcpdump/print-sll.c
+++ b/contrib/tcpdump/print-sll.c
@@ -19,14 +19,15 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#define NETDISSECT_REWORKED
+/* \summary: Linux cooked sockets capture printer */
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <tcpdump-stdinc.h>
+#include <netdissect-stdinc.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "ethertype.h"
#include "extract.h"
@@ -198,7 +199,8 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
u_int length = h->len;
register const struct sll_header *sllp;
u_short ether_type;
- u_short extracted_ethertype;
+ int llc_hdrlen;
+ u_int hdrlen;
if (caplen < SLL_HDR_LEN) {
/*
@@ -221,6 +223,7 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
length -= SLL_HDR_LEN;
caplen -= SLL_HDR_LEN;
p += SLL_HDR_LEN;
+ hdrlen = SLL_HDR_LEN;
ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
@@ -247,23 +250,17 @@ recurse:
* 802.2.
* Try to print the LLC-layer header & higher layers.
*/
- if (llc_print(ndo, p, length, caplen, NULL, NULL,
- &extracted_ethertype) == 0)
+ llc_hdrlen = llc_print(ndo, p, length, caplen, NULL, NULL);
+ if (llc_hdrlen < 0)
goto unknown; /* unknown LLC type */
+ hdrlen += llc_hdrlen;
break;
default:
- extracted_ethertype = 0;
/*FALLTHROUGH*/
unknown:
- /* ether_type not known, print raw packet */
- if (!ndo->ndo_eflag)
- sll_print(ndo, sllp, length + SLL_HDR_LEN);
- if (extracted_ethertype) {
- ND_PRINT((ndo, "(LLC %s) ",
- etherproto_string(htons(extracted_ethertype))));
- }
+ /* packet type not known, print raw packet */
if (!ndo->ndo_suppress_default_print)
ND_DEFAULTPRINT(p, caplen);
break;
@@ -273,9 +270,13 @@ recurse:
* Print VLAN information, and then go back and process
* the enclosed type field.
*/
- if (caplen < 4 || length < 4) {
+ if (caplen < 4) {
+ ND_PRINT((ndo, "[|vlan]"));
+ return (hdrlen + caplen);
+ }
+ if (length < 4) {
ND_PRINT((ndo, "[|vlan]"));
- return (SLL_HDR_LEN);
+ return (hdrlen + length);
}
if (ndo->ndo_eflag) {
uint16_t tag = EXTRACT_16BITS(p);
@@ -293,9 +294,10 @@ recurse:
p += 4;
length -= 4;
caplen -= 4;
+ hdrlen += 4;
goto recurse;
} else {
- if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) {
+ if (ethertype_print(ndo, ether_type, p, length, caplen, NULL, NULL) == 0) {
/* ether_type not known, print raw packet */
if (!ndo->ndo_eflag)
sll_print(ndo, sllp, length + SLL_HDR_LEN);
@@ -304,5 +306,5 @@ recurse:
}
}
- return (SLL_HDR_LEN);
+ return (hdrlen);
}
OpenPOWER on IntegriCloud