aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-cdp.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-cdp.c')
-rw-r--r--epan/dissectors/packet-cdp.c280
1 files changed, 145 insertions, 135 deletions
diff --git a/epan/dissectors/packet-cdp.c b/epan/dissectors/packet-cdp.c
index c6ad428c53..21407fff5b 100644
--- a/epan/dissectors/packet-cdp.c
+++ b/epan/dissectors/packet-cdp.c
@@ -20,6 +20,13 @@
#include <epan/cisco_pid.h>
/*
+ *
+ * See
+ *
+ * https://web.archive.org/web/20000914194913/http://www.cisco.com/univercd/cc/td/doc/product/lan/trsrb/frames.pdf
+ *
+ * for some documentation on CDP.
+ *
* See
*
* http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/cdp/configuration/15-mt/cdp-15-mt-book/nm-cdp-discover.html#GUID-84FBA50B-677C-4D90-AF56-2FB96F2DC085
@@ -32,117 +39,119 @@
*
* Also see
*
- * http://www.rhyshaden.com/cdp.htm
+ * https://web.archive.org/web/20220711213555/http://www.rhyshaden.com/cdp.htm
*/
void proto_register_cdp(void);
void proto_reg_handoff_cdp(void);
+static dissector_handle_t cdp_handle;
+
/* Offsets in TLV structure. */
#define TLV_TYPE 0
#define TLV_LENGTH 2
-static int proto_cdp = -1;
-static int hf_cdp_version = -1;
-static int hf_cdp_checksum = -1;
-static int hf_cdp_checksum_status = -1;
-static int hf_cdp_ttl = -1;
-static int hf_cdp_tlvtype = -1;
-static int hf_cdp_tlvlength = -1;
-static int hf_cdp_nrgyz_tlvtype = -1;
-static int hf_cdp_nrgyz_tlvlength = -1;
-static int hf_cdp_deviceid = -1;
-static int hf_cdp_platform = -1;
-static int hf_cdp_portid = -1;
-static int hf_cdp_capabilities = -1;
-static int hf_cdp_capabilities_router = -1;
-static int hf_cdp_capabilities_trans_bridge = -1;
-static int hf_cdp_capabilities_src_bridge = -1;
-static int hf_cdp_capabilities_switch = -1;
-static int hf_cdp_capabilities_host = -1;
-static int hf_cdp_capabilities_igmp_capable = -1;
-static int hf_cdp_capabilities_repeater = -1;
-static int hf_cdp_capabilities_voip_phone = -1;
-static int hf_cdp_capabilities_remote = -1;
-static int hf_cdp_capabilities_cvta = -1;
-static int hf_cdp_capabilities_mac_relay = -1;
-static int hf_cdp_spare_poe_tlv = -1;
-static int hf_cdp_spare_poe_tlv_poe = -1;
-static int hf_cdp_spare_poe_tlv_spare_pair_arch = -1;
-static int hf_cdp_spare_poe_tlv_req_spare_pair_poe = -1;
-static int hf_cdp_spare_poe_tlv_pse_spare_pair_poe = -1;
+static int proto_cdp;
+static int hf_cdp_version;
+static int hf_cdp_checksum;
+static int hf_cdp_checksum_status;
+static int hf_cdp_ttl;
+static int hf_cdp_tlvtype;
+static int hf_cdp_tlvlength;
+static int hf_cdp_nrgyz_tlvtype;
+static int hf_cdp_nrgyz_tlvlength;
+static int hf_cdp_deviceid;
+static int hf_cdp_platform;
+static int hf_cdp_portid;
+static int hf_cdp_capabilities;
+static int hf_cdp_capabilities_router;
+static int hf_cdp_capabilities_trans_bridge;
+static int hf_cdp_capabilities_src_bridge;
+static int hf_cdp_capabilities_switch;
+static int hf_cdp_capabilities_host;
+static int hf_cdp_capabilities_igmp_capable;
+static int hf_cdp_capabilities_repeater;
+static int hf_cdp_capabilities_voip_phone;
+static int hf_cdp_capabilities_remote;
+static int hf_cdp_capabilities_cvta;
+static int hf_cdp_capabilities_mac_relay;
+static int hf_cdp_spare_poe_tlv;
+static int hf_cdp_spare_poe_tlv_poe;
+static int hf_cdp_spare_poe_tlv_spare_pair_arch;
+static int hf_cdp_spare_poe_tlv_req_spare_pair_poe;
+static int hf_cdp_spare_poe_tlv_pse_spare_pair_poe;
/* Generated from convert_proto_tree_add_text.pl */
-static int hf_cdp_num_tlvs_table = -1;
-static int hf_cdp_encrypted_data = -1;
-static int hf_cdp_cluster_ip = -1;
-static int hf_cdp_nrgyz_reply_to_backup_server_ip = -1;
-static int hf_cdp_nrgyz_reply_to_port = -1;
-static int hf_cdp_unknown_pad = -1;
-static int hf_cdp_cluster_version = -1;
-static int hf_cdp_hello_unknown = -1;
-static int hf_cdp_management_id = -1;
-static int hf_cdp_data = -1;
-static int hf_cdp_nrgyz_reply_to_ip_address = -1;
-static int hf_cdp_nrgyz_reply_to_name = -1;
-static int hf_cdp_nrgyz_reply_to_domain = -1;
-static int hf_cdp_nrgyz_reply_to_role = -1;
-static int hf_cdp_nrgyz_ip_address = -1;
-static int hf_cdp_nrgyz_ip6_address = -1;
-static int hf_cdp_model_number = -1;
-static int hf_cdp_nrgyz_reply_to_unknown_field = -1;
-static int hf_cdp_len_tlv_table = -1;
-static int hf_cdp_vtp_management_domain = -1;
-static int hf_cdp_hardware_version_id = -1;
-static int hf_cdp_cluster_unknown = -1;
-static int hf_cdp_native_vlan = -1;
-static int hf_cdp_ip_prefix = -1;
-static int hf_cdp_odr_default_gateway = -1;
-static int hf_cdp_power_consumption = -1;
-static int hf_cdp_cluster_status = -1;
-static int hf_cdp_power_requested = -1;
-static int hf_cdp_trust_bitmap = -1;
-static int hf_cdp_seen_sequence = -1;
-static int hf_cdp_system_name = -1;
-static int hf_cdp_power_available = -1;
-static int hf_cdp_cluster_commander_mac = -1;
-static int hf_cdp_mtu = -1;
-static int hf_cdp_protocol_length = -1;
-static int hf_cdp_system_serial_number = -1;
-static int hf_cdp_sequence_number = -1;
-static int hf_cdp_duplex = -1;
-static int hf_cdp_voice_vlan = -1;
-static int hf_cdp_request_id = -1;
-static int hf_cdp_cluster_sub_version = -1;
-static int hf_cdp_oui = -1;
-static int hf_cdp_nrgyz_reply_to_backup_server_port = -1;
-static int hf_cdp_cluster_master_ip = -1;
-static int hf_cdp_protocol = -1;
-static int hf_cdp_protocol_type = -1;
-static int hf_cdp_address = -1;
-static int hf_cdp_system_object_identifier = -1;
-static int hf_cdp_location_unknown = -1;
-static int hf_cdp_nrgyz_unknown_values = -1;
-static int hf_cdp_address_length = -1;
-static int hf_cdp_protocol_id = -1;
-static int hf_cdp_cluster_switch_mac = -1;
-static int hf_cdp_location = -1;
-static int hf_cdp_untrusted_port_cos = -1;
-static int hf_cdp_number_of_addresses = -1;
-static int hf_cdp_cluster_management_vlan = -1;
-static int hf_cdp_software_version = -1;
-
-static gint ett_cdp = -1;
-static gint ett_cdp_tlv = -1;
-static gint ett_cdp_nrgyz_tlv = -1;
-static gint ett_cdp_address = -1;
-static gint ett_cdp_capabilities = -1;
-static gint ett_cdp_spare_poe_tlv = -1;
-static gint ett_cdp_checksum = -1;
-
-static expert_field ei_cdp_invalid_data = EI_INIT;
-static expert_field ei_cdp_nrgyz_tlvlength = EI_INIT;
-static expert_field ei_cdp_checksum = EI_INIT;
+static int hf_cdp_num_tlvs_table;
+static int hf_cdp_encrypted_data;
+static int hf_cdp_cluster_ip;
+static int hf_cdp_nrgyz_reply_to_backup_server_ip;
+static int hf_cdp_nrgyz_reply_to_port;
+static int hf_cdp_unknown_pad;
+static int hf_cdp_cluster_version;
+static int hf_cdp_hello_unknown;
+static int hf_cdp_management_id;
+static int hf_cdp_data;
+static int hf_cdp_nrgyz_reply_to_ip_address;
+static int hf_cdp_nrgyz_reply_to_name;
+static int hf_cdp_nrgyz_reply_to_domain;
+static int hf_cdp_nrgyz_reply_to_role;
+static int hf_cdp_nrgyz_ip_address;
+static int hf_cdp_nrgyz_ip6_address;
+static int hf_cdp_model_number;
+static int hf_cdp_nrgyz_reply_to_unknown_field;
+static int hf_cdp_len_tlv_table;
+static int hf_cdp_vtp_management_domain;
+static int hf_cdp_hardware_version_id;
+static int hf_cdp_cluster_unknown;
+static int hf_cdp_native_vlan;
+static int hf_cdp_ip_prefix;
+static int hf_cdp_odr_default_gateway;
+static int hf_cdp_power_consumption;
+static int hf_cdp_cluster_status;
+static int hf_cdp_power_requested;
+static int hf_cdp_trust_bitmap;
+static int hf_cdp_seen_sequence;
+static int hf_cdp_system_name;
+static int hf_cdp_power_available;
+static int hf_cdp_cluster_commander_mac;
+static int hf_cdp_mtu;
+static int hf_cdp_protocol_length;
+static int hf_cdp_system_serial_number;
+static int hf_cdp_sequence_number;
+static int hf_cdp_duplex;
+static int hf_cdp_voice_vlan;
+static int hf_cdp_request_id;
+static int hf_cdp_cluster_sub_version;
+static int hf_cdp_oui;
+static int hf_cdp_nrgyz_reply_to_backup_server_port;
+static int hf_cdp_cluster_master_ip;
+static int hf_cdp_protocol;
+static int hf_cdp_protocol_type;
+static int hf_cdp_address;
+static int hf_cdp_system_object_identifier;
+static int hf_cdp_location_unknown;
+static int hf_cdp_nrgyz_unknown_values;
+static int hf_cdp_address_length;
+static int hf_cdp_protocol_id;
+static int hf_cdp_cluster_switch_mac;
+static int hf_cdp_location;
+static int hf_cdp_untrusted_port_cos;
+static int hf_cdp_number_of_addresses;
+static int hf_cdp_cluster_management_vlan;
+static int hf_cdp_software_version;
+
+static gint ett_cdp;
+static gint ett_cdp_tlv;
+static gint ett_cdp_nrgyz_tlv;
+static gint ett_cdp_address;
+static gint ett_cdp_capabilities;
+static gint ett_cdp_spare_poe_tlv;
+static gint ett_cdp_checksum;
+
+static expert_field ei_cdp_invalid_data;
+static expert_field ei_cdp_nrgyz_tlvlength;
+static expert_field ei_cdp_checksum;
static int
dissect_address_tlv(tvbuff_t *tvb, packet_info* pinfo, int offset, int length, proto_tree *tree);
@@ -154,7 +163,7 @@ dissect_nrgyz_tlv(tvbuff_t *tvb, packet_info* pinfo, int offset, guint16 length,
static void
dissect_spare_poe_tlv(tvbuff_t *tvb, int offset, int length, proto_tree *tree);
static void
-add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start,
+add_multi_line_string_to_tree(wmem_allocator_t *scope, proto_tree *tree, tvbuff_t *tvb, gint start,
gint len, int hf);
#define TYPE_DEVICE_ID 0x0001
@@ -369,7 +378,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_stringzpad(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_deviceid, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_deviceid, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -399,7 +408,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, real_length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_portid, tvb, offset + 4, real_length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_portid, tvb, offset + 4, real_length - 4, ENC_ASCII);
}
offset += real_length;
break;
@@ -450,7 +459,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
length, ett_cdp_tlv, NULL, "Software Version");
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- add_multi_line_string_to_tree(tlv_tree, tvb, offset + 4,
+ add_multi_line_string_to_tree(pinfo->pool, tlv_tree, tvb, offset + 4,
length - 4, hf_cdp_software_version);
}
offset += length;
@@ -464,7 +473,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -858,7 +867,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -871,7 +880,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -890,7 +899,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
}
offset += length;
@@ -904,7 +913,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -917,7 +926,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -930,7 +939,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -943,7 +952,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -956,7 +965,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -969,7 +978,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -982,7 +991,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -995,7 +1004,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -1008,7 +1017,7 @@ dissect_cdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
tvb_format_text(pinfo->pool, tvb, offset + 4, length - 4));
proto_tree_add_item(tlv_tree, hf_cdp_tlvtype, tvb, offset + TLV_TYPE, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tlv_tree, hf_cdp_tlvlength, tvb, offset + TLV_LENGTH, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII|ENC_NA);
+ proto_tree_add_item(tlv_tree, hf_cdp_platform, tvb, offset + 4, length - 4, ENC_ASCII);
}
offset += length;
break;
@@ -1149,7 +1158,10 @@ dissect_address_tlv(tvbuff_t *tvb, packet_info* pinfo, int offset, int length, p
if (hf_addr == -1)
{
proto_tree_add_item(address_tree, hf_cdp_address, tvb, offset, address_length, ENC_NA);
- proto_item_set_text(ti, "Address: %s", tvb_bytes_to_str(pinfo->pool, tvb, offset, address_length));
+ if(address_length)
+ {
+ proto_item_set_text(ti, "Address: %s", tvb_bytes_to_str(pinfo->pool, tvb, offset, address_length));
+ }
}
return 2 + protocol_length + 2 + address_length;
@@ -1274,7 +1286,7 @@ dissect_spare_poe_tlv(tvbuff_t *tvb, int offset, int length,
}
static void
-add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start,
+add_multi_line_string_to_tree(wmem_allocator_t *scope, proto_tree *tree, tvbuff_t *tvb, gint start,
gint len, int hf)
{
gint next;
@@ -1284,7 +1296,7 @@ add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start,
while (len > 0) {
line_len = tvb_find_line_end(tvb, start, len, &next, FALSE);
data_len = next - start;
- proto_tree_add_string(tree, hf, tvb, start, data_len, tvb_format_stringzpad(wmem_packet_scope(), tvb, start, line_len));
+ proto_tree_add_string(tree, hf, tvb, start, data_len, tvb_format_stringzpad(scope, tvb, start, line_len));
start += data_len;
len -= data_len;
}
@@ -1323,7 +1335,7 @@ proto_register_cdp(void)
NULL, HFILL }},
{ &hf_cdp_nrgyz_tlvlength,
- { "TLV Length", "cdp.nrgyz.tlv.len", FT_UINT16, BASE_DEC, NULL, 0x0,
+ { "TLV Length", "cdp.nrgyz.tlv.len", FT_UINT32, BASE_DEC, NULL, 0x0,
NULL, HFILL }},
{ &hf_cdp_deviceid,
@@ -1344,47 +1356,47 @@ proto_register_cdp(void)
{ &hf_cdp_capabilities_router,
{"Router", "cdp.capabilities.router", FT_BOOLEAN, 32,
- TFS(&tfs_yes_no), 0x01, NULL, HFILL }},
+ TFS(&tfs_yes_no), 0x00000001, NULL, HFILL }},
{ &hf_cdp_capabilities_trans_bridge,
{"Transparent Bridge", "cdp.capabilities.trans_bridge", FT_BOOLEAN, 32,
- TFS(&tfs_yes_no), 0x02, NULL, HFILL }},
+ TFS(&tfs_yes_no), 0x00000002, NULL, HFILL }},
{ &hf_cdp_capabilities_src_bridge,
{"Source Route Bridge", "cdp.capabilities.src_bridge", FT_BOOLEAN, 32,
- TFS(&tfs_yes_no), 0x04, NULL, HFILL }},
+ TFS(&tfs_yes_no), 0x00000004, NULL, HFILL }},
{ &hf_cdp_capabilities_switch,
{"Switch", "cdp.capabilities.switch", FT_BOOLEAN, 32,
- TFS(&tfs_yes_no), 0x08, NULL, HFILL }},
+ TFS(&tfs_yes_no), 0x00000008, NULL, HFILL }},
{ &hf_cdp_capabilities_host,
{"Host", "cdp.capabilities.host", FT_BOOLEAN, 32,
- TFS(&tfs_yes_no), 0x10, NULL, HFILL }},
+ TFS(&tfs_yes_no), 0x00000010, NULL, HFILL }},
{ &hf_cdp_capabilities_igmp_capable,
{"IGMP capable", "cdp.capabilities.igmp_capable", FT_BOOLEAN, 32,
- TFS(&tfs_yes_no), 0x20, NULL, HFILL }},
+ TFS(&tfs_yes_no), 0x00000020, NULL, HFILL }},
{ &hf_cdp_capabilities_repeater,
{"Repeater", "cdp.capabilities.repeater", FT_BOOLEAN, 32,
- TFS(&tfs_yes_no), 0x40, NULL, HFILL }},
+ TFS(&tfs_yes_no), 0x00000040, NULL, HFILL }},
{ &hf_cdp_capabilities_voip_phone,
{"VoIP Phone", "cdp.capabilities.voip_phone", FT_BOOLEAN, 32,
- TFS(&tfs_yes_no), 0x80, NULL, HFILL }},
+ TFS(&tfs_yes_no), 0x00000080, NULL, HFILL }},
{ &hf_cdp_capabilities_remote,
{"Remotely Managed Device", "cdp.capabilities.remote", FT_BOOLEAN, 32,
- TFS(&tfs_yes_no), 0x0100, NULL, HFILL }},
+ TFS(&tfs_yes_no), 0x00000100, NULL, HFILL }},
{ &hf_cdp_capabilities_cvta,
{"CVTA/STP Dispute Resolution/Cisco VT Camera", "cdp.capabilities.cvta", FT_BOOLEAN, 32,
- TFS(&tfs_yes_no), 0x0200, NULL, HFILL }},
+ TFS(&tfs_yes_no), 0x00000200, NULL, HFILL }},
{ &hf_cdp_capabilities_mac_relay,
{"Two Port Mac Relay", "cdp.capabilities.mac_relay", FT_BOOLEAN, 32,
- TFS(&tfs_yes_no), 0x0400, NULL, HFILL }},
+ TFS(&tfs_yes_no), 0x00000400, NULL, HFILL }},
{ &hf_cdp_spare_poe_tlv,
{ "Spare Pair PoE", "cdp.spare_poe_tlv", FT_UINT8, BASE_HEX,
@@ -1491,6 +1503,7 @@ proto_register_cdp(void)
expert_module_t* expert_cdp;
proto_cdp = proto_register_protocol("Cisco Discovery Protocol", "CDP", "cdp");
+ cdp_handle = register_dissector("cdp", dissect_cdp, proto_cdp);
proto_register_field_array(proto_cdp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
@@ -1501,9 +1514,6 @@ proto_register_cdp(void)
void
proto_reg_handoff_cdp(void)
{
- dissector_handle_t cdp_handle;
-
- cdp_handle = create_dissector_handle(dissect_cdp, proto_cdp);
dissector_add_uint("llc.cisco_pid", CISCO_PID_CDP, cdp_handle);
dissector_add_uint("chdlc.protocol", 0x2000, cdp_handle);
dissector_add_uint("ppp.protocol", 0x0207, cdp_handle);