]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Don't show the packet type as an Ethernet type if it's not one.
authorguy <guy>
Tue, 26 Apr 2005 00:16:28 +0000 (00:16 +0000)
committerguy <guy>
Tue, 26 Apr 2005 00:16:28 +0000 (00:16 +0000)
print-sll.c

index 0a65a8bc68bde4b22453ba05c19ecb5b1acc8651..c08dd83b480d0bd635027b0edde20bea60f51436 100644 (file)
@@ -20,7 +20,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.16 2004-10-28 00:34:29 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-sll.c,v 1.17 2005-04-26 00:16:28 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -53,6 +53,8 @@ const struct tok sll_pkttype_values[] = {
 static inline void
 sll_print(register const struct sll_header *sllp, u_int length)
 {
+       u_short ether_type;
+
         printf("%3s ",tok2str(sll_pkttype_values,"?",EXTRACT_16BITS(&sllp->sll_pkttype)));
 
        /*
@@ -63,11 +65,44 @@ sll_print(register const struct sll_header *sllp, u_int length)
        if (EXTRACT_16BITS(&sllp->sll_halen) == 6)
                (void)printf("%s ", etheraddr_string(sllp->sll_addr));
 
-       if (!qflag)
-                (void)printf("ethertype %s (0x%04x), length %u: ",
-                         tok2str(ethertype_values,"Unknown", EXTRACT_16BITS(&sllp->sll_protocol)),
-                         EXTRACT_16BITS(&sllp->sll_protocol),
-                         length);
+       if (!qflag) {
+               ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
+       
+               if (ether_type <= ETHERMTU) {
+                       /*
+                        * Not an Ethernet type; what type is it?
+                        */
+                       switch (ether_type) {
+
+                       case LINUX_SLL_P_802_3:
+                               /*
+                                * Ethernet_802.3 IPX frame.
+                                */
+                               (void)printf("802.3");
+                               break;
+
+                       case LINUX_SLL_P_802_2:
+                               /*
+                                * 802.2.
+                                */
+                               (void)printf("802.3");
+                               break;
+
+                       default:
+                               /*
+                                * What is it?
+                                */
+                               (void)printf("ethertype Unknown (0x%04x)",
+                                   ether_type);
+                               break;
+                       }
+               } else {
+                       (void)printf("ethertype %s (0x%04x)",
+                           tok2str(ethertype_values, "Unknown", ether_type),
+                           ether_type);
+               }
+               (void)printf(", length %u: ", length);
+       }
 }
 
 /*