From 50408de7628c96cfe49b808c4565b8b1a7d74a84 Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Mon, 18 Mar 2019 17:13:26 +0100 Subject: vlan: Use proto_tree_add_bitmask_list() to add flags. Change-Id: I1c71e9d4a672cd5781ac9aebd0c0ac7c01f83e1f Reviewed-on: https://code.wireshark.org/review/32469 Petri-Dish: Anders Broman Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/dissectors/packet-vlan.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'epan/dissectors/packet-vlan.c') diff --git a/epan/dissectors/packet-vlan.c b/epan/dissectors/packet-vlan.c index 8f23257465..01bcd72645 100644 --- a/epan/dissectors/packet-vlan.c +++ b/epan/dissectors/packet-vlan.c @@ -238,6 +238,14 @@ dissect_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ proto_tree *vlan_tree; proto_item *item; guint vlan_nested_count; + int hf1, hf2; + + int * flags[] = { + &hf1, + &hf2, + &hfi_vlan_id.id, + NULL + }; col_set_str(pinfo->cinfo, COL_PROTOCOL, "VLAN"); col_clear(pinfo->cinfo, COL_INFO); @@ -276,34 +284,36 @@ dissect_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ vlan_tree = proto_item_add_subtree(ti, ett_vlan); if (vlan_version == IEEE_8021Q_1998) { - proto_tree_add_item(vlan_tree, &hfi_vlan_priority_old, tvb, 0, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(vlan_tree, &hfi_vlan_cfi, tvb, 0, 2, ENC_BIG_ENDIAN); + hf1 = hfi_vlan_priority_old.id; + hf2 = hfi_vlan_cfi.id; } else { switch (vlan_priority_drop) { case Priority_Drop_8P0D: - proto_tree_add_item(vlan_tree, &hfi_vlan_priority, tvb, 0, 2, ENC_BIG_ENDIAN); + hf1 = hfi_vlan_priority.id; break; case Priority_Drop_7P1D: - proto_tree_add_item(vlan_tree, &hfi_vlan_priority_7, tvb, 0, 2, ENC_BIG_ENDIAN); + hf1 = hfi_vlan_priority_7.id; break; case Priority_Drop_6P2D: - proto_tree_add_item(vlan_tree, &hfi_vlan_priority_6, tvb, 0, 2, ENC_BIG_ENDIAN); + hf1 = hfi_vlan_priority_6.id; break; case Priority_Drop_5P3D: - proto_tree_add_item(vlan_tree, &hfi_vlan_priority_5, tvb, 0, 2, ENC_BIG_ENDIAN); + hf1 = hfi_vlan_priority_5.id; break; } if (vlan_version == IEEE_8021Q_2005) { - proto_tree_add_item(vlan_tree, &hfi_vlan_cfi, tvb, 0, 2, ENC_BIG_ENDIAN); + hf2 = hfi_vlan_cfi.id; } else { - proto_tree_add_item(vlan_tree, &hfi_vlan_dei, tvb, 0, 2, ENC_BIG_ENDIAN); + hf2 = hfi_vlan_dei.id; } } - proto_tree_add_item(vlan_tree, &hfi_vlan_id, tvb, 0, 2, ENC_BIG_ENDIAN); + + proto_tree_add_bitmask_list(vlan_tree, tvb, 0, 2, (const int **)flags, 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)); -- cgit v1.2.3