move AF specific stuff into dedicated file
authorhannes <hannes>
Mon, 26 Feb 2007 13:31:33 +0000 (13:31 +0000)
committerhannes <hannes>
Mon, 26 Feb 2007 13:31:33 +0000 (13:31 +0000)
FILES
Makefile.in
af.c [new file with mode: 0644]
af.h [new file with mode: 0644]
print-bgp.c
print-ldp.c
print-null.c
win32/prj/GNUmakefile
win32/prj/WinDump.dsp

diff --git a/FILES b/FILES
index d6c110b21ef213a43765f2a01991350cf59dc1d0..8d0f527e015d92449a6e15762390d110280ca23e 100644 (file)
--- a/FILES
+++ b/FILES
@@ -11,6 +11,8 @@ acconfig.h
 aclocal.m4
 addrtoname.c
 addrtoname.h
+af.c
+af.h
 ah.h
 aodv.h
 appletalk.h
index f4bf1ad4119a9f76dc681c7c4fb76083e8fdc30d..0852abc6152212f6fce9dbe4828219730599ab4d 100644 (file)
@@ -17,7 +17,7 @@
 #  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 #
-# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.293.2.3 2005-09-20 06:05:36 guy Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.293.2.4 2007-02-26 13:31:33 hannes Exp $ (LBL)
 
 #
 # Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -65,7 +65,7 @@ INSTALL_DATA = @INSTALL_DATA@
        @rm -f $@
        $(CC) $(CFLAGS) -c $(srcdir)/$*.c
 
-CSRC = addrtoname.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
+CSRC = addrtoname.c af.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
         nlpid.c l2vpn.c machdep.c parsenfsfh.c \
        print-802_11.c print-ap1394.c print-ah.c print-arcnet.c \
        print-aodv.c print-arp.c print-ascii.c print-atalk.c print-atm.c \
