]> The Tcpdump Group git mirrors - tcpdump/commitdiff
move the BSD AF defs into af.h and make the null and rip printer make use of it
authorhannes <hannes>
Thu, 23 Mar 2006 14:58:44 +0000 (14:58 +0000)
committerhannes <hannes>
Thu, 23 Mar 2006 14:58:44 +0000 (14:58 +0000)
af.c
af.h
print-null.c
print-rip.c

diff --git a/af.c b/af.c
index 06d675fe2ff0aeca123be3a375498d2556e4326b..e3c77bf3c4ceda58709cccdb91b90e605db1c549 100644 (file)
--- a/af.c
+++ b/af.c
@@ -17,7 +17,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/af.c,v 1.2 2006-02-27 07:25:27 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/af.c,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -49,3 +49,15 @@ struct tok af_values[] = {
     { AFNUM_VPLS,             "VPLS"},
     { 0, NULL},
 };
+
+struct tok bsd_af_values[] = {
+    { BSD_AFNUM_INET, "IPv4" },
+    { BSD_AFNUM_NS, "NS" },
+    { BSD_AFNUM_ISO, "ISO" },
+    { BSD_AFNUM_APPLETALK, "Appletalk" },
+    { BSD_AFNUM_IPX, "IPX" },
+    { BSD_AFNUM_INET6_BSD, "IPv6" },
+    { BSD_AFNUM_INET6_FREEBSD, "IPv6" },
+    { BSD_AFNUM_INET6_DARWIN, "IPv6" },
+    { 0, NULL}
+};
diff --git a/af.h b/af.h
index 876fe932bf9cb09fd99b41f2f8ec65bdd58c1499..c036cef9637d4df99b78c2d23764e068dc5299d0 100644 (file)
--- a/af.h
+++ b/af.h
@@ -1,4 +1,4 @@
-/* @(#) $Header: /tcpdump/master/tcpdump/af.h,v 1.2 2006-02-27 07:25:27 hannes Exp $ (LBL) */
+/* @(#) $Header: /tcpdump/master/tcpdump/af.h,v 1.3 2006-03-23 14:58:44 hannes Exp $ (LBL) */
 
 /*
  * Copyright (c) 1998-2006 The TCPDUMP project
@@ -18,6 +18,7 @@
  */
 
 extern struct tok af_values[];
+extern struct tok bsd_af_values[];
 
 /* RFC1700 address family numbers */
 #define AFNUM_INET     1
@@ -38,3 +39,19 @@ extern struct tok af_values[];
 #define AFNUM_VPLS      25
 /* draft-kompella-ppvpn-l2vpn */
 #define AFNUM_L2VPN     196 /* still to be approved by IANA */
+
+/*
+ * BSD AF_ values.
+ *
+ * Unfortunately, the BSDs don't all use the same value for AF_INET6,
+ * so, because we want to be able to read captures from all of the BSDs,
+ * we check for all of them.
+ */
+#define BSD_AFNUM_INET         2
+#define BSD_AFNUM_NS           6               /* XEROX NS protocols */
+#define BSD_AFNUM_ISO          7
+#define BSD_AFNUM_APPLETALK    16
+#define BSD_AFNUM_IPX          23
+#define BSD_AFNUM_INET6_BSD    24      /* OpenBSD (and probably NetBSD), BSD/OS */
+#define BSD_AFNUM_INET6_FREEBSD        28
+#define BSD_AFNUM_INET6_DARWIN 30
index 6de6d48908b2ac8635effbfc504e70bdd09be166..a69997da12e312e692dcdbb2f739403a32328921 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.56 2005-07-07 01:22:19 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.57 2006-03-23 14:58:44 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -41,6 +41,7 @@ static const char rcsid[] _U_ =
 #ifdef INET6
 #include "ip6.h"
 #endif
+#include "af.h"
 
 /*
  * The DLT_NULL packet header is 4 bytes long. It contains a host-byte-order
@@ -54,35 +55,6 @@ static const char rcsid[] _U_ =
  */
 #define        NULL_HDRLEN 4
 
-/*
- * BSD AF_ values.
- *
- * Unfortunately, the BSDs don't all use the same value for AF_INET6,
- * so, because we want to be able to read captures from all of the BSDs,
- * we check for all of them.
- */
-#define BSD_AF_INET            2
-#define BSD_AF_NS              6               /* XEROX NS protocols */
-#define BSD_AF_ISO             7
-#define BSD_AF_APPLETALK       16
-#define BSD_AF_IPX             23
-#define BSD_AF_INET6_BSD       24      /* OpenBSD (and probably NetBSD), BSD/OS */
-#define BSD_AF_INET6_FREEBSD   28
-#define BSD_AF_INET6_DARWIN    30
-
-const struct tok bsd_af_values[] = {
-        { BSD_AF_INET, "IPv4" },
-        { BSD_AF_NS, "NS" },
-        { BSD_AF_ISO, "ISO" },
-        { BSD_AF_APPLETALK, "Appletalk" },
-        { BSD_AF_IPX, "IPX" },
-        { BSD_AF_INET6_BSD, "IPv6" },
-        { BSD_AF_INET6_FREEBSD, "IPv6" },
-        { BSD_AF_INET6_DARWIN, "IPv6" },
-        { 0, NULL}
-};
-
-
 /*
  * Byte-swap a 32-bit number.
  * ("htonl()" or "ntohl()" won't work - we want to byte-swap even on
@@ -145,27 +117,27 @@ null_if_print(const struct pcap_pkthdr *h, const u_char *p)
 
        switch (family) {
 
-       case BSD_AF_INET:
+       case BSD_AFNUM_INET:
                ip_print(gndo, p, length);
                break;
 
 #ifdef INET6
-       case BSD_AF_INET6_BSD:
-       case BSD_AF_INET6_FREEBSD:
-       case BSD_AF_INET6_DARWIN:
+       case BSD_AFNUM_INET6_BSD:
+       case BSD_AFNUM_INET6_FREEBSD:
+       case BSD_AFNUM_INET6_DARWIN:
                ip6_print(p, length);
                break;
 #endif
 
-       case BSD_AF_ISO:
+       case BSD_AFNUM_ISO:
                isoclns_print(p, length, caplen);
                break;
 
-       case BSD_AF_APPLETALK:
+       case BSD_AFNUM_APPLETALK:
                atalk_print(p, length);
                break;
 
-       case BSD_AF_IPX:
+       case BSD_AFNUM_IPX:
                ipx_print(p, length);
                break;
 
index c66c86dbb51544676fa53f288c07a00fe5978ad2..27446a6823638075afc5213af43a3801afb03759 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.58 2006-02-21 10:27:40 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.59 2006-03-23 14:58:44 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -102,8 +102,8 @@ rip_entry_print_v1(register const struct rip_netinfo *ni)
 
        /* RFC 1058 */
        family = EXTRACT_16BITS(&ni->rip_family);
-       if (family != AF_INET) {
-               printf("\n\t AFI %s, ", tok2str(af_values, "Unknown (%u)", family));
+       if (family != BSD_AFNUM_INET) {
+               printf("\n\t AFI %s, ", tok2str(bsd_af_values, "Unknown (%u)", family));
                 print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t  ",RIP_ROUTELEN);
                return;
        }
@@ -113,7 +113,7 @@ rip_entry_print_v1(register const struct rip_netinfo *ni)
                /* MBZ fields not zero */
                 print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t  ",RIP_ROUTELEN);
                return;
-       } /* AF_INET */
+       } /* BSD_AFNUM_INET */
        printf("\n\t  %s, metric: %u",
                ipaddr_string(&ni->rip_dest),
               EXTRACT_32BITS(&ni->rip_metric));
@@ -141,13 +141,13 @@ rip_entry_print_v2(register const struct rip_netinfo *ni)
                               EXTRACT_16BITS(&ni->rip_tag));
                         print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t  ",RIP_AUTHLEN);
                }
-       } else if (family != AF_INET) {
-               printf("\n\t  AFI %s", tok2str(af_values, "Unknown (%u)", family));
+       } else if (family != BSD_AFNUM_INET) {
+               printf("\n\t  AFI %s", tok2str(bsd_af_values, "Unknown (%u)", family));
                 print_unknown_data((u_int8_t *)&ni->rip_tag,"\n\t  ",RIP_ROUTELEN-2);
                return;
-       } else { /* AF_INET */
+       } else { /* BSD_AFNUM_INET */
                printf("\n\t  AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
-                       tok2str(af_values, "Unknown (%u)", family),
+                       tok2str(bsd_af_values, "Unknown (%u)", family),
                        ipaddr_string(&ni->rip_dest),
                       mask2plen(EXTRACT_32BITS(&ni->rip_dest_mask)),
                        EXTRACT_16BITS(&ni->rip_tag),