diff options
author | Anish Bhatt <anish@chelsio.com> | 2014-05-06 02:27:39 -0700 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2014-05-07 04:32:15 +0000 |
commit | 9b7830114fdbb4949f2d73eac5478cab552aa7d9 (patch) | |
tree | 239e85685110f9c3c71ba1030951a597105b15ba /epan/dissectors/packet-lldp.c | |
parent | 45b6780178f0b686bb27f01652828b894e5cdac4 (diff) |
Further LLDP dissection cleanup
Change-Id: I75f4ed401f63e993a2aefa1c289fd48fa00b46e2
Signed-off-by: Anish Bhatt <anish@chelsio.com>
Reviewed-on: https://code.wireshark.org/review/1528
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-lldp.c')
-rw-r--r-- | epan/dissectors/packet-lldp.c | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/epan/dissectors/packet-lldp.c b/epan/dissectors/packet-lldp.c index 0b716f7505..41b9ba59c9 100644 --- a/epan/dissectors/packet-lldp.c +++ b/epan/dissectors/packet-lldp.c @@ -130,6 +130,13 @@ static int hf_ieee_802_1_subtype = -1; static int hf_ieee_802_1_port_and_vlan_id_flag = -1; static int hf_ieee_802_1_port_and_vlan_id_flag_supported = -1; static int hf_ieee_802_1_port_and_vlan_id_flag_enabled = -1; +static int hf_ieee_802_1_port_vlan_id = -1; +static int hf_ieee_802_1_port_proto_vlan_id = -1; +static int hf_ieee_802_1_vlan_id = -1; +static int hf_ieee_802_1_vlan_name_length = -1; +static int hf_ieee_802_1_vlan_name = -1; +static int hf_ieee_802_1_proto_id_length = -1; +static int hf_ieee_802_1_proto_id = -1; static int hf_ieee_8021qau_cnpv_prio0 = -1; static int hf_ieee_8021qau_cnpv_prio1 = -1; static int hf_ieee_8021qau_cnpv_prio2 = -1; @@ -1040,7 +1047,7 @@ dissect_lldp_chassis_id(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, case 2: /* Interface alias */ case 6: /* Interface name */ case 7: /* Locally assigned */ - proto_tree_add_text(chassis_tree, tvb, (offset+3), (tempLen-1), "Chassis Id: %s", strPtr); + proto_tree_add_item(chassis_tree, hf_chassis_id, tvb, (offset+3), (tempLen-1), ENC_NA); proto_item_append_text(tf, ", Id: %s", strPtr); break; case 1: /* Chassis component */ @@ -1663,10 +1670,10 @@ dissect_ieee_802_1_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, { case 0x01: /* Port VLAN ID */ { - /* Get port vland id */ - tempShort = tvb_get_ntohs(tvb, tempOffset); if (tree) - proto_tree_add_text(tree, tvb, tempOffset, 2, "Port VLAN Identifier: %u (0x%04X)", tempShort, tempShort); + proto_tree_add_item(tree, hf_ieee_802_1_port_vlan_id, tvb, tempOffset, 2, ENC_BIG_ENDIAN); + + tempOffset +=2; break; } @@ -1684,34 +1691,33 @@ dissect_ieee_802_1_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, tempOffset++; - /* Get port and protocol vlan id */ - tempShort = tvb_get_ntohs(tvb, tempOffset); if (tree) - proto_tree_add_text(tree, tvb, tempOffset, 2, "Port and Protocol VLAN Identifier: %u (0x%04X)", tempShort, tempShort); + proto_tree_add_item(tree, hf_ieee_802_1_port_proto_vlan_id, tvb, tempOffset, 2, ENC_BIG_ENDIAN); + + tempOffset +=2; break; } case 0x03: /* VLAN Name */ { - /* Get vlan id */ - tempShort = tvb_get_ntohs(tvb, tempOffset); if (tree) - proto_tree_add_text(tree, tvb, tempOffset, 2, "VLAN Identifier: %u (0x%04X)", tempShort, tempShort); + proto_tree_add_item(tree, hf_ieee_802_1_vlan_id, tvb, tempOffset, 2, ENC_BIG_ENDIAN); tempOffset += 2; /* Get vlan name length */ tempByte = tvb_get_guint8(tvb, tempOffset); if (tree) - proto_tree_add_text(tree, tvb, tempOffset, 1, "VLAN Name Length: %u", tempByte); + proto_tree_add_item(tree, hf_ieee_802_1_vlan_name_length, tvb, tempOffset, 1, ENC_BIG_ENDIAN); tempOffset++; if (tempByte > 0) { if (tree) - proto_tree_add_text(tree, tvb, tempOffset, tempByte, "VLAN Name: %s", - tvb_format_stringzpad(tvb, tempOffset, tempByte)); + proto_tree_add_item(tree, hf_ieee_802_1_vlan_name, tvb, tempOffset, tempByte, ENC_ASCII|ENC_NA); + + tempOffset += tempByte; } break; @@ -1721,15 +1727,16 @@ dissect_ieee_802_1_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, /* Get protocal id length */ tempByte = tvb_get_guint8(tvb, tempOffset); if (tree) - proto_tree_add_text(tree, tvb, tempOffset, 1, "Protocol Identity Length: %u", tempByte); + proto_tree_add_item(tree, hf_ieee_802_1_proto_id_length, tvb, tempOffset, 1, ENC_BIG_ENDIAN); tempOffset++; if (tempByte > 0) { if (tree) - proto_tree_add_text(tree, tvb, tempOffset, tempByte, "Protocol Identity: %s", - tvb_bytes_to_ep_str(tvb, tempOffset, tempByte)); + proto_tree_add_item(tree, hf_ieee_802_1_proto_id, tvb, tempOffset, tempByte, ENC_ASCII|ENC_NA); + + tempOffset += tempByte; } break; @@ -3672,6 +3679,34 @@ proto_register_lldp(void) { "Port and Protocol VLAN", "lldp.ieee.802_1.port_and_vlan_id_flag.enabled", FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled), 0x04, NULL, HFILL } }, + { &hf_ieee_802_1_port_vlan_id, + { "Port VLAN Identifier", "lldp.ieee.802_1.port_vlan.id", FT_UINT16, BASE_DEC_HEX, + NULL, 0x0, NULL, HFILL } + }, + { &hf_ieee_802_1_port_proto_vlan_id, + { "Port and Protocol VLAN Identifier", "lldp.ieee.802_1.port_proto_vlan.id", FT_UINT16, BASE_DEC_HEX, + NULL, 0x0, NULL, HFILL } + }, + { &hf_ieee_802_1_vlan_id, + { "VLAN Identifier", "lldp.ieee.802_1.vlan.id", FT_UINT16, BASE_DEC_HEX, + NULL, 0x0, NULL, HFILL } + }, + { &hf_ieee_802_1_vlan_name_length, + { "VLAN Name Length", "lldp.ieee.802_1.vlan.name_len", FT_UINT8, BASE_DEC, + NULL, 0x0, NULL, HFILL } + }, + { &hf_ieee_802_1_vlan_name, + { "VLAN Name", "lldp.ieee.802_1.vlan.name", FT_STRINGZ, BASE_NONE, + NULL, 0x0, NULL, HFILL } + }, + { &hf_ieee_802_1_proto_id_length, + { "Protocol Identity Length", "lldp.ieee.802_1.proto.id_length", FT_UINT8, BASE_DEC, + NULL, 0x0, NULL, HFILL } + }, + { &hf_ieee_802_1_proto_id, + { "Protocol Identity", "lldp.ieee.802_1.proto.id", FT_STRINGZ, BASE_NONE, + NULL, 0x0, NULL, HFILL } + }, { &hf_ieee_8021qau_cnpv_prio0, { "Priority 0 CNPV Capability", "lldp.ieee.802_1qau.cnpv.prio0", FT_BOOLEAN, 8, TFS(&tfs_enabled_disabled), 0x01, NULL, HFILL } |