diff --git a/af.c b/af.c
new file mode 100644 (file)
index 0000000..61d3e4c
--- /dev/null
+++ b/af.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 1998-2006 The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ *
+ * Original code by Hannes Gredler (hannes@juniper.net)
+ */
+
+#ifndef lint
+static const char rcsid[] _U_ =
+    "@(#) $Header: /tcpdump/master/tcpdump/af.c,v 1.3.2.1 2007-02-26 13:33:17 hannes Exp $ (LBL)";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <tcpdump-stdinc.h>
+#include "interface.h"
+#include "af.h"
+
+struct tok af_values[] = {
+    { 0,                      "Reserved"},
+    { AFNUM_INET,             "IPv4"},
+    { AFNUM_INET6,            "IPv6"},
+    { AFNUM_NSAP,             "NSAP"},
+    { AFNUM_HDLC,             "HDLC"},
+    { AFNUM_BBN1822,          "BBN 1822"},
+    { AFNUM_802,              "802"},
+    { AFNUM_E163,             "E.163"},
+    { AFNUM_E164,             "E.164"},
+    { AFNUM_F69,              "F.69"},
+    { AFNUM_X121,             "X.121"},
+    { AFNUM_IPX,              "Novell IPX"},
+    { AFNUM_ATALK,            "Appletalk"},
+    { AFNUM_DECNET,           "Decnet IV"},
+    { AFNUM_BANYAN,           "Banyan Vines"},
+    { AFNUM_E164NSAP,         "E.164 with NSAP subaddress"},
+    { AFNUM_L2VPN,            "Layer-2 VPN"},
+    { 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
new file mode 100644 (file)
index 0000000..e31c131
--- /dev/null
+++ b/af.h
@@ -0,0 +1,57 @@
+/* @(#) $Header: /tcpdump/master/tcpdump/af.h,v 1.3.2.1 2007-02-26 13:33:17 hannes Exp $ (LBL) */
+
+/*
+ * Copyright (c) 1998-2006 The TCPDUMP project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code
+ * distributions retain the above copyright notice and this paragraph
+ * in its entirety, and (2) distributions including binary code include
+ * the above copyright notice and this paragraph in its entirety in
+ * the documentation or other materials provided with the distribution.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
+ * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE.
+ *
+ * Original code by Hannes Gredler (hannes@juniper.net)
+ */
+
+extern struct tok af_values[];
+extern struct tok bsd_af_values[];
+
+/* RFC1700 address family numbers */
+#define AFNUM_INET     1
+#define AFNUM_INET6    2
+#define AFNUM_NSAP     3
+#define AFNUM_HDLC     4
+#define AFNUM_BBN1822  5
+#define AFNUM_802      6
+#define AFNUM_E163     7
+#define AFNUM_E164     8
+#define AFNUM_F69      9
+#define AFNUM_X121     10
+#define AFNUM_IPX      11
+#define AFNUM_ATALK    12
+#define AFNUM_DECNET   13
+#define AFNUM_BANYAN   14
+#define AFNUM_E164NSAP 15
+#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 439d8b60444866d285643c63bcd54cf017306e0d..bec2ca158fc4cc8e7515fa79519a94de4a44879c 100644 (file)
@@ -36,7 +36,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.91.2.10 2006-10-06 06:26:40 hannes Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.91.2.11 2007-02-26 13:31:33 hannes Exp $";
 #endif
 
 #include <tcpdump-stdinc.h>
@@ -50,6 +50,7 @@ static const char rcsid[] _U_ =
 #include "extract.h"
 #include "bgp.h"
 #include "l2vpn.h"
+#include "af.h"
 
 struct bgp {
        u_int8_t bgp_marker[16];
@@ -339,48 +340,6 @@ static struct tok bgp_safi_values[] = {
 #define BGP_COMMUNITY_NO_ADVERT                        0xffffff02
 #define BGP_COMMUNITY_NO_EXPORT_SUBCONFED      0xffffff03
 
-/* RFC1700 address family numbers */
-#define AFNUM_INET     1
-#define AFNUM_INET6    2
-#define AFNUM_NSAP     3
-#define AFNUM_HDLC     4
-#define AFNUM_BBN1822  5
-#define AFNUM_802      6
-#define AFNUM_E163     7
-#define AFNUM_E164     8
-#define AFNUM_F69      9
-#define AFNUM_X121     10
-#define AFNUM_IPX      11
-#define AFNUM_ATALK    12
-#define AFNUM_DECNET   13
-#define AFNUM_BANYAN   14
-#define AFNUM_E164NSAP 15
-#define AFNUM_VPLS      25
-/* draft-kompella-ppvpn-l2vpn */
-#define AFNUM_L2VPN     196 /* still to be approved by IANA */
-
-static struct tok bgp_afi_values[] = {
-    { 0,                      "Reserved"},
-    { AFNUM_INET,             "IPv4"},
-    { AFNUM_INET6,            "IPv6"},
-    { AFNUM_NSAP,             "NSAP"},
-    { AFNUM_HDLC,             "HDLC"},
-    { AFNUM_BBN1822,          "BBN 1822"},
-    { AFNUM_802,              "802"},
-    { AFNUM_E163,             "E.163"},
-    { AFNUM_E164,             "E.164"},
-    { AFNUM_F69,              "F.69"},
-    { AFNUM_X121,             "X.121"},
-    { AFNUM_IPX,              "Novell IPX"},
-    { AFNUM_ATALK,            "Appletalk"},
-    { AFNUM_DECNET,           "Decnet IV"},
-    { AFNUM_BANYAN,           "Banyan Vines"},
-    { AFNUM_E164NSAP,         "E.164 with NSAP subaddress"},
-    { AFNUM_L2VPN,            "Layer-2 VPN"},
-    { AFNUM_VPLS,             "VPLS"},
-    { 0, NULL},
-};
-
 /* Extended community type - draft-ietf-idr-bgp-ext-communities-05 */
 #define BGP_EXT_COM_RT_0        0x0002  /* Route Target,Format AS(2bytes):AN(4bytes) */
 #define BGP_EXT_COM_RT_1        0x0102  /* Route Target,Format IP address:AN(2bytes) */
@@ -1020,7 +979,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
                safi = tptr[2];
        
                 printf("\n\t    AFI: %s (%u), %sSAFI: %s (%u)",
-                       tok2strbuf(bgp_afi_values, "Unknown AFI", af,
+                       tok2strbuf(af_values, "Unknown AFI", af,
                                  tokbuf, sizeof(tokbuf)),
                        af,
                        (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
@@ -1356,7 +1315,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
                safi = tptr[2];
 
                 printf("\n\t    AFI: %s (%u), %sSAFI: %s (%u)",
-                       tok2strbuf(bgp_afi_values, "Unknown AFI", af,
+                       tok2strbuf(af_values, "Unknown AFI", af,
                                  tokbuf, sizeof(tokbuf)),
                        af,
                        (safi>128) ? "vendor specific " : "", /* 128 is meanwhile wellknown */
@@ -1685,7 +1644,7 @@ bgp_open_print(const u_char *dat, int length)
                     switch(cap_type) {
                     case BGP_CAPCODE_MP:
                         printf("\n\t\tAFI %s (%u), SAFI %s (%u)",
-                               tok2strbuf(bgp_afi_values, "Unknown",
+                               tok2strbuf(af_values, "Unknown",
                                          EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2),
                                          tokbuf, sizeof(tokbuf)),
                                EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+2),
@@ -1702,7 +1661,7 @@ bgp_open_print(const u_char *dat, int length)
                         cap_offset=4;
                         while(tcap_len>=4) {
                             printf("\n\t\t  AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
-                                   tok2strbuf(bgp_afi_values,"Unknown",
+                                   tok2strbuf(af_values,"Unknown",
                                              EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+cap_offset),
                                              tokbuf, sizeof(tokbuf)),
                                    EXTRACT_16BITS(opt+i+BGP_OPT_SIZE+cap_offset),
@@ -1916,7 +1875,7 @@ bgp_notification_print(const u_char *dat, int length)
                tptr = dat + BGP_NOTIFICATION_SIZE;
                TCHECK2(*tptr, 7);
                printf(", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
-                      tok2strbuf(bgp_afi_values, "Unknown",
+                      tok2strbuf(af_values, "Unknown",
                                  EXTRACT_16BITS(tptr), tokbuf, sizeof(tokbuf)),
                       EXTRACT_16BITS(tptr),
                       tok2strbuf(bgp_safi_values, "Unknown", *(tptr+2),
@@ -1950,7 +1909,7 @@ bgp_route_refresh_print(const u_char *pptr, int len) {
         bgp_route_refresh_header = (const struct bgp_route_refresh *)pptr;
 
         printf("\n\t  AFI %s (%u), SAFI %s (%u)",
-               tok2strbuf(bgp_afi_values,"Unknown",
+               tok2strbuf(af_values,"Unknown",
                          /* this stinks but the compiler pads the structure
                           * weird */
                          EXTRACT_16BITS(&bgp_route_refresh_header->afi),
index c05c75c53a3e18fd5b8abc68d75f8cdec3052685..7154325ddc0172e7b934789a50a4a7ab17b9b350 100644 (file)
@@ -16,7 +16,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.8.2.9 2006-06-23 02:07:27 hannes Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.8.2.10 2007-02-26 13:31:33 hannes Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -33,6 +33,7 @@ static const char rcsid[] _U_ =
 #include "decode_prefix.h"
 #include "extract.h"
 #include "addrtoname.h"
+#include "af.h"
 
 #include "l2vpn.h"
 
@@ -214,10 +215,6 @@ static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = {
     { 0, NULL}
 };
 
-/* RFC1700 address family numbers, same definition in print-bgp.c */
-/* FIXME: move all AF stuff into dedicated files */
-#define AFNUM_INET     1
-#define AFNUM_INET6    2
 #define AFNUM_LEN       2 
 
 int ldp_msg_print(register const u_char *);
index 0d1dcf5948487068e8f58729012905cd08353552..73b990a301ed0dc1fb58e13dbcddd6c8385f88fa 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.3 2005-07-07 01:24:38 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.53.2.4 2007-02-26 13:31:33 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -36,6 +36,7 @@ static const char rcsid[] _U_ =
 
 #include "interface.h"
 #include "addrtoname.h"
+#include "af.h"
 
 #include "ip.h"
 #ifdef INET6
@@ -54,34 +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.
@@ -145,27 +118,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 b80be6c67fea3a4febd2192eb09c36203f703b4b..5006407669e8def1e898438360453d0184f0adf4 100644 (file)
@@ -29,6 +29,7 @@ LDFLAGS =
 LIBS = -L ${PCAP_DIR}/WPCAP/LIB -lwpcap -lws2_32
 OBJS = \
        ../../addrtoname.o \
+       ../../af.o \
        ../../gmpls.o \
        ../../gmt2local.o \
        ../../missing/inet_aton.o \
index 2636b9cf2668d65d35c54f889b4dd10029ad2b46..357054fbe45a74a1da54499d51273af4b976e02a 100644 (file)
@@ -89,6 +89,10 @@ SOURCE=..\..\addrtoname.c
 # End Source File
 # Begin Source File
 
+SOURCE=..\..\af.c
+# End Source File
+# Begin Source File
+
 SOURCE=..\..\bpf_dump.c
 # End Source File
 # Begin Source File