Ethereal-dev: [Ethereal-dev] CDP dissector, power consumption [PATCH]

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

From: Jaap Keuter <jaap.keuter@xxxxxxxxx>
Date: Fri, 23 Dec 2005 15:38:30 +0100 (CET)
Hi list,

On the Ethereal Wiki is a CDP capture of a Broadcom BCM1100 VoIP chipset.
It has a power consumption TLV, which was not yet dissected. The attached
patch does that.

Thanx,
Jaap

Index: packet-cdp.c
===================================================================
--- packet-cdp.c	(revision 16889)
+++ packet-cdp.c	(working copy)
@@ -92,6 +92,7 @@
 /*                              0x000d */
 #define TYPE_VOIP_VLAN_REPLY    0x000e /* VoIP VLAN reply */
 #define TYPE_VOIP_VLAN_QUERY    0x000f /* VoIP VLAN query */
+#define TYPE_POWER              0x0010 /* Power consumption */
 #define TYPE_MTU                0x0011 /* MTU */
 #define TYPE_TRUST_BITMAP       0x0012 /* Trust bitmap */
 #define TYPE_UNTRUSTED_COS      0x0013 /* Untrusted port CoS */
@@ -115,6 +116,7 @@
 	{ TYPE_DUPLEX,          "Duplex" },
 	{ TYPE_VOIP_VLAN_REPLY, "VoIP VLAN Reply" },
 	{ TYPE_VOIP_VLAN_QUERY, "VoIP VLAN Query" },
+	{ TYPE_POWER,           "Power consumption" },
 	{ TYPE_MTU,             "MTU"},
 	{ TYPE_TRUST_BITMAP,    "Trust Bitmap" },
 	{ TYPE_UNTRUSTED_COS,   "Untrusted Port CoS" },
@@ -501,6 +503,20 @@
 	      }
 	      offset += length;
 	      break;
+	    case TYPE_POWER:
+		tlvi = proto_tree_add_text(cdp_tree, tvb,
+			    offset, length, "Power consumption: %d mW",
+					   tvb_get_ntohs(tvb, offset + 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,
+			    length - 4, "Power consumption: %d mW",
+				    tvb_get_ntohs(tvb, offset + 4));
+		offset += length;
+		break;
 	    case TYPE_MTU:
 	      tlvi = proto_tree_add_text(cdp_tree, tvb,
 					 offset, length, "MTU: %u",