* Routines for the disassembly of the "Cisco Discovery Protocol"
* (c) Copyright Hannes R. Boehm <hannes@boehm.org>
*
- * $Id: packet-cdp.c,v 1.14 1999/09/17 05:56:53 guy 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>
#define TLV_LENGTH 2
static int proto_cdp = -1;
+static int hf_cdp_version = -1;
+static int hf_cdp_flags = -1;
+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);
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_text(cdp_tree, offset, 1, "Version: %u", pd[offset]);
+ proto_tree_add_item(cdp_tree, hf_cdp_version, offset, 1, pd[offset]);
offset += 1;
- proto_tree_add_text(cdp_tree, offset, 1, "Flags: %x (unknown)",
- pd[offset]);
+ proto_tree_add_item_format(cdp_tree, hf_cdp_flags, offset, 1,
+ pd[offset],
+ "Flags: %x (unknown)", pd[offset]);
offset += 1;
- proto_tree_add_text(cdp_tree, offset, 2, "TTL: %u (unknown)",
- pntohs(&pd[offset]));
+ proto_tree_add_item_format(cdp_tree, hf_cdp_ttl, offset, 2,
+ pntohs(&pd[offset]),
+ "TTL: %u (unknown)", pntohs(&pd[offset]));
offset += 2;
while( IS_DATA_IN_FRAME(offset) ){
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,
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,
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,
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,
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,
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,
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,
proto_register_cdp(void)
{
static hf_register_info hf[] = {
+ { &hf_cdp_version,
+ { "Version", "cdp.version", FT_UINT8, BASE_DEC, NULL, 0x0,
+ "" }},
+
+ { &hf_cdp_flags,
+ { "Flags", "cdp.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_cdp_ttl,
+ { "TTL", "cdp.ttl", FT_UINT16, BASE_DEC, NULL, 0x0,
+ "" }},
+
{ &hf_cdp_tlvtype,
- { "Type", "cdp.tlv.type", FT_VALS_UINT16, VALS(type_vals) }},
+ { "Type", "cdp.tlv.type", FT_UINT16, BASE_HEX, VALS(type_vals), 0x0,
+ "" }},
{ &hf_cdp_tlvlength,
- { "Length", "cdp.tlv.len", FT_UINT16, NULL }},
+ { "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));
}