]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ether.c
Add support for Apple's IP-over-IEEE 1394 encapsulation.
[tcpdump] / print-ether.c
index 2704148df8721eb77e17a8b8363fb53883e982cc..e9230d2fc752bc2d11ab02276ff3055526f7e481 100644 (file)
@@ -19,8 +19,8 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 #ifndef lint
-static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.81 2003-05-28 12:56:52 hannes Exp $ (LBL)";
+static const char rcsid[] _U_ =
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.82.2.3 2003-12-29 22:42:21 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -40,6 +40,39 @@ static const char rcsid[] =
 
 const u_char *snapend;
 
+const struct tok ethertype_values[] = { 
+    { ETHERTYPE_IP,            "IPv4" },
+    { ETHERTYPE_MPLS,          "MPLS unicast" },
+    { ETHERTYPE_MPLS_MULTI,    "MPLS multicast" },
+    { ETHERTYPE_IPV6,          "IPv6" },
+    { ETHERTYPE_8021Q,         "802.1Q" },
+    { ETHERTYPE_VMAN,          "VMAN" },
+    { ETHERTYPE_PUP,            "PUP" },
+    { ETHERTYPE_ARP,            "ARP"},
+    { ETHERTYPE_REVARP ,        "Reverse ARP"},
+    { ETHERTYPE_NS,             "NS" },
+    { ETHERTYPE_SPRITE,         "Sprite" },
+    { ETHERTYPE_TRAIL,          "Trail" },
+    { ETHERTYPE_MOPDL,          "MOP DL" },
+    { ETHERTYPE_MOPRC,          "MOP RC" },
+    { ETHERTYPE_DN,             "DN" },
+    { ETHERTYPE_LAT,            "LAT" },
+    { ETHERTYPE_SCA,            "SCA" },
+    { ETHERTYPE_LANBRIDGE,      "Lanbridge" },
+    { ETHERTYPE_DECDNS,         "DEC DNS" },
+    { ETHERTYPE_DECDTS,         "DEC DTS" },
+    { ETHERTYPE_VEXP,           "VEXP" },
+    { ETHERTYPE_VPROD,          "VPROD" },
+    { ETHERTYPE_ATALK,          "Appletalk" },
+    { ETHERTYPE_AARP,           "Appletalk ARP" },
+    { ETHERTYPE_IPX,            "IPX" },
+    { ETHERTYPE_PPP,            "PPP" },
+    { ETHERTYPE_PPPOED,         "PPPoE D" },
+    { ETHERTYPE_PPPOES,         "PPPoE S" },
+    { ETHERTYPE_LOOPBACK,       "Loopback" },
+    { 0, NULL}
+};
+
 static inline void
 ether_hdr_print(register const u_char *bp, u_int length)
 {
@@ -54,8 +87,14 @@ ether_hdr_print(register const u_char *bp, u_int length)
                if (ntohs(ep->ether_type) <= ETHERMTU)
                          (void)printf(", 802.3");
                 else 
-                         (void)printf(", ethertype %s",
-                                      tok2str(ethertype_values,"0x%04x", ntohs(ep->ether_type)));            
+                         (void)printf(", ethertype %s (0x%04x)",
+                                      tok2str(ethertype_values,"Unknown", ntohs(ep->ether_type)),
+                                       ntohs(ep->ether_type));       
+        } else {
+                if (ntohs(ep->ether_type) <= ETHERMTU)
+                          (void)printf(", 802.3");
+                else 
+                          (void)printf(", %s", tok2str(ethertype_values,"Unknown Ethertype (0x%04x)", ntohs(ep->ether_type)));  
         }
 
        (void)printf(", length %u: ", length);
@@ -106,7 +145,7 @@ ether_print(const u_char *p, u_int length, u_int caplen)
 
                if (!xflag && !qflag)
                        default_print(p, caplen);
-       }
+       } 
 }
 
 /*
@@ -222,7 +261,7 @@ ether_encap_print(u_short ether_type, const u_char *p,
                return (1);
 
         case ETHERTYPE_LOOPBACK:
-                return (1);
+                return (0);
 
        case ETHERTYPE_MPLS:
        case ETHERTYPE_MPLS_MULTI: