]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Making "extracted_ethertype" static to "print-ether.c" broke other
authorguy <guy>
Mon, 18 Dec 2000 05:41:58 +0000 (05:41 +0000)
committerguy <guy>
Mon, 18 Dec 2000 05:41:58 +0000 (05:41 +0000)
dissectors that expected calls to "llc_print()" to set it.  (Thanks and
a tip of the hat to Olaf Kirch <[email protected]> for noticing this.)

Make "ether_encap_print()" and "llc_print()" take a pointer to an
extracted-Ethertype variable as an argument, have "llc_print()" pass it
to "ether_encap_print()", and have "ether_encap_print()" set what it
points to rather than setting a static "extracted_ethertype" variable.

Get rid of said static "extracted_ethertype" variable in favor of one
local to "ether_if_print()", just as other link-layer dissectors have
local "extracted_ethertype" variables.

interface.h
print-cip.c
print-ether.c
print-fddi.c
print-gre.c
print-lane.c
print-llc.c
print-token.c

index c8462f443c1360ac66c28dbe3087a32d74d09f39..8008fc511e4dfc93858efe8d069c1d87a760354e 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.146 2000-12-05 06:42:49 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.147 2000-12-18 05:41:58 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -200,9 +200,9 @@ extern void ascii_print(const u_char *, u_int);
 extern void hex_print_with_offset(const u_char *, u_int, u_int);    
 extern void telnet_print(const u_char *, u_int);    
 extern void hex_print(const u_char *, u_int);    
-extern int ether_encap_print(u_short, const u_char *, u_int, u_int);
+extern int ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *);
 extern int llc_print(const u_char *, u_int, u_int, const u_char *,
-       const u_char *);
+       const u_char *, u_short *);
 extern void aarp_print(const u_char *, u_int);
 extern void arp_print(const u_char *, u_int, u_int);
 extern void atalk_print(const u_char *, u_int);
index 248fb5e43351a600f4b04ce358601b6c0e6a62e6..7a2de818c1a3f8ee6b634669abdd4cb5e5cba296 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.9 2000-09-29 04:58:35 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-cip.c,v 1.10 2000-12-18 05:41:58 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -132,7 +132,8 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
        extracted_ethertype = 0;
        if (ether_type < ETHERMTU) {
                /* Try to print the LLC-layer header & higher layers */
-               if (llc_print(p, length, caplen, NULL, NULL)==0) {
+               if (llc_print(p, length, caplen, NULL, NULL,
+                   &extracted_ethertype)==0) {
                        /* ether_type not known, print raw packet */
                        if (!eflag)
                                cip_print((u_char *)bp, length);
@@ -143,7 +144,8 @@ cip_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                        if (!xflag && !qflag)
                                default_print(p, caplen);
                }
-       } else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
+       } else if (ether_encap_print(ether_type, p, length, caplen,
+           &extracted_ethertype) == 0) {
                /* ether_type not known, print raw packet */
                if (!eflag)
                        cip_print((u_char *)bp, length + RFC1483LLC_LEN);
index 167c53e21337a70c3ff092d445ac9e7dfc720e38..0711cca9651dac52593238d27d7a50b2789095b3 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.59 2000-10-22 04:17:53 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.60 2000-12-18 05:41:59 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -67,8 +67,6 @@ ether_print(register const u_char *bp, u_int length)
                             length);
 }
 
-static u_short extracted_ethertype;
-
 /*
  * This is the top level routine of the printer.  'p' is the points
  * to the ether header of the packet, 'h->tv' is the timestamp,
@@ -82,6 +80,7 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
        u_int length = h->len;
        struct ether_header *ep;
        u_short ether_type;
+       u_short extracted_ethertype;
 
        ts_print(&h->ts);
 
@@ -114,7 +113,8 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
        extracted_ethertype = 0;
        if (ether_type <= ETHERMTU) {
                /* Try to print the LLC-layer header & higher layers */
-               if (llc_print(p, length, caplen, ESRC(ep), EDST(ep)) == 0) {
+               if (llc_print(p, length, caplen, ESRC(ep), EDST(ep),
+                   &extracted_ethertype) == 0) {
                        /* ether_type not known, print raw packet */
                        if (!eflag)
                                ether_print((u_char *)ep, length);
@@ -125,7 +125,8 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                        if (!xflag && !qflag)
                                default_print(p, caplen);
                }
-       } else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
+       } else if (ether_encap_print(ether_type, p, length, caplen,
+           &extracted_ethertype) == 0) {
                /* ether_type not known, print raw packet */
                if (!eflag)
                        ether_print((u_char *)ep, length + ETHER_HDRLEN);
@@ -144,16 +145,18 @@ ether_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
  *
  * Returns non-zero if it can do so, zero if the ethertype is unknown.
  *
- * Stuffs the ether type into a global for the benefit of lower layers
- * that might want to know what it is.
+ * The Ethernet type code is passed through a pointer; if it was
+ * ETHERTYPE_8021Q, it gets updated to be the Ethernet type of
+ * the 802.1Q payload, for the benefit of lower layers that might
+ * want to know what it is.
  */
 
 int
 ether_encap_print(u_short ethertype, const u_char *p,
-    u_int length, u_int caplen)
+    u_int length, u_int caplen, u_short *extracted_ethertype)
 {
  recurse:
-       extracted_ethertype = ethertype;
+       *extracted_ethertype = ethertype;
 
        switch (ethertype) {
 
@@ -202,15 +205,16 @@ ether_encap_print(u_short ethertype, const u_char *p,
                if (ethertype > ETHERMTU)
                        goto recurse;
 
-               extracted_ethertype = 0;
+               *extracted_ethertype = 0;
 
-               if (llc_print(p, length, caplen, p - 18, p - 12) == 0) {
+               if (llc_print(p, length, caplen, p - 18, p - 12,
+                   extracted_ethertype) == 0) {
                        /* ether_type not known, print raw packet */
                        if (!eflag)
                                ether_print(p - 18, length + 4);
-                       if (extracted_ethertype) {
+                       if (*extracted_ethertype) {
                                printf("(LLC %s) ",
-                              etherproto_string(htons(extracted_ethertype)));
+                              etherproto_string(htons(*extracted_ethertype)));
                        }
                        if (!xflag && !qflag)
                                default_print(p - 18, caplen + 4);
index f1e0ecf82df154c29dde337f5ebf5bd8f1f545cd..6763ad4bde82d827e1024124a3d54b823773928e 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.47 2000-10-09 02:59:40 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-fddi.c,v 1.48 2000-12-18 05:41:59 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -298,8 +298,8 @@ fddi_if_print(u_char *pcap, const struct pcap_pkthdr *h,
        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))
-                   == 0) {
+               if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
+                   &extracted_ethertype) == 0) {
                        /*
                         * Some kinds of LLC packet we cannot
                         * handle intelligently
index 1076c7fd44ca9588f2456f43e9e0c303ed5f4f59..1e801b91112123df9725efca53d4c1e2ac9a58fc 100644 (file)
@@ -24,7 +24,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.8 2000-09-29 04:58:39 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-gre.c,v 1.9 2000-12-18 05:41:59 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -86,7 +86,7 @@ gre_print(const u_char *bp, u_int length)
 {
        const u_char *cp = bp + 4;
        const struct gre *gre;
-       u_short flags, proto;
+       u_short flags, proto, extracted_ethertype;
 
        gre = (const struct gre *)bp;
 
@@ -123,7 +123,8 @@ gre_print(const u_char *bp, u_int length)
                cp += 4;
 
        length -= cp - bp;
-       if (ether_encap_print(proto, cp, length, length) == 0)
+       if (ether_encap_print(proto, cp, length, length,
+           &extracted_ethertype) == 0)
                printf("gre-proto-0x%04X", proto);
        return;
 
index 501031400afde8ba7a11342af70834bba060d9f8..149a5aed9f2d72f89304fe8250a3cccc28cda2fd 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.9 2000-09-29 04:58:43 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-lane.c,v 1.10 2000-12-18 05:42:00 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -112,7 +112,8 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
        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)==0) {
+               if (llc_print(p, length, caplen, ep->h_source, ep->h_dest,
+                   &extracted_ethertype) == 0) {
                        /* ether_type not known, print raw packet */
                        if (!eflag)
                                lane_print((u_char *)ep, length);
@@ -123,7 +124,8 @@ lane_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                        if (!xflag && !qflag)
                                default_print(p, caplen);
                }
-       } else if (ether_encap_print(ether_type, p, length, caplen) == 0) {
+       } else if (ether_encap_print(ether_type, p, length, caplen,
+           &extracted_ethertype) == 0) {
                /* ether_type not known, print raw packet */
                if (!eflag)
                        lane_print((u_char *)ep, length + sizeof(*ep));
index 2763c0fca4eafa0175b1901fa6d873677f3c19fd..6e757714fdcc9d661e0f394ba8f8f96458ec5e4a 100644 (file)
@@ -24,7 +24,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.30 2000-12-05 06:42:48 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.31 2000-12-18 05:42:00 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -64,7 +64,7 @@ static struct tok cmd2str[] = {
  */
 int
 llc_print(const u_char *p, u_int length, u_int caplen,
-         const u_char *esrc, const u_char *edst)
+         const u_char *esrc, const u_char *edst, u_short *extracted_ethertype)
 {
        struct llc llc;
        register u_short et;
@@ -153,7 +153,8 @@ llc_print(const u_char *p, u_int length, u_int caplen,
 
                /* This is an encapsulated Ethernet packet */
                et = EXTRACT_16BITS(&llc.ethertype[0]);
-               ret = ether_encap_print(et, p, length, caplen);
+               ret = ether_encap_print(et, p, length, caplen,
+                   extracted_ethertype);
                if (ret)
                        return (ret);
        }
index 156c61091f176fff6cf586f238613e6065f1a5d4..9fa0b63b0b2906abf7aafa6f5c9d102e62bc153f 100644 (file)
@@ -25,7 +25,7 @@
  */
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.8 2000-10-06 04:23:14 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-token.c,v 1.9 2000-12-18 05:42:00 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -180,8 +180,8 @@ token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
        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))
-                   == 0) {
+               if (llc_print(p, length, caplen, ESRC(&ehdr), EDST(&ehdr),
+                   &extracted_ethertype) == 0) {
                        /* ether_type not known, print raw packet */
                        if (!eflag)
                                token_print(trp, length,