Ethereal-dev: [Ethereal-dev] BGP4 Cooperative Route Filtering Capability support

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

From: Motonori Shindo <mshindo@xxxxxxxxxxx>
Date: Sun, 04 Nov 2001 01:29:49 +0900 (JST)
Hi,

I have added a Cooporative Route Filtering Capability support based on
draft-ietf-idr-route-filter-04.txt.

I also fixed a bug in Route Refresh Message dissector.

A patch against current CVS repository attached.

Regards,

=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
 +----+----+     
 |.. .|    |     Motonori Shindo
 |_~__|    |     
 | .. |~~_~|     Sr. Systems Engineer
 | .  |    |     CoSine Communications Inc.
 +----+----+     
 C o S i n e     e-mail:  mshindo@xxxxxxxxxxxxx 
Communications
=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=





Index: packet-bgp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-bgp.c,v
retrieving revision 1.47
diff -u -r1.47 packet-bgp.c
--- packet-bgp.c	2001/09/13 22:06:54	1.47
+++ packet-bgp.c	2001/11/03 16:51:29
@@ -197,6 +197,21 @@
     { 0, NULL },
 };
 
+/* ORF Type, draft-ietf-idr-route-filter-04.txt */
+static const value_string orf_type_vals[] = {
+    { 2,	"Communities ORF-Type" },
+    { 3,	"Extended Communities ORF-Type" },
+    { 0,	NULL },
+};
+
+/* ORF Send/Receive, draft-ietf-idr-route-filter-04.txt */
+static const value_string orf_send_recv_vals[] = {
+    { 1,	"Receive" },
+    { 2,	"Send" },
+    { 3,	"Both" },
+    { 0,	NULL },
+};
+
 /* Maximal size of an IP address string */
 #define MAX_SIZE_OF_IP_ADDR_STRING      16
 
@@ -491,6 +506,9 @@
     proto_tree      *subtree1; /* subtree for an option */
     proto_tree      *subtree2; /* subtree for an option */
     proto_tree      *subtree3; /* subtree for an option */
+    guint8          orfnum;    /* number of ORFs */
+    guint8          orftype;        /* ORF Type */
+    guint8          orfsendrecv;    /* ORF Send/Receive */
 
     /* snarf OPEN message */
     tvb_memcpy(tvb, bgpo.bgpo_marker, offset, BGP_MIN_OPEN_MSG_SIZE);
@@ -637,6 +655,60 @@
 			}
 			p += clen;
 			break;
+		    case BGP_CAPABILITY_COOPERATIVE_ROUTE_FILTERING:
+			ti = proto_tree_add_text(subtree1, tvb, p - 2,
+                             2 + clen,
+                             "Cooperative route filtering capability (%u %s)",
+                             2 + clen, (clen == 1) ? "byte" : "bytes");
+			subtree2 = proto_item_add_subtree(ti, ett_bgp_option);
+			proto_tree_add_text(subtree2, tvb, p - 2,
+                             1, "Capability code: Cooperative route filtering (%d)",
+                             ctype);
+			proto_tree_add_text(subtree2, tvb, p - 1,
+			     1, "Capability length: %u %s", clen,
+			     (clen == 1) ? "byte" : "bytes");
+			ti = proto_tree_add_text(subtree2, tvb, p,
+                             clen, "Capability value");
+			subtree3 = proto_item_add_subtree(ti, ett_bgp_option);
+			/* AFI */
+			i = tvb_get_ntohs(tvb, p);
+			proto_tree_add_text(subtree3, tvb, p,
+			     2, "Address family identifier: %s (%u)",
+                             val_to_str(i, afn_vals, "Unknown"), i);
+			p += 2;
+			/* Reserved */
+			proto_tree_add_text(subtree3, tvb, p, 
+			     1, "Reserved: 1 byte");
+			p++;
+			/* SAFI */
+			i = tvb_get_guint8(tvb, p);
+			proto_tree_add_text(subtree3, tvb, p,
+			     1, "Subsequent address family identifier: %s (%u)",
+			     val_to_str(i, bgpattr_nlri_safi,
+			     i >= 128 ? "Vendor specific" : "Unknown"), i);
+			p++;
+			/* Number of ORFs */
+			orfnum = tvb_get_guint8(tvb, p);
+			proto_tree_add_text(subtree3, tvb, p,
+					    1, "Number of ORFs: %u", orfnum);
+			p++;
+			for (i=0; i<orfnum; i++) {
+			    /* ORF Type */
+			    orftype = tvb_get_guint8(tvb, p);
+			    proto_tree_add_text(subtree3, tvb, p,
+				1, "ORF Type: %s (%u)",
+				val_to_str(orftype, orf_type_vals,"Unknown"),
+				orftype);
+			    p++;
+			    /* Send/Receive */
+			    orfsendrecv = tvb_get_guint8(tvb, p);
+			    proto_tree_add_text(subtree3, tvb, p,
+				1, "Send/Receive: %s (%u)",
+				val_to_str(orfsendrecv, orf_send_recv_vals, 
+				"Uknown"), orfsendrecv);
+			    p++;
+			}
+			break;
 		    /* unknown capability */
 		    default:
 			ti = proto_tree_add_text(subtree, tvb, p - 2,
@@ -1558,12 +1630,12 @@
                         val_to_str(i, afn_vals, "Unknown"), i);
     offset += 2;
     /* Reserved */
-    proto_tree_add_text(tree, tvb, offset + BGP_HEADER_SIZE + 2, 1, 
+    proto_tree_add_text(tree, tvb, offset + BGP_HEADER_SIZE, 1, 
                         "Reserved: 1 byte");
     offset++;
     /* SAFI */
-    i = tvb_get_guint8(tvb, offset);
-    proto_tree_add_text(tree, tvb, offset + BGP_HEADER_SIZE + 3, 1, 
+    i = tvb_get_guint8(tvb, offset + BGP_HEADER_SIZE);
+    proto_tree_add_text(tree, tvb, offset + BGP_HEADER_SIZE, 1, 
                         "Subsequent address family identifier: %s (%u)",
                         val_to_str(i, bgpattr_nlri_safi,
                         i >= 128 ? "Vendor specific" : "Unknown"),
Index: packet-bgp.h
===================================================================
RCS file: /cvsroot/ethereal/packet-bgp.h,v
retrieving revision 1.15
diff -u -r1.15 packet-bgp.h
--- packet-bgp.h	2001/07/21 10:27:12	1.15
+++ packet-bgp.h	2001/11/03 16:51:30
@@ -109,6 +109,7 @@
 #define BGP_CAPABILITY_RESERVED		0   /* RFC2434 */
 #define BGP_CAPABILITY_MULTIPROTOCOL	1   /* RFC2858 */
 #define BGP_CAPABILITY_ROUTE_REFRESH	2   /* RFC2918 */
+#define BGP_CAPABILITY_COOPERATIVE_ROUTE_FILTERING	3	/* draft-ietf-idr-route-filter-04.txt */
 #define BGP_CAPABILITY_ROUTE_REFRESH_CISCO      0x80   /* Cisco */