From e1d54cfc3e8223bb4334e5aeed019dab35528e9b Mon Sep 17 00:00:00 2001 From: Uli Heilmeier Date: Sun, 13 Mar 2016 23:16:20 +0100 Subject: IEEE 802.1Q/VLAN: Resolve ID to a describing name A vlans file in the personal preference directory add an option to resolve VLAN IDs to a describing name. Format of vlan file is 123\tName of VLAN To enable the resolving the preference nameres.vlan_name must be set to TRUE. Bug: 11209 Change-Id: I3f00b4897aace89c03c57b68b6c4b6c8b7d4685a Reviewed-on: https://code.wireshark.org/review/14471 Reviewed-by: Michael Mann Reviewed-by: Alexis La Goutte --- epan/dissectors/packet-vlan.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'epan/dissectors/packet-vlan.c') diff --git a/epan/dissectors/packet-vlan.c b/epan/dissectors/packet-vlan.c index 05ba381dac..915129b573 100644 --- a/epan/dissectors/packet-vlan.c +++ b/epan/dissectors/packet-vlan.c @@ -34,6 +34,7 @@ #include #include #include +#include void proto_register_vlan(void); void proto_reg_handoff_vlan(void); @@ -81,6 +82,10 @@ static header_field_info hfi_vlan_id VLAN_HFI_INIT = { "ID", "vlan.id", FT_UINT16, BASE_DEC, NULL, 0x0FFF, "VLAN ID", HFILL }; +static header_field_info hfi_vlan_id_name VLAN_HFI_INIT = { + "Name", "vlan.id_name", FT_STRING, STR_UNICODE, + NULL, 0x0, "VLAN ID Name", HFILL }; + static header_field_info hfi_vlan_etype VLAN_HFI_INIT = { "Type", "vlan.etype", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, "Ethertype", HFILL }; @@ -141,6 +146,7 @@ dissect_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ guint16 encap_proto; gboolean is_802_2; proto_tree *vlan_tree; + proto_item *item; col_set_str(pinfo->cinfo, COL_PROTOCOL, "VLAN"); col_clear(pinfo->cinfo, COL_INFO); @@ -169,6 +175,14 @@ dissect_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ proto_tree_add_item(vlan_tree, &hfi_vlan_priority, tvb, 0, 2, ENC_BIG_ENDIAN); proto_tree_add_item(vlan_tree, &hfi_vlan_cfi, tvb, 0, 2, ENC_BIG_ENDIAN); proto_tree_add_item(vlan_tree, &hfi_vlan_id, tvb, 0, 2, ENC_BIG_ENDIAN); + + if (gbl_resolv_flags.vlan_name) { + item = proto_tree_add_string(vlan_tree, &hfi_vlan_id_name, tvb, 0, 2, + get_vlan_name(wmem_packet_scope(), vlan_id)); + PROTO_ITEM_SET_GENERATED(item); + + } + } encap_proto = tvb_get_ntohs(tvb, 2); @@ -214,6 +228,7 @@ proto_register_vlan(void) &hfi_vlan_priority, &hfi_vlan_cfi, &hfi_vlan_id, + &hfi_vlan_id_name, &hfi_vlan_etype, &hfi_vlan_len, &hfi_vlan_trailer, -- cgit v1.2.3