X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/728363f6db3565d20aa0c5571f7413783f48cab1..9bdbb51f4122817ca8bdba9fb9917969809ff451:/print-sll.c diff --git a/print-sll.c b/print-sll.c index 0a65a8bc..d96b3de2 100644 --- a/print-sll.c +++ b/print-sll.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.16 2004-10-28 00:34:29 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.19 2005-11-13 12:12:43 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -53,6 +53,8 @@ const struct tok sll_pkttype_values[] = { static inline void sll_print(register const struct sll_header *sllp, u_int length) { + u_short ether_type; + printf("%3s ",tok2str(sll_pkttype_values,"?",EXTRACT_16BITS(&sllp->sll_pkttype))); /* @@ -63,11 +65,44 @@ sll_print(register const struct sll_header *sllp, u_int length) if (EXTRACT_16BITS(&sllp->sll_halen) == 6) (void)printf("%s ", etheraddr_string(sllp->sll_addr)); - if (!qflag) - (void)printf("ethertype %s (0x%04x), length %u: ", - tok2str(ethertype_values,"Unknown", EXTRACT_16BITS(&sllp->sll_protocol)), - EXTRACT_16BITS(&sllp->sll_protocol), - length); + if (!qflag) { + ether_type = EXTRACT_16BITS(&sllp->sll_protocol); + + if (ether_type <= ETHERMTU) { + /* + * Not an Ethernet type; what type is it? + */ + switch (ether_type) { + + case LINUX_SLL_P_802_3: + /* + * Ethernet_802.3 IPX frame. + */ + (void)printf("802.3"); + break; + + case LINUX_SLL_P_802_2: + /* + * 802.2. + */ + (void)printf("802.3"); + break; + + default: + /* + * What is it? + */ + (void)printf("ethertype Unknown (0x%04x)", + ether_type); + break; + } + } else { + (void)printf("ethertype %s (0x%04x)", + tok2str(ethertype_values, "Unknown", ether_type), + ether_type); + } + (void)printf(", length %u: ", length); + } } /* @@ -113,7 +148,6 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p) * Is it (gag) an 802.3 encapsulation, or some non-Ethernet * packet type? */ - extracted_ethertype = 0; if (ether_type <= ETHERMTU) { /* * Yes - what type is it? @@ -138,6 +172,9 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p) break; default: + extracted_ethertype = 0; + /*FALLTHROUGH*/ + unknown: /* ether_type not known, print raw packet */ if (!eflag) @@ -146,7 +183,7 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p) printf("(LLC %s) ", etherproto_string(htons(extracted_ethertype))); } - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p, caplen); break; } @@ -155,7 +192,7 @@ sll_if_print(const struct pcap_pkthdr *h, const u_char *p) /* ether_type not known, print raw packet */ if (!eflag) sll_print(sllp, length + SLL_HDR_LEN); - if (!xflag && !qflag) + if (!suppress_default_print) default_print(p, caplen); }