Support for draft-rosen-vpn-ospf-bgp-mpls and for additional BGP

extended communities, from Aamer Akhter.

svn path=/trunk/; revision=3667
This commit is contained in:
Guy Harris 2001-07-08 22:59:51 +00:00
parent 60e5d8235d
commit 2c8be34f57
5 changed files with 92 additions and 24 deletions

View File

@ -716,6 +716,11 @@ Jeff Morriss <jeff.morriss@ulticom.com> {
Support for ANSI flavor of MTP3
}
Aamer Akhter <aakhter@cisco.com> {
Support for draft-rosen-vpn-ospf-bgp-mpls
Support for additional BGP extended communities
}
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to
give his permission to use his version of snprintf.c.

View File

@ -1128,6 +1128,7 @@ B<http://www.ethereal.com>.
Laurent Rabret <laurent.rabret@rd.francetelecom.fr>
nuf si <gnippiks@yahoo.com>
Jeff Morriss <jeff.morriss@ulticom.com>
Aamer Akhter <aakhter@cisco.com>
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to give his
permission to use his version of snprintf.c.

View File

@ -2,7 +2,7 @@
* Routines for BGP packet dissection.
* Copyright 1999, Jun-ichiro itojun Hagino <itojun@itojun.org>
*
* $Id: packet-bgp.c,v 1.43 2001/07/03 02:49:38 guy Exp $
* $Id: packet-bgp.c,v 1.44 2001/07/08 22:59:50 guy Exp $
*
* Supports:
* RFC1771 A Border Gateway Protocol 4 (BGP-4)
@ -164,9 +164,26 @@ static const value_string bgpext_com_type[] = {
{ BGP_EXT_COM_RT_1, "Route Target" },
{ BGP_EXT_COM_RO_0, "Route Origin" },
{ BGP_EXT_COM_RO_1, "Route Origin" },
{ BGP_EXT_COM_LINKBAND, "Link Bandwidth" },
{ BGP_EXT_COM_VPN_ORIGIN, "OSPF Domain" },
{ BGP_EXT_COM_OSPF_RTYPE, "OSPF Route Type" },
{ BGP_EXT_COM_OSPF_RID, "OSPF Router ID" },
{ 0, NULL },
};
static const value_string bgpext_ospf_rtype[] = {
{ BGP_OSPF_RTYPE_RTR, "Router" },
{ BGP_OSPF_RTYPE_NET, "Network" },
{ BGP_OSPF_RTYPE_SUM, "Summary" },
{ BGP_OSPF_RTYPE_EXT, "External" },
{ BGP_OSPF_RTYPE_NSSA,"NSSA External" },
{ BGP_OSPF_RTYPE_SHAM,"MPLS-VPN Sham" },
{ 0, NULL },
};
static const value_string bgpext_osptf_rtype_metric[] = {
};
/* MUST be resized if a longer named extended community is added */
#define MAX_SIZE_OF_EXT_COM_NAMES 20
@ -197,6 +214,7 @@ static const value_string bgpattr_nlri_safi[] = {
{ SAFNUM_UNICAST, "Unicast" },
{ SAFNUM_MULCAST, "Multicast" },
{ SAFNUM_UNIMULC, "Unicast+Multicast" },
{ SAFNUM_MPLS_LABEL, "MPLS Labeled Prefix"},
{ SAFNUM_LBVPNIP, "Labeled VPN-IPv4" }, /* draft-rosen-rfc2547bis-03 */
{ 0, NULL },
};
@ -1431,27 +1449,47 @@ dissect_bgp_update(tvbuff_t *tvb, int offset, proto_tree *tree)
subtree3 = proto_item_add_subtree(ti,ett_bgp_extended_communities) ;
while (q < end) {
ext_com_str[0] = '\0' ;
ext_com = tvb_get_ntohs(tvb,q) ;
snprintf(junk_buf, sizeof(junk_buf), "%s", val_to_str(ext_com,bgpext_com_type,"Unknown"));
strncat(ext_com_str,junk_buf,sizeof(junk_buf));
switch (ext_com) {
case BGP_EXT_COM_RT_0:
case BGP_EXT_COM_RO_0:
snprintf(junk_buf, sizeof(junk_buf), ": %u%s%d",tvb_get_ntohs(tvb,q+2),":",tvb_get_ntohl(tvb,q+4));
break ;
case BGP_EXT_COM_RT_1:
case BGP_EXT_COM_RO_1:
tvb_memcpy(tvb,ipaddr,q+2,4);
snprintf(junk_buf, sizeof(junk_buf), ": %s%s%u",ip_to_str(ipaddr),":",tvb_get_ntohs(tvb,q+6));
break ;
default:
snprintf(junk_buf, sizeof(junk_buf), " ");
break ;
}
strncat(ext_com_str,junk_buf,sizeof(junk_buf));
proto_tree_add_text(subtree3,tvb,q,8, "%s",ext_com_str);
q = q + 8 ;
ext_com_str[0] = '\0' ;
ext_com = tvb_get_ntohs(tvb,q) ;
snprintf(junk_buf, sizeof(junk_buf), "%s", val_to_str(ext_com,bgpext_com_type,"Unknown"));
strncat(ext_com_str,junk_buf,sizeof(junk_buf));
switch (ext_com) {
case BGP_EXT_COM_RT_0:
case BGP_EXT_COM_RO_0:
snprintf(junk_buf, sizeof(junk_buf), ": %u%s%d",tvb_get_ntohs(tvb,q+2),":",tvb_get_ntohl(tvb,q+4));
break ;
case BGP_EXT_COM_RT_1:
case BGP_EXT_COM_RO_1:
tvb_memcpy(tvb,ipaddr,q+2,4);
snprintf(junk_buf, sizeof(junk_buf), ": %s%s%u",ip_to_str(ipaddr),":",tvb_get_ntohs(tvb,q+6));
break;
case BGP_EXT_COM_VPN_ORIGIN:
case BGP_EXT_COM_OSPF_RID:
tvb_memcpy(tvb,ipaddr,q+2,4);
snprintf(junk_buf, sizeof(junk_buf), ": %s",ip_to_str(ipaddr));
break;
case BGP_EXT_COM_OSPF_RTYPE:
tvb_memcpy(tvb,ipaddr,q+2,4);
snprintf(junk_buf, sizeof(junk_buf), ": Area:%s %s",ip_to_str(ipaddr),val_to_str(tvb_get_guint8(tvb,q+6),bgpext_ospf_rtype,"Unknown"));
/* print OSPF Metric type if selected */
/* always print E2 even if not external route -- receiving router should ignore */
if ( (tvb_get_guint8(tvb,q+7)) & BGP_OSPF_RTYPE_METRIC_TYPE ) {
strcat(junk_buf," E2");
} else if (tvb_get_guint8(tvb,q+6)==(BGP_OSPF_RTYPE_EXT ||BGP_OSPF_RTYPE_NSSA ) ) {
strcat(junk_buf, " E1");
}
break;
case BGP_EXT_COM_LINKBAND:
tvb_memcpy(tvb,ipaddr,q+2,4); /* need to check on IEEE format on all platforms */
snprintf(junk_buf, sizeof(junk_buf), ": %f bytes per second",(double)*ipaddr);
break;
default:
snprintf(junk_buf, sizeof(junk_buf), " ");
break ;
}
strncat(ext_com_str,junk_buf,sizeof(junk_buf));
proto_tree_add_text(subtree3,tvb,q,8, "%s",ext_com_str);
q = q + 8 ;
}
free(ext_com_str) ;
}

