Ethereal-dev: [Ethereal-dev] additions for draft-rosen-vpns-ospf-bgp-mpls

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Aamer Akhter <aakhter@xxxxxxxxx>
Date: Sun, 8 Jul 2001 17:34:13 -0400
Hello,

Please find attached vpns-bgp-ospf.patch.

This decodes:
	draft-rosen-vpn-ospf-bgp-mpls (changes in packet-bgp and packet-ospf)
	additional BGP extended communities

Corrections are much appreciated.

As I find time, I'm plannig on  adding SAFI==4 (LABELD MPBGP NLRI), and making changes/additions to packet-bgp to provide display filter 
capabililty (currently the only one avaliable is BGP message type-- is this intentional?). 

thanks

---
Aamer Akhter / aa@xxxxxxxxx
NISTE - cisco Sysems
? my.patch
? makediffs
? cscope.out
? aakhter@localhost
Index: packet-bgp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-bgp.c,v
retrieving revision 1.43
diff -u -r1.43 packet-bgp.c
--- packet-bgp.c	2001/07/03 02:49:38	1.43
+++ packet-bgp.c	2001/07/08 21:20:48
@@ -164,9 +164,26 @@
     { 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 @@
     { 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 @@
                         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) ;
                 }
Index: packet-bgp.h
===================================================================
RCS file: /cvsroot/ethereal/packet-bgp.h,v
retrieving revision 1.13
diff -u -r1.13 packet-bgp.h
--- packet-bgp.h	2001/06/10 02:08:09	1.13
+++ packet-bgp.h	2001/07/08 21:20:48
@@ -138,11 +138,28 @@
 #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) */
 #define FORMAT_IP_LOC       0x01    /* Format IP address:AN(2bytes) */
@@ -169,6 +186,7 @@
 #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
Index: packet-ospf.c
===================================================================
RCS file: /cvsroot/ethereal/packet-ospf.c,v
retrieving revision 1.41
diff -u -r1.41 packet-ospf.c
--- packet-ospf.c	2001/07/03 04:56:45	1.41
+++ packet-ospf.c	2001/07/08 21:20:49
@@ -85,6 +85,7 @@
 #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
@@ -1031,6 +1032,11 @@
 	if (options_string[0] != '\0')
 	    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)",