]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Have separate "struct tok" PID-to-name tables for different OUIs; don't
authorguy <guy>
Mon, 25 Apr 2005 17:56:43 +0000 (17:56 +0000)
committerguy <guy>
Mon, 25 Apr 2005 17:56:43 +0000 (17:56 +0000)
print-ether.c
print-llc.c

index a12e7b05342edddd77e811195053ef4f97c6dfdc..c845ae4d6a7183b362bd9f48550c7e0d72b5103b 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.95 2005-04-06 21:32:39 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.96 2005-04-25 17:56:43 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -37,24 +37,8 @@ static const char rcsid[] _U_ =
 #include "ethertype.h"
 
 #include "ether.h"
-#include "llc.h"
 
 const struct tok ethertype_values[] = { 
-    /* not really ethertypes but PIDs that are used
-       in the SNAP printer - its more convenient
-       to put them into a single tokentable */
-    { PID_RFC2684_ETH_FCS,      "Ethernet + FCS" },
-    { PID_RFC2684_ETH_NOFCS,    "Ethernet no FCS" },
-    { PID_RFC2684_802_4_FCS,    "802.4 + FCS" },
-    { PID_RFC2684_802_4_NOFCS,  "w/o FCS" },
-    { PID_RFC2684_802_5_FCS,    "Tokenring + FCS" },
-    { PID_RFC2684_802_5_NOFCS,  "Tokenring no FCS" },
-    { PID_RFC2684_FDDI_FCS,     "FDDI + FCS" },
-    { PID_RFC2684_FDDI_NOFCS,   "FDDI no FCS" },
-    { PID_RFC2684_802_6_FCS,    "802.6 + FCS" },
-    { PID_RFC2684_802_6_NOFCS,  "802.6 no FCS" },
-    { PID_RFC2684_BPDU,         "BPDU" },
-    /* the real Ethertypes */
     { ETHERTYPE_IP,            "IPv4" },
     { ETHERTYPE_MPLS,          "MPLS unicast" },
     { ETHERTYPE_MPLS_MULTI,    "MPLS multicast" },
index 52250f2ffb537e082bfa3d8dea7c63c82ea2f07c..114a30df67f703ef2a9b642c81e7f09e5c4440a6 100644 (file)
@@ -24,7 +24,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.61 2005-04-06 21:32:41 mcr Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.62 2005-04-25 17:56:43 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -73,6 +73,32 @@ static struct tok cmd2str[] = {
        { 0,            NULL }
 };
 
+struct oui_tok {
+       u_int32_t       oui;
+       const struct tok *tok;
+};
+
+static const struct tok bridged_values[] = { 
+    { PID_RFC2684_ETH_FCS,      "Ethernet + FCS" },
+    { PID_RFC2684_ETH_NOFCS,    "Ethernet w/o FCS" },
+    { PID_RFC2684_802_4_FCS,    "802.4 + FCS" },
+    { PID_RFC2684_802_4_NOFCS,  "802.4 w/o FCS" },
+    { PID_RFC2684_802_5_FCS,    "Token Ring + FCS" },
+    { PID_RFC2684_802_5_NOFCS,  "Token Ring w/o FCS" },
+    { PID_RFC2684_FDDI_FCS,     "FDDI + FCS" },
+    { PID_RFC2684_FDDI_NOFCS,   "FDDI w/o FCS" },
+    { PID_RFC2684_802_6_FCS,    "802.6 + FCS" },
+    { PID_RFC2684_802_6_NOFCS,  "802.6 w/o FCS" },
+    { PID_RFC2684_BPDU,         "BPDU" },
+    { 0,                        NULL },
+};
+
+static const struct oui_tok oui_to_tok[] = {
+       { 0x000000, ethertype_values },
+       { 0x0080C2, bridged_values },   /* bridged, RFC 2427 FR or RFC 2864 ATM */
+       { 0, NULL }
+};
+
 /*
  * Returns non-zero IFF it succeeds in printing the header
  */
@@ -221,12 +247,23 @@ llc_print(const u_char *p, u_int length, u_int caplen,
                orgcode = EXTRACT_24BITS(&llc.llc_orgcode[0]);
                et = EXTRACT_16BITS(&llc.llc_ethertype[0]);
 
-                if (eflag)
-                    (void)printf("oui %s (0x%06x), ethertype %s (0x%04x): ",
-                                 tok2str(oui_values,"Unknown",orgcode),
-                                 orgcode,
-                                 tok2str(ethertype_values,"Unknown", et),
-                                 et);
+               if (eflag) {
+                       const struct tok *tok = NULL;
+                       const struct oui_tok *otp;
+
+                       for (otp = &oui_to_tok[0]; otp->tok != NULL; otp++) {
+                               if (otp->oui == orgcode) {
+                                       tok = otp->tok;
+                                       break;
+                               }
+                       }
+                       (void)printf("oui %s (0x%06x), %s %s (0x%04x): ",
+                            tok2str(oui_values, "Unknown", orgcode),
+                            orgcode,
+                            (orgcode == 0x000000 ? "ethertype" : "pid"),
+                            tok2str(tok, "Unknown", et),
+                            et);
+               }
 
                /*
                 * XXX - what *is* the right bridge pad value here?