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>
This commit is contained in:
Michael Mann 2015-05-20 07:51:00 -04:00 committed by Anders Broman
parent 67159be03d
commit 344c990159
3 changed files with 55 additions and 16 deletions

View File

@ -179,6 +179,7 @@ const value_string etype_vals[] = {
{ ETHERTYPE_ROCE, "RDMA over Converged Ethernet" },
{ ETHERTYPE_TDMOE, "Digium TDM over Ethernet Protocol" },
{ ETHERTYPE_WAI, "WAI Authentication Protocol" },
{ ETHERTYPE_VNTAG, "VN-Tag" },
{ ETHERTYPE_HSR, "High-availability Seamless Redundancy (IEC62439 Part 3)" },
{ ETHERTYPE_BPQ, "AX.25"},
{ ETHERTYPE_CMD, "CiscoMetaData"},

View File

@ -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");
}

View File

@ -530,6 +530,10 @@ extern "C" {
#define ETHERTYPE_TTE_PCF 0x891D /* TTEthernet Protocol Control Frame */
#endif
#ifndef ETHERTYPE_VNTAG
#define ETHERTYPE_VNTAG 0x8926 /* VN-Tag */
#endif
#ifndef ETHERTYPE_HSR
#define ETHERTYPE_HSR 0x892F /* High-availability Seamless Redundancy (IEC62439 Part 3) */
#endif