]> The Tcpdump Group git mirrors - tcpdump/commitdiff
resolve CHDLC proto to name, remove tok2str() lookalive
authorhannes <hannes>
Fri, 4 Nov 2005 18:30:21 +0000 (18:30 +0000)
committerhannes <hannes>
Fri, 4 Nov 2005 18:30:21 +0000 (18:30 +0000)
print-chdlc.c

index 4743b951e81d0890cc82373ec175726057e53328..7354dc7203e456ed233494c282a3c2c1dcea963a 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.40 2005-08-23 10:24:58 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.41 2005-11-04 18:30:21 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -42,6 +42,13 @@ static const char rcsid[] _U_ =
 
 static void chdlc_slarp_print(const u_char *, u_int);
 
+const struct tok chdlc_cast_values[] = { 
+    { CHDLC_UNICAST, "unicast" },
+    { CHDLC_BCAST, "bcast" },
+    { 0, NULL}
+};
+
+
 /* Standard CHDLC printer */
 u_int
 chdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p)
@@ -63,18 +70,11 @@ chdlc_print(register const u_char *p, u_int length) {
 
        proto = EXTRACT_16BITS(&p[2]);
        if (eflag) {
-               switch (p[0]) {
-               case CHDLC_UNICAST:
-                       printf("unicast ");
-                       break;
-               case CHDLC_BCAST:
-                       printf("bcast ");
-                       break;
-               default:
-                       printf("0x%02x ", p[0]);
-                       break;
-               }
-               printf("%d %04x: ", length, proto);
+                printf("%s, ethertype %s (0x%04x), length %u: ",
+                       tok2str(chdlc_cast_values, "0x%02x", p[0]),
+                       tok2str(ethertype_values, "Unknown", proto),
+                       proto,
+                       length);
        }
 
        length -= CHDLC_HDRLEN;