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 13c0617..6766fab 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 @@
     { 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 @@
 	/*
 	 * 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 308f8c9..1e7d554 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 @@
 	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 e19d979..c980765 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 @@
 	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 ab03a44..33723aa 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 @@
 	/*
 	 * 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 50ba5cd..a797804 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 @@
 	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 @@
 	}
 
 	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 @@
 		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 @@
             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 @@
 	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 @@
 			}
 		}
 	} 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 9895830..d96b3de 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 @@
 	 * 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 @@
 			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 d17e950..04defa9 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 @@
 	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),