aboutsummaryrefslogtreecommitdiffstats
path: root/packet-cdp.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-11-16 11:44:20 +0000
committerGuy Harris <guy@alum.mit.edu>1999-11-16 11:44:20 +0000
commita7aba0a28890856d2570951c2b0a76c922fdfa72 (patch)
treebcc3d6ea4d23e60c7841a408e9b1876ed6a93106 /packet-cdp.c
parent3a2f7f641a49b5eb9f369dcb29bc8a7cb1c50a91 (diff)
Replace the ETT_ "enum" members, declared in "packet.h", with
dynamically-assigned "ett_" integer values, assigned by "proto_register_subtree_array()"; this: obviates the need to update "packet.h" whenever you add a new subtree type - you only have to add a call to "proto_register_subtree_array()" to a "register" routine and an array of pointers to "ett_", if they're not already there, and add a pointer to the new "ett_" variable to the array, if they are there; would allow run-time-loaded dissectors to allocate subtree types when they're loaded. svn path=/trunk/; revision=1043
Diffstat (limited to 'packet-cdp.c')
-rw-r--r--packet-cdp.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/packet-cdp.c b/packet-cdp.c
index 5ea46954ec..95a826953c 100644
--- a/packet-cdp.c
+++ b/packet-cdp.c
@@ -2,7 +2,7 @@
* Routines for the disassembly of the "Cisco Discovery Protocol"
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
- * $Id: packet-cdp.c,v 1.16 1999/10/16 14:27:00 deniel Exp $
+ * $Id: packet-cdp.c,v 1.17 1999/11/16 11:42:28 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -47,6 +47,9 @@ static int hf_cdp_ttl = -1;
static int hf_cdp_tlvtype = -1;
static int hf_cdp_tlvlength = -1;
+static gint ett_cdp = -1;
+static gint ett_cdp_tlv = -1;
+
static void
add_multi_line_string_to_tree(proto_tree *tree, gint start, gint len,
const gchar *prefix, const gchar *string);
@@ -88,7 +91,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
if(tree){
ti = proto_tree_add_item(tree, proto_cdp, offset, END_OF_FRAME, NULL);
- cdp_tree = proto_item_add_subtree(ti, ETT_CDP);
+ cdp_tree = proto_item_add_subtree(ti, ett_cdp);
/* CDP header */
proto_tree_add_item(cdp_tree, hf_cdp_version, offset, 1, pd[offset]);
@@ -117,7 +120,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
length + 4, "Type: %s, length: %u",
type_str, length);
tlv_tree = proto_item_add_subtree(tlvi,
- ETT_CDP_TLV);
+ ett_cdp_tlv);
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype,
offset + TLV_TYPE, 2, type);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength,
@@ -134,7 +137,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
length, "Chassis ID: %s",
&pd[offset+4]);
tlv_tree = proto_item_add_subtree(tlvi,
- ETT_CDP_TLV);
+ ett_cdp_tlv);
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype,
offset + TLV_TYPE, 2, type);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength,
@@ -153,7 +156,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
4, "Type: %u (unknown), second field: %u",
type, length);
tlv_tree = proto_item_add_subtree(tlvi,
- ETT_CDP_TLV);
+ ett_cdp_tlv);
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype,
offset + TLV_TYPE, 2, type);
proto_tree_add_text(tlv_tree,
@@ -167,7 +170,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
length, "Sent through Interface: %s",
&pd[offset+4]);
tlv_tree = proto_item_add_subtree(tlvi,
- ETT_CDP_TLV);
+ ett_cdp_tlv);
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype,
offset + TLV_TYPE, 2, type);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength,
@@ -193,7 +196,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
offset, length, "Platform: %s",
stringmem);
tlv_tree = proto_item_add_subtree(tlvi,
- ETT_CDP_TLV);
+ ett_cdp_tlv);
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype,
offset + TLV_TYPE, 2, type);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength,
@@ -211,7 +214,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
offset, length + 4, "Mgmt IP: %s",
ip_to_str(&pd[offset+4]));
tlv_tree = proto_item_add_subtree(tlvi,
- ETT_CDP_TLV);
+ ett_cdp_tlv);
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype,
offset + TLV_TYPE, 2, type);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength,
@@ -226,7 +229,7 @@ dissect_cdp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
length, "Type: %s, length: %u",
type_str, length);
tlv_tree = proto_item_add_subtree(tlvi,
- ETT_CDP_TLV);
+ ett_cdp_tlv);
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype,
offset + TLV_TYPE, 2, type);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength,
@@ -304,7 +307,12 @@ proto_register_cdp(void)
{ "Length", "cdp.tlv.len", FT_UINT16, BASE_DEC, NULL, 0x0,
"" }},
};
+ static gint *ett[] = {
+ &ett_cdp,
+ &ett_cdp_tlv,
+ };
proto_cdp = proto_register_protocol("Cisco Discovery Protocol", "cdp");
proto_register_field_array(proto_cdp, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
}