]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Have print_llc() clear out the extracted_ethertype argument, rather than
authorguy <guy>
Sun, 13 Nov 2005 12:12:41 +0000 (12:12 +0000)
committerguy <guy>
Sun, 13 Nov 2005 12:12:41 +0000 (12:12 +0000)
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).

print-ether.c
print-fddi.c
print-ipfc.c
print-lane.c
print-llc.c
print-sll.c
print-token.c

index 13c06174fa1931f8b2056936bd77926c0be0e847..6766faba6ba8ae2fdea1c48b26fdf3981cc30406 100644 (file)
@@ -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),
index 308f8c903da7a42fbd2bd8da2e1722bca8c858b7..1e7d554ad7104268ef61f4276de0b5468801dc64 100644 (file)
@@ -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),
index e19d9791ac8c6c9909a3f831ea19552f9bdf79bd..c980765196b3d4835b0c578fc8724aec5c83196e 100644 (file)
@@ -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) {
index ab03a44a38b0a947ec8636d83d514790827b44c1..33723aaa4751c4953d394aa684682f7c5eebc723 100644 (file)
@@ -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,
index 50ba5cdee1c0fb075c8c82ebd4ffbb622e475033..a797804ba938947c487ea5c2ce00f42b8da40921 100644 (file)
@@ -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;
index 989583029fec455262c82e8eb808a61eaebda24c..d96b3de29ee208da72a24fb6bf70e9c12e5d4ecf 100644 (file)
@@ -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)
index d17e9506863544d53a840db6f379597b68a0223b..04defa9921b685e942762ba8f608c1602aaa597b 100644 (file)
@@ -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),