X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/d5be981c91f153934cda3361567c857fc8d64886..0845bc813c1cc48b18cdefff0b387c110647463c:/print-sll.c diff --git a/print-sll.c b/print-sll.c index 1f5f6008..5003a3dd 100644 --- a/print-sll.c +++ b/print-sll.c @@ -19,14 +19,13 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#define NETDISSECT_REWORKED #ifdef HAVE_CONFIG_H #include "config.h" #endif #include -#include "interface.h" +#include "netdissect.h" #include "addrtoname.h" #include "ethertype.h" #include "extract.h" @@ -198,7 +197,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 +221,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 +248,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 +268,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,6 +292,7 @@ recurse: p += 4; length -= 4; caplen -= 4; + hdrlen += 4; goto recurse; } else { if (ethertype_print(ndo, ether_type, p, length, caplen) == 0) { @@ -304,5 +304,5 @@ recurse: } } - return (SLL_HDR_LEN); + return (hdrlen); }