Ethereal-dev: [Ethereal-dev] packet-cdp.c update

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

From: Paul Ionescu <paul@xxxxxxxx>
Date: Fri, 05 Jan 2001 17:48:54 +0200
Hello,

Here is a patch for the packet-cdp.c and a sample capture to see the
changes.
This patch add the support of IP-PREFIX field used in On Demand Routing.

Please commit if it is ok.
--- ethereal-2001-01-04/packet-cdp.c	Wed Jan  3 08:55:27 2001
+++ ethereal-my/packet-cdp.c	Fri Jan  5 12:49:16 2001
@@ -76,6 +76,7 @@
 #define TYPE_CAPABILITIES	0x0004
 #define TYPE_IOS_VERSION	0x0005
 #define TYPE_PLATFORM		0x0006
+#define TYPE_IP_PREFIX		0x0007
 
 static const value_string type_vals[] = {
 	{ TYPE_DEVICE_ID,    "Device ID" },
@@ -84,6 +85,7 @@
 	{ TYPE_CAPABILITIES, "Capabilities" },
 	{ TYPE_IOS_VERSION,  "Software version" },
 	{ TYPE_PLATFORM,     "Platform" },
+	{ TYPE_IP_PREFIX,    "IP Prefix (used for ODR)" },
 	{ 0,                 NULL },
 };
 	
@@ -251,7 +253,31 @@
 			    tvb_get_ptr(tvb, offset + 4, length - 4));
 		offset += length;
 		break;
+            case TYPE_IP_PREFIX:
+		tlvi = proto_tree_add_text(cdp_tree, tvb, offset,
+			    length, "IP Prefixes: %d",length/5);
 
+			    /* the actual number of prefixes is (length-4)/5
+			    but if the variable is not a "float" but "integer"
+			    then length/5=(length-4)/5  :)  */
+			    
+		tlv_tree = proto_item_add_subtree(tlvi, ett_cdp_tlv);
+                proto_tree_add_uint(tlv_tree, hf_cdp_tlvtype, tvb,
+                            offset + TLV_TYPE, 2, type);          
+                proto_tree_add_uint(tlv_tree, hf_cdp_tlvlength, tvb,
+                            offset + TLV_LENGTH, 2, length);
+                offset +=4;
+                length -=4;
+		while (length > 0)
+			{
+			proto_tree_add_text(tlv_tree,tvb,offset,5,
+			"IP Prefix = %s/%d",
+			ip_to_str(tvb_get_ptr(tvb, offset, 4)),
+			tvb_get_guint8(tvb,offset+4));
+			offset += 5;
+			length -= 5;
+			}                                                    		                
+		break;
 	    default:
 		tlvi = proto_tree_add_text(cdp_tree, tvb, offset,
 			    length, "Type: %s, length: %u",

Attachment: cdp3.cap
Description: Binary data