X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/59864b113d8f2310a38d916e11a27c6f7e979ad9..0845bc813c1cc48b18cdefff0b387c110647463c:/print-sll.c diff --git a/print-sll.c b/print-sll.c index e15afa9e..5003a3dd 100644 --- a/print-sll.c +++ b/print-sll.c @@ -25,7 +25,7 @@ #include -#include "interface.h" +#include "netdissect.h" #include "addrtoname.h" #include "ethertype.h" #include "extract.h" @@ -197,6 +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; + int llc_hdrlen; + u_int hdrlen; if (caplen < SLL_HDR_LEN) { /* @@ -219,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); @@ -245,15 +248,17 @@ recurse: * 802.2. * Try to print the LLC-layer header & higher layers. */ - if (llc_print(ndo, p, length, caplen, NULL, NULL) == 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: /*FALLTHROUGH*/ unknown: - /* ether_type not known, print raw packet */ + /* packet type not known, print raw packet */ if (!ndo->ndo_suppress_default_print) ND_DEFAULTPRINT(p, caplen); break; @@ -263,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); @@ -283,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) { @@ -294,5 +304,5 @@ recurse: } } - return (SLL_HDR_LEN); + return (hdrlen); }