View File

@ -1,7 +1,7 @@
/* packet-bgp.c
* Definitions for BGP packet disassembly structures and routine
*
* $Id: packet-bgp.h,v 1.13 2001/06/10 02:08:09 guy Exp $
* $Id: packet-bgp.h,v 1.14 2001/07/08 22:59:50 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -138,10 +138,27 @@ struct bgp_attr {
#define BGPTYPE_EXTENDED_COMMUNITY 16 /* Draft Ramachandra */
/* Extended community type */
/* draft-ramachandra-bgp-ext-communities */
#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) */
#define BGP_EXT_COM_RO_0 0x0003 /* Route Origin,Format AS(2bytes):AN(4bytes) */
#define BGP_EXT_COM_RO_1 0x0103 /* Route Origin,Format IP address:AN(2bytes) */
#define BGP_EXT_COM_LINKBAND 0x4004 /* Link Bandwidth,Format AS(2B):Bandwidth(4B) */
/* rfc2547 bgp-mpls-vpns */
#define BGP_EXT_COM_VPN_ORIGIN 0x0005 /* OSPF Domin ID / VPN of Origin */
/* draft-rosen-vpns-ospf-bgp-mpls */
#define BGP_EXT_COM_OSPF_RTYPE 0X8000 /* OSPF Route Type,Format Area(4B):RouteType(1B):Options(1B) */
#define BGP_EXT_COM_OSPF_RID 0x8001 /* OSPF Router ID,Format RouterID(4B):Unused(2B) */
/* OSPF codes for BGP_EXT_COM_OSPF_RTYPE draft-rosen-vpns-ospf-bgp-mpls */
#define BGP_OSPF_RTYPE_RTR 1 /* OSPF Router LSA */
#define BGP_OSPF_RTYPE_NET 2 /* OSPF Network LSA */
#define BGP_OSPF_RTYPE_SUM 3 /* OSPF Summary LSA */
#define BGP_OSPF_RTYPE_EXT 5 /* OSPF External LSA, note that ASBR doesn't apply to MPLS-VPN */
#define BGP_OSPF_RTYPE_NSSA 7 /* OSPF NSSA External*/
#define BGP_OSPF_RTYPE_SHAM 129 /* OSPF-MPLS-VPN Sham link */
#define BGP_OSPF_RTYPE_METRIC_TYPE 0x1 /* LSB of RTYPE Options Field */
/* Extended community & Route dinstinguisher formats */
#define FORMAT_AS2_LOC 0x00 /* Format AS(2bytes):AN(4bytes) */
@ -169,6 +186,7 @@ struct bgp_attr {
#define SAFNUM_UNICAST 1
#define SAFNUM_MULCAST 2
#define SAFNUM_UNIMULC 3
#define SAFNUM_MPLS_LABEL 4 /* rfc3107 */
#define SAFNUM_LBVPNIP 128 /* Draft-rosen-rfc2547bis-03 */
#ifndef offsetof

View File

@ -2,7 +2,7 @@
* Routines for OSPF packet disassembly
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
* $Id: packet-ospf.c,v 1.41 2001/07/03 04:56:45 guy Exp $
* $Id: packet-ospf.c,v 1.42 2001/07/08 22:59:50 guy Exp $
*
* At this time, this module is able to analyze OSPF
* packets as specified in RFC2328. MOSPF (RFC1584) and other
@ -85,6 +85,7 @@ static const value_string auth_vals[] = {
#define OSPF_OPTIONS_EA 0x10
#define OSPF_OPTIONS_DC 0x20
#define OSPF_OPTIONS_O 0x40
#define OSPF_OPTIONS_DN 0x01
#define OSPF_DBD_FLAG_MS 1
#define OSPF_DBD_FLAG_M 2
@ -1032,6 +1033,11 @@ dissect_ospf_options(tvbuff_t *tvb, int offset, proto_tree *tree)
strcat(options_string, "/");
strcat(options_string, "O");
}
if (options & OSPF_OPTIONS_DN) {
if (options_string[0] != '\0')
strcat(options_string, "/");
strcat(options_string, "DN");
}
proto_tree_add_text(tree, tvb, offset, 1, "Options: 0x%x (%s)",
options, options_string);