From: guy Date: Sun, 13 Nov 2005 12:12:41 +0000 (+0000) Subject: Have print_llc() clear out the extracted_ethertype argument, rather than X-Git-Tag: tcpdump-4.0.0~300 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/dd928cfb35d7ceeacf55dd880ffc9673ac8809e7 Have print_llc() clear out the extracted_ethertype argument, rather than having its callers do so - some of its callers *weren't* doing so, leaving random junk in that argument in some cases. When checking for "802.3-encapsulated" IPX, check the raw values of the SSAP and DSAP for 0xFF, don't check them after the low-order bit has been masked off. The "flag" values in the LLC header aren't bits, they're combinations of bits, including the combination "no bits"; don't use "bittok2str()" on them. Also, combine the proper bits, namely the C/R bit (which we weren't combining) and the P/F bit (which we were). --- diff --git a/print-ether.c b/print-ether.c index 13c06174..6766faba 100644 --- a/print-ether.c +++ b/print-ether.c @@ -20,7 +20,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.99 2005-07-10 14:41:34 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.100 2005-11-13 12:12:41 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -47,7 +47,7 @@ const struct tok ethertype_values[] = { { ETHERTYPE_VMAN, "VMAN" }, { ETHERTYPE_PUP, "PUP" }, { ETHERTYPE_ARP, "ARP"}, - { ETHERTYPE_REVARP , "Reverse ARP"}, + { ETHERTYPE_REVARP, "Reverse ARP"}, { ETHERTYPE_NS, "NS" }, { ETHERTYPE_SPRITE, "Sprite" }, { ETHERTYPE_TRAIL, "Trail" }, @@ -128,7 +128,6 @@ ether_print(const u_char *p, u_int length, u_int caplen) /* * Is it (gag) an 802.3 encapsulation? */ - extracted_ether_type = 0; if (ether_type <= ETHERMTU) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ESRC(ep), EDST(ep), diff --git a/print-fddi.c b/print-fddi.c index 308f8c90..1e7d554a 100644 --- a/print-fddi.c +++ b/print-fddi.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.65 2005-07-07 01:22:18 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.66 2005-11-13 12:12:41 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -264,7 +264,6 @@ fddi_print(const u_char *p, u_int length, u_int caplen) caplen -= FDDI_HDRLEN; /* Frame Control field determines interpretation of packet */ - extracted_ethertype = 0; if ((fddip->fddi_fc & FDDIFC_CLFF) == FDDIFC_LLC_ASYNC) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr), diff --git a/print-ipfc.c b/print-ipfc.c index e19d9791..c9807651 100644 --- a/print-ipfc.c +++ b/print-ipfc.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.8 2005-07-07 01:22:19 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ipfc.c,v 1.9 2005-11-13 12:12:42 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -101,8 +101,6 @@ ipfc_print(const u_char *p, u_int length, u_int caplen) p += IPFC_HDRLEN; caplen -= IPFC_HDRLEN; - /* Frame Control field determines interpretation of packet */ - extracted_ethertype = 0; /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr), &extracted_ethertype) == 0) { diff --git a/print-lane.c b/print-lane.c index ab03a44a..33723aaa 100644 --- a/print-lane.c +++ b/print-lane.c @@ -22,7 +22,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.24 2005-07-07 01:22:19 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.25 2005-11-13 12:12:42 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -134,7 +134,6 @@ lane_print(const u_char *p, u_int length, u_int caplen) /* * Is it (gag) an 802.3 encapsulation? */ - extracted_ethertype = 0; if (ether_type <= ETHERMTU) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ep->h_source, ep->h_dest, diff --git a/print-llc.c b/print-llc.c index 50ba5cde..a797804b 100644 --- a/print-llc.c +++ b/print-llc.c @@ -24,7 +24,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.66 2005-09-29 07:37:08 hannes Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.67 2005-11-13 12:12:42 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -138,6 +138,8 @@ llc_print(const u_char *p, u_int length, u_int caplen, int is_u; register int ret; + *extracted_ethertype = 0; + if (caplen < 3) { (void)printf("[|llc]"); default_print((u_char *)p, caplen); @@ -145,9 +147,7 @@ llc_print(const u_char *p, u_int length, u_int caplen, } dsap_field = *p; - dsap = dsap_field & ~LLC_IG; ssap_field = *(p + 1); - ssap = ssap_field & ~LLC_GSAP; /* * OK, what type of LLC frame is this? The length @@ -179,7 +179,7 @@ llc_print(const u_char *p, u_int length, u_int caplen, is_u = 0; } - if (ssap == LLCSAP_GLOBAL && dsap == LLCSAP_GLOBAL) { + if (ssap_field == LLCSAP_GLOBAL && dsap_field == LLCSAP_GLOBAL) { /* * This is an Ethernet_802.3 IPX frame; it has an * 802.3 header (i.e., an Ethernet header where the @@ -202,6 +202,9 @@ llc_print(const u_char *p, u_int length, u_int caplen, return (1); } + dsap = dsap_field & ~LLC_IG; + ssap = ssap_field & ~LLC_GSAP; + if (eflag) { printf("LLC, dsap %s (0x%02x), ssap %s (0x%02x)", tok2str(llc_values, "Unknown", dsap), @@ -319,7 +322,7 @@ llc_print(const u_char *p, u_int length, u_int caplen, if (is_u) { printf("Unnumbered, %s, Flags [%s], length %u", tok2str(llc_cmd_values, "%02x", LLC_U_CMD(control)), - bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_U_POLL)), + tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_U_POLL)), length); p += 3; @@ -335,18 +338,17 @@ llc_print(const u_char *p, u_int length, u_int caplen, } } } else { - if ((control & LLC_S_FMT) == LLC_S_FMT) { (void)printf("Supervisory, %s, rcv seq %u, Flags [%s], length %u", tok2str(llc_supervisory_values,"?",LLC_S_CMD(control)), LLC_IS_NR(control), - bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_IS_POLL)), + tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)), length); } else { (void)printf("Information, send seq %u, rcv seq %u, Flags [%s], length %u", LLC_I_NS(control), LLC_IS_NR(control), - bittok2str(llc_flag_values,"?",(ssap) | (control & LLC_IS_POLL)), + tok2str(llc_flag_values,"?",(ssap_field & LLC_GSAP) | (control & LLC_IS_POLL)), length); } p += 4; diff --git a/print-sll.c b/print-sll.c index 98958302..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.18 2005-07-07 01:22:21 guy 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 @@ -148,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? @@ -173,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) diff --git a/print-token.c b/print-token.c index d17e9506..04defa99 100644 --- a/print-token.c +++ b/print-token.c @@ -25,7 +25,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.26 2005-07-07 01:22:21 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.27 2005-11-13 12:12:43 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -153,7 +153,6 @@ token_print(const u_char *p, u_int length, u_int caplen) caplen -= hdr_len; /* Frame Control field determines interpretation of packet */ - extracted_ethertype = 0; if (FRAME_TYPE(trp) == TOKEN_FC_LLC) { /* Try to print the LLC-layer header & higher layers */ if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),