]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-bgp.c
Update from current NetBSD version of ieee80211_radiotap.h.
[tcpdump] / print-bgp.c
index 04226807dc52fe3a2804c018e866f0020f59e0dc..e4c08f27a5a9d7d43c6e515bc9c175c33ea97a1d 100644 (file)
@@ -36,7 +36,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.91.2.5 2005-05-18 20:03:19 hannes Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-bgp.c,v 1.91.2.9 2006-02-02 12:36:46 hannes Exp $";
 #endif
 
 #include <tcpdump-stdinc.h>
@@ -355,6 +355,7 @@ static struct tok bgp_safi_values[] = {
 #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 */
 
@@ -376,6 +377,7 @@ static struct tok bgp_afi_values[] = {
     { AFNUM_BANYAN,           "Banyan Vines"},
     { AFNUM_E164NSAP,         "E.164 with NSAP subaddress"},
     { AFNUM_L2VPN,            "Layer-2 VPN"},
+    { AFNUM_VPLS,             "VPLS"},
     { 0, NULL},
 };
 
@@ -403,6 +405,14 @@ static struct tok bgp_afi_values[] = {
 
 #define BGP_EXT_COM_L2INFO      0x800a  /* draft-kompella-ppvpn-l2vpn */
 
+/* http://www.cisco.com/en/US/tech/tk436/tk428/technologies_tech_note09186a00801eb09a.shtml  */
+#define BGP_EXT_COM_EIGRP_GEN   0x8800
+#define BGP_EXT_COM_EIGRP_METRIC_AS_DELAY  0x8801
+#define BGP_EXT_COM_EIGRP_METRIC_REL_NH_BW 0x8802
+#define BGP_EXT_COM_EIGRP_METRIC_LOAD_MTU  0x8803
+#define BGP_EXT_COM_EIGRP_EXT_REMAS_REMID  0x8804
+#define BGP_EXT_COM_EIGRP_EXT_REMPROTO_REMMETRIC 0x8805
+
 static struct tok bgp_extd_comm_flag_values[] = {
     { 0x8000,                  "vendor-specific"},
     { 0x4000,                  "non-transitive"},
@@ -427,6 +437,12 @@ static struct tok bgp_extd_comm_subtype_values[] = {
     { BGP_EXT_COM_OSPF_RID,    "ospf-router-id"},
     { BGP_EXT_COM_OSPF_RID2,   "ospf-router-id"},
     { BGP_EXT_COM_L2INFO,      "layer2-info"}, 
+    { BGP_EXT_COM_EIGRP_GEN , "eigrp-general-route (flag, tag)" },
+    { BGP_EXT_COM_EIGRP_METRIC_AS_DELAY , "eigrp-route-metric (AS, delay)" },
+    { BGP_EXT_COM_EIGRP_METRIC_REL_NH_BW , "eigrp-route-metric (reliability, nexthop, bandwidth)" },
+    { BGP_EXT_COM_EIGRP_METRIC_LOAD_MTU , "eigrp-route-metric (load, MTU)" },
+    { BGP_EXT_COM_EIGRP_EXT_REMAS_REMID , "eigrp-external-route (remote-AS, remote-ID)" },
+    { BGP_EXT_COM_EIGRP_EXT_REMPROTO_REMMETRIC , "eigrp-external-route (remote-proto, remote-metric)" },
     { 0, NULL},
 };
 
@@ -491,6 +507,9 @@ decode_labeled_prefix4(const u_char *pptr, char *buf, u_int buflen)
            stacked labels in a a single BGP message
         */
 
+       if (24 > plen)
+               return -1;
+
         plen-=24; /* adjust prefixlen - labellength */
 
        if (32 < plen)
@@ -565,9 +584,15 @@ decode_rt_routing_info(const u_char *pptr, char *buf, u_int buflen)
        TCHECK(pptr[0]);
        plen = pptr[0];   /* get prefix length */
 
+       if (0 == plen)
+               return 1; /* default route target */
+
+       if (32 > plen)
+               return -1;
+
         plen-=32; /* adjust prefix length */
 
-       if (0 < plen)
+       if (64 < plen)
                return -1;
 
        memset(&route_target, 0, sizeof(route_target));
@@ -596,6 +621,9 @@ decode_labeled_vpn_prefix4(const u_char *pptr, char *buf, u_int buflen)
        TCHECK(pptr[0]);
        plen = pptr[0];   /* get prefix length */
 
+       if ((24+64) > plen)
+               return -1;
+
         plen-=(24+64); /* adjust prefixlen - labellength - RD len*/
 
        if (32 < plen)
@@ -710,6 +738,10 @@ decode_labeled_prefix6(const u_char *pptr, char *buf, u_int buflen)
 
        TCHECK(pptr[0]);
        plen = pptr[0]; /* get prefix length */
+
+       if (24 > plen)
+               return -1;
+
         plen-=24; /* adjust prefixlen - labellength */
 
        if (128 < plen)
@@ -744,6 +776,9 @@ decode_labeled_vpn_prefix6(const u_char *pptr, char *buf, u_int buflen)
        TCHECK(pptr[0]);
        plen = pptr[0];   /* get prefix length */
 
+       if ((24+64) > plen)
+               return -1;
+
         plen-=(24+64); /* adjust prefixlen - labellength - RD len*/
 
        if (128 < plen)
@@ -791,7 +826,7 @@ decode_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
                        ((0xff00 >> (plen % 8)) & 0xff);
        }
        snprintf(buf, buflen, "%s/%d",
-                 isonsap_string(addr,(plen + 7) / 8 - 1),
+                 isonsap_string(addr,(plen + 7) / 8),
                  plen);
 
        return 1 + (plen + 7) / 8;
@@ -809,6 +844,9 @@ decode_labeled_vpn_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
        TCHECK(pptr[0]);
        plen = pptr[0];   /* get prefix length */
 
+       if ((24+64) > plen)
+               return -1;
+
         plen-=(24+64); /* adjust prefixlen - labellength - RD len*/
 
        if (152 < plen)
@@ -824,7 +862,7 @@ decode_labeled_vpn_clnp_prefix(const u_char *pptr, char *buf, u_int buflen)
         /* the label may get offsetted by 4 bits so lets shift it right */
        snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
                  bgp_vpn_rd_print(pptr+4),
-                 isonsap_string(addr,(plen + 7) / 8 - 1),
+                 isonsap_string(addr,(plen + 7) / 8),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -840,7 +878,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
 {
        int i;
        u_int16_t af;
-       u_int8_t safi, snpa;
+       u_int8_t safi, snpa, nhlen;
         union { /* copy buffer for bandwidth values */
             float f; 
             u_int32_t i;
@@ -1018,6 +1056,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
                 case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
                 case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
                 case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
+                case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
                     break;
                 default:
                     TCHECK2(tptr[0], tlen);
@@ -1031,7 +1070,8 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
                 tptr +=3;
 
                TCHECK(tptr[0]);
-               tlen = tptr[0];
+               nhlen = tptr[0];
+                tlen = nhlen;
                 tptr++;
 
                if (tlen) {
@@ -1100,6 +1140,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
                             }
                             break;
 #endif
+                        case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
                         case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
                         case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
                         case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
@@ -1157,6 +1198,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
                         }
                     }
                }
+                printf(", nh-length: %u", nhlen);
                tptr += tlen;
 
                TCHECK(tptr[0]);
@@ -1258,6 +1300,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
                             printf("\n\t      %s", buf);
                         break;
 #endif
+                    case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):
@@ -1392,6 +1435,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *pptr, int len)
                             printf("\n\t      %s", buf);
                         break;
 #endif
+                    case (AFNUM_VPLS<<8 | SAFNUM_VPLS):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNICAST):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNMULTICAST):
                     case (AFNUM_L2VPN<<8 | SAFNUM_VPNUNIMULTICAST):