]> The Tcpdump Group git mirrors - tcpdump/commitdiff
move AF specific stuff to dedicated files
authorhannes <hannes>
Tue, 21 Feb 2006 10:27:40 +0000 (10:27 +0000)
committerhannes <hannes>
Tue, 21 Feb 2006 10:27:40 +0000 (10:27 +0000)
FILES
Makefile.in
print-bgp.c
print-isoclns.c
print-ldp.c
print-rip.c
win32/prj/GNUmakefile
win32/prj/WinDump.dsp

diff --git a/FILES b/FILES
index b57291ca52649ad7ba350ba9ed529a5d24b0d8fa..35fd3b47d981e72d5d5e53086e003e2e5cc04db1 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 b605ed6a7a4828f0e112a2982afb87dca48bc256..1b1fb6cc7b556db34b73a3126913cf071c79063e 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.298 2006-02-10 04:52:25 hannes Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.299 2006-02-21 10:27:40 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 checksum.c cpack.c gmpls.c oui.c gmt2local.c ipproto.c \
+CSRC = addrtoname.c af.c checksum.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 \
index 5eab496916e79ea059f74a95ab296129fb4ccdfd..4d5c1d372153bd91f8f02bfe77937b20a783fef2 100644 (file)
@@ -36,7 +36,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.100 2006-02-02 12:36:09 hannes Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.101 2006-02-21 10:27:40 hannes Exp $";
 #endif
 
 #include <tcpdump-stdinc.h>
@@ -49,6 +49,7 @@ static const char rcsid[] _U_ =
 #include "addrtoname.h"
 #include "extract.h"
 #include "bgp.h"
+#include "af.h"
 #include "l2vpn.h"
 
 struct bgp {
@@ -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 4b9106b236f16b4f59bcac8c4389a387e27606d5..2b81a3889db4e9d4c6c8f8ac13a9737cd572dd86 100644 (file)
@@ -26,7 +26,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.154 2005-11-12 22:22:59 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-isoclns.c,v 1.155 2006-02-21 10:27:40 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -47,9 +47,6 @@ static const char rcsid[] _U_ =
 #include "gmpls.h"
 #include "oui.h"
 
-#define IPV4            1       /* AFI value */
-#define IPV6            2       /* AFI value */
-
 /*
  * IS-IS is defined in ISO 10589.  Look there for protocol definitions.
  */
@@ -1629,7 +1626,7 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi
     processed=4;
     tptr+=4;
     
-    if (afi == IPV4) {
+    if (afi == AF_INET) {
         if (!TTEST2(*tptr, 1)) /* fetch status byte */
             return (0);
         status_byte=*(tptr++);
@@ -1642,7 +1639,7 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi
         }
         processed++;
 #ifdef INET6
-    } else if (afi == IPV6) {
+    } else if (afi == AF_INET6) {
         if (!TTEST2(*tptr, 1)) /* fetch status & prefix_len byte */
             return (0);
         status_byte=*(tptr++);
@@ -1667,13 +1664,13 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi
     tptr+=byte_length;
     processed+=byte_length;
 
-    if (afi == IPV4)
+    if (afi == AF_INET)
         printf("%sIPv4 prefix: %15s/%u",
                ident,
                ipaddr_string(prefix),
                bit_length);
 #ifdef INET6
-    if (afi == IPV6)
+    if (afi == AF_INET6)
         printf("%sIPv6 prefix: %s/%u",
                ident,
                ip6addr_string(prefix),
@@ -1684,17 +1681,17 @@ isis_print_extd_ip_reach (const u_int8_t *tptr, const char *ident, u_int16_t afi
            ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
            metric);
 
-    if (afi == IPV4 && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
+    if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
         printf(", sub-TLVs present");
 #ifdef INET6
-    if (afi == IPV6)
+    if (afi == AF_INET6)
         printf(", %s%s",
                ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal",
                ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : "");
 #endif
     
-    if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)  && afi == IPV4) ||
-        (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) && afi == IPV6)) {
+    if ((ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte)  && afi == AF_INET) ||
+        (ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) && afi == AF_INET6)) {
         /* assume that one prefix can hold more
            than one subTLV - therefore the first byte must reflect
            the aggregate bytecount of the subTLVs for this prefix
@@ -2238,7 +2235,7 @@ static int isis_print (const u_int8_t *p, u_int length)
 
        case ISIS_TLV_EXTD_IP_REACH:
            while (tmp>0) {
-                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", IPV4);
+                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", AF_INET);
                 if (ext_ip_len == 0) /* did something go wrong ? */
                     goto trunctlv;
                 tptr+=ext_ip_len;
@@ -2254,7 +2251,7 @@ static int isis_print (const u_int8_t *p, u_int length)
                 tptr+=mt_len;
                 tmp-=mt_len;
 
-                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", IPV4);
+                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", AF_INET);
                 if (ext_ip_len == 0) /* did something go wrong ? */
                     goto trunctlv;
                 tptr+=ext_ip_len;
@@ -2265,7 +2262,7 @@ static int isis_print (const u_int8_t *p, u_int length)
 #ifdef INET6
        case ISIS_TLV_IP6_REACH:
            while (tmp>0) {
-                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", IPV6);
+                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", AF_INET6);
                 if (ext_ip_len == 0) /* did something go wrong ? */
                     goto trunctlv;
                 tptr+=ext_ip_len;
@@ -2281,7 +2278,7 @@ static int isis_print (const u_int8_t *p, u_int length)
                 tptr+=mt_len;
                 tmp-=mt_len;
 
-                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", IPV6);
+                ext_ip_len = isis_print_extd_ip_reach(tptr, "\n\t      ", AF_INET6);
                 if (ext_ip_len == 0) /* did something go wrong ? */
                     goto trunctlv;
                 tptr+=ext_ip_len;
index f499133a06949132c886f9943b6e7a10c1061f0f..f36f2d00fd47f2913551ede49a90586ef48beba7 100644 (file)
@@ -16,7 +16,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.17 2006-02-03 08:32:39 hannes Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.18 2006-02-21 10:27:40 hannes Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -35,6 +35,7 @@ static const char rcsid[] _U_ =
 #include "addrtoname.h"
 
 #include "l2vpn.h"
+#include "af.h"
 
 /*
  * ldp common header
@@ -130,6 +131,7 @@ static const struct tok ldp_msg_values[] = {
 
 #define        LDP_TLV_FEC                  0x0100
 #define        LDP_TLV_ADDRESS_LIST         0x0101
+#define LDP_TLV_ADDRESS_LIST_AFNUM_LEN 2
 #define        LDP_TLV_HOP_COUNT            0x0103
 #define        LDP_TLV_PATH_VECTOR          0x0104
 #define        LDP_TLV_GENERIC_LABEL        0x0200
@@ -214,12 +216,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 
-
 #define FALSE 0
 #define TRUE  1
 
@@ -298,27 +294,31 @@ ldp_tlv_print(register const u_char *tptr) {
 
     case LDP_TLV_ADDRESS_LIST:
        af = EXTRACT_16BITS(tptr);
-       tptr+=AFNUM_LEN;
-        tlv_tlen -= AFNUM_LEN;
-       printf("\n\t      Address Family: ");
-       if (af == AFNUM_INET) {
-           printf("IPv4, addresses:");
+       tptr+=LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
+        tlv_tlen -= LDP_TLV_ADDRESS_LIST_AFNUM_LEN;
+       printf("\n\t      Address Family: %s, addresses",
+               tok2str(af_values, "Unknown (%u)", af));
+        switch (af) {
+        case AFNUM_INET:
            while(tlv_tlen >= sizeof(struct in_addr)) {
                printf(" %s",ipaddr_string(tptr));
                tlv_tlen-=sizeof(struct in_addr);
                tptr+=sizeof(struct in_addr);                
            }
-       }
+            break;
 #ifdef INET6
-       else if (af == AFNUM_INET6) {
-           printf("IPv6, addresses:");
+        case AFNUM_INET6:
            while(tlv_tlen >= sizeof(struct in6_addr)) {
                printf(" %s",ip6addr_string(tptr));
                tlv_tlen-=sizeof(struct in6_addr);
                tptr+=sizeof(struct in6_addr);                
            }
-       }
+            break;
 #endif
+        default:
+            /* unknown AF */
+            break;
+        }
        break;
 
     case LDP_TLV_COMMON_SESSION:
index 3369885aef7a67dca0655e4c5b7ab8b84a8be5c7..c66c86dbb51544676fa53f288c07a00fe5978ad2 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.57 2003-11-16 09:36:34 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.58 2006-02-21 10:27:40 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -37,6 +37,8 @@ static const char rcsid[] _U_ =
 #include "addrtoname.h"
 #include "extract.h"                   /* must come after interface.h */
 
+#include "af.h"
+
 struct rip {
        u_int8_t rip_cmd;               /* request/response */
        u_int8_t rip_vers;              /* protocol version # */
@@ -101,7 +103,7 @@ 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: %u:", family);
+               printf("\n\t AFI %s, ", tok2str(af_values, "Unknown (%u)", family));
                 print_unknown_data((u_int8_t *)&ni->rip_family,"\n\t  ",RIP_ROUTELEN);
                return;
        }
@@ -140,11 +142,12 @@ rip_entry_print_v2(register const struct rip_netinfo *ni)
                         print_unknown_data((u_int8_t *)&ni->rip_dest,"\n\t  ",RIP_AUTHLEN);
                }
        } else if (family != AF_INET) {
-               printf("\n\t  AFI: %u", family);
+               printf("\n\t  AFI %s", tok2str(af_values, "Unknown (%u)", family));
                 print_unknown_data((u_int8_t *)&ni->rip_tag,"\n\t  ",RIP_ROUTELEN-2);
                return;
        } else { /* AF_INET */
-               printf("\n\t  AFI: IPv4: %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
+               printf("\n\t  AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
+                       tok2str(af_values, "Unknown (%u)", family),
                        ipaddr_string(&ni->rip_dest),
                       mask2plen(EXTRACT_32BITS(&ni->rip_dest_mask)),
                        EXTRACT_16BITS(&ni->rip_tag),
index dbbd32ebe964d2c0e1f9ddbc247ab141353d4e84..95ecdca3aea88ebe41e9ceb9f0c35444fc8b2daf 100644 (file)
@@ -29,6 +29,7 @@ LDFLAGS =
 LIBS = -L ${PCAP_DIR}/WPCAP/LIB -lwpcap -lws2_32
 OBJS = \
        ../../addrtoname.o \
+       ../../af.o \
        ../../checksum.o \
        ../../gmpls.o \
        ../../gmt2local.o \
index 9b7a75b09e30ab20ce818ce587fe0f1a1cb37a97..8c725eb7a22662051c1a7b788cea5451a4d7777c 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