Ethereal-dev: [Ethereal-dev] [PATCH] packet-cdp.c patch

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: Sun, 14 Mar 2004 17:01:16 +0200
Hi list,

Here is a patch for the cdp dissector for ODR prefix section.
This adds ODR HUB default gateway announcements.
Attached is the patch and a sample capture with 2 packets: one is normal
odr prefix announcement and the other is hub default gw announcement.
Please review and apply.

Best regards,
Paul Ionescu


--- packet-cdp.c.orig	2004-03-14 15:26:39.000000000 +0200
+++ packet-cdp.c	2004-03-14 16:48:27.000000000 +0200
@@ -108,7 +108,7 @@
 	{ TYPE_CAPABILITIES, 	"Capabilities" },
 	{ TYPE_IOS_VERSION,  	"Software version" },
 	{ TYPE_PLATFORM,        "Platform" },
-	{ TYPE_IP_PREFIX,       "IP Prefix (used for ODR)" },
+	{ TYPE_IP_PREFIX,       "IP Prefix/Gateway (used for ODR)" },
 	{ TYPE_PROTOCOL_HELLO,  "Protocol Hello" },
 	{ TYPE_VTP_MGMT_DOMAIN, "VTP Management Domain" },
 	{ TYPE_NATIVE_VLAN,     "Native VLAN" },
@@ -305,6 +305,23 @@
 		offset += length;
 		break;
             case TYPE_IP_PREFIX:
+              if (length==8) /* if length is 8 then this is default gw not prefix */
+              {
+		tlvi = proto_tree_add_text(cdp_tree, tvb, offset,
+			    length, "ODR Default gateway: %s",
+			    ip_to_str(tvb_get_ptr(tvb, offset+4, 4)));
+		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);
+		proto_tree_add_text(tlv_tree, tvb, offset+4, 4,
+				"ODR Default gateway = %s",
+				ip_to_str(tvb_get_ptr(tvb, offset+4, 4)));
+                offset+=8;
+              }
+              else
+              {  
 		tlvi = proto_tree_add_text(cdp_tree, tvb, offset,
 			    length, "IP Prefixes: %d",length/5);
 
@@ -327,7 +344,8 @@
 			offset += 5;
 			length -= 5;
 		}
-		break;
+              }
+              break;
 	    case TYPE_PROTOCOL_HELLO:
 	      tlvi = proto_tree_add_text(cdp_tree, tvb,
 					 offset,length, "Protocol Hello: %s",

Attachment: cdp.cap
Description: Binary data