aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-vntag.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-05-20 07:51:00 -0400
committerAnders Broman <a.broman58@gmail.com>2015-05-20 14:57:51 +0000
commit344c990159d109940bffd28505d6dfab0cc19b9c (patch)
tree8e0a782727d93f56ef75f04492bf6515b358d04f /epan/dissectors/packet-vntag.c
parent67159be03d06dca32567fc54acf5b39d249a7ee7 (diff)
Improve VN-Tag dissector.
Bug: 7496 Change-Id: Ic1648f1c111913b7370b2eaf5557c4d8ea078033 Reviewed-on: https://code.wireshark.org/review/8546 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-vntag.c')
-rw-r--r--epan/dissectors/packet-vntag.c66
1 files changed, 50 insertions, 16 deletions
diff --git a/epan/dissectors/packet-vntag.c b/epan/dissectors/packet-vntag.c
index d49e5ec69e..5aa2666d6d 100644
--- a/epan/dissectors/packet-vntag.c
+++ b/epan/dissectors/packet-vntag.c
@@ -32,6 +32,14 @@ static dissector_handle_t ethertype_handle;
static int proto_vntag = -1;
static int hf_vntag_etype = -1;
+static int hf_vntag_dir = -1;
+static int hf_vntag_ptr = -1;
+static int hf_vntag_vif_list_id = -1;
+static int hf_vntag_dst = -1;
+static int hf_vntag_looped = -1;
+static int hf_vntag_r = -1;
+static int hf_vntag_version = -1;
+static int hf_vntag_src = -1;
/* static int hf_vntag_len = -1; */
static int hf_vntag_trailer = -1;
@@ -44,27 +52,28 @@ dissect_vntag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_tree *vntag_tree = NULL;
ethertype_data_t ethertype_data;
+ /* from scapy (http://hg.secdev.org/scapy-com/rev/37acec891993) GPLv2: */
+ /* another: http://www.definethecloud.net/access-layer-network-virtualization-vn-tag-and-vepa */
+ static const int * fields[] = {
+ &hf_vntag_dir,
+ &hf_vntag_ptr,
+ &hf_vntag_vif_list_id,
+ &hf_vntag_dst,
+ &hf_vntag_looped,
+ &hf_vntag_r,
+ &hf_vntag_version,
+ &hf_vntag_src,
+ NULL
+ };
+
col_set_str(pinfo->cinfo, COL_PROTOCOL, "VNTAG");
col_clear(pinfo->cinfo, COL_INFO);
if (tree) {
proto_item *ti = proto_tree_add_item(tree, proto_vntag, tvb, 0, 4, ENC_NA);
-
vntag_tree = proto_item_add_subtree(ti, ett_vntag);
- /* XXX, 4 bytes of data */
-
- /* from scapy (http://hg.secdev.org/scapy-com/rev/37acec891993) GPLv2:
-
- BitField("dir", 0, 1),
- BitField("ptr", 0, 1),
- BitField("dst", 0, 14),
- BitField("looped", 0, 1),
- BitField("r", 0, 1),
- BitField("version", 0, 2),
- BitField("src", 0, 12) ]
- */
- /* another: http://www.definethecloud.net/access-layer-network-virtualization-vn-tag-and-vepa */
+ proto_tree_add_bitmask_list(vntag_tree, tvb, 0, 4, fields, ENC_BIG_ENDIAN);
}
encap_proto = tvb_get_ntohs(tvb, 4);
@@ -84,7 +93,7 @@ dissect_vntag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
is_802_2 = TRUE;
/* Don't throw an exception for this check (even a BoundsError) */
- if (tvb_length_remaining(tvb, 4) >= 2) {
+ if (tvb_captured_length_remaining(tvb, 4) >= 2) {
if (tvb_get_ntohs(tvb, 4) == 0xffff)
is_802_2 = FALSE;
}
@@ -112,6 +121,31 @@ proto_register_vntag(void)
{ &hf_vntag_etype,
{ "Type", "vntag.etype", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, NULL, HFILL }
},
+ { &hf_vntag_dir,
+ { "Direction", "vntag.dir", FT_UINT32, BASE_DEC, NULL, 0x80000000, NULL, HFILL }
+ },
+ { &hf_vntag_ptr,
+ { "Pointer", "vntag.ptr", FT_UINT32, BASE_DEC, NULL, 0x40000000, NULL, HFILL }
+ },
+ { &hf_vntag_vif_list_id,
+ { "Downlink Ports", "vntag.vif_list_id", FT_UINT32, BASE_DEC, NULL, 0x30000000, NULL, HFILL }
+ },
+ { &hf_vntag_dst,
+ { "Destination", "vntag.dst", FT_UINT32, BASE_DEC, NULL, 0x0FFF0000, NULL, HFILL }
+ },
+ { &hf_vntag_looped,
+ { "Looped", "vntag.looped", FT_UINT32, BASE_DEC, NULL, 0x00008000, NULL, HFILL }
+ },
+ { &hf_vntag_r,
+ { "Reserved", "vntag.r", FT_UINT32, BASE_DEC, NULL, 0x00004000, NULL, HFILL }
+ },
+ { &hf_vntag_version,
+ { "Version", "vntag.version", FT_UINT32, BASE_DEC, NULL, 0x00003000, NULL, HFILL }
+ },
+ { &hf_vntag_src,
+ { "Source", "vntag.src", FT_UINT32, BASE_DEC, NULL, 0x00000FFF, NULL, HFILL }
+ },
+
#if 0
{ &hf_vntag_len,
{ "Length", "vntag.len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
@@ -139,7 +173,7 @@ proto_reg_handoff_vntag(void)
/* XXX, add 0x8926 define to epan/etypes.h && etype_vals */
vntag_handle = create_dissector_handle(dissect_vntag, proto_vntag);
- dissector_add_uint("ethertype", 0x8926, vntag_handle);
+ dissector_add_uint("ethertype", ETHERTYPE_VNTAG, vntag_handle);
ethertype_handle = find_dissector("ethertype");
}