diff options
author | Joerg Mayer <jmayer@loplof.de> | 2018-02-22 07:46:37 +0100 |
---|---|---|
committer | Jörg Mayer <jmayer@loplof.de> | 2018-02-22 10:04:41 +0000 |
commit | e510ceed0563a5b37481339beb1a8cb61809d164 (patch) | |
tree | f34df0e43d872cd1bb5ec91a2c8e25f72a8c759d /epan/dissectors/packet-vntag.c | |
parent | 818b58da97d55af5fe0a0d7de72518f865730f20 (diff) |
Reenable ieee 802.3 encapsulation and small cleanups/updates
Change-Id: I6674140b79bb21121edbd3caa371b7d0f179811a
Reviewed-on: https://code.wireshark.org/review/25982
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
Diffstat (limited to 'epan/dissectors/packet-vntag.c')
-rw-r--r-- | epan/dissectors/packet-vntag.c | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/epan/dissectors/packet-vntag.c b/epan/dissectors/packet-vntag.c index 9aee26194b..2e39136848 100644 --- a/epan/dissectors/packet-vntag.c +++ b/epan/dissectors/packet-vntag.c @@ -11,6 +11,9 @@ #include <epan/packet.h> #include <epan/etypes.h> +#include <epan/expert.h> +#include <epan/tfs.h> +#include <epan/dissectors/packet-ieee8023.h> void proto_register_vntag(void); void proto_reg_handoff_vntag(void); @@ -22,17 +25,27 @@ 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_len = -1; static int hf_vntag_trailer = -1; static gint ett_vntag = -1; +static expert_field ei_vntag_len = EI_INIT; + +static const true_false_string vntag_dir_tfs = { + "From Bridge", + "To Bridge" +}; +static const true_false_string vntag_ptr_tfs = { + "vif_list_id", + "vif_id" +}; + static int dissect_vntag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { @@ -40,12 +53,13 @@ dissect_vntag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U 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 */ + /* Documentation: + https://d2zmdbbm9feqrf.cloudfront.net/2012/usa/pdf/BRKDCT-2340.pdf p.61 + 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, @@ -66,8 +80,7 @@ dissect_vntag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U encap_proto = tvb_get_ntohs(tvb, 4); - /* copied from packet-vlan.c do we need it also for VNTAG? */ -#if 0 + /* VNTAG may also carry 802.2 encapsulated data */ if (encap_proto <= IEEE_802_3_MAX_LEN) { gboolean is_802_2; @@ -81,14 +94,13 @@ dissect_vntag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U is_802_2 = TRUE; /* Don't throw an exception for this check (even a BoundsError) */ - if (tvb_captured_length_remaining(tvb, 4) >= 2) { - if (tvb_get_ntohs(tvb, 4) == 0xffff) + if (tvb_captured_length_remaining(tvb, 6) >= 2) { + if (tvb_get_ntohs(tvb, 6) == 0xffff) is_802_2 = FALSE; } - dissect_802_3(encap_proto, is_802_2, tvb, 4, pinfo, tree, vntag_tree, hf_vntag_len, hf_vntag_trailer, 0); + dissect_802_3(encap_proto, is_802_2, tvb, 6, pinfo, tree, vntag_tree, hf_vntag_len, hf_vntag_trailer, &ei_vntag_len, 0); } else { -#endif ethertype_data.etype = encap_proto; ethertype_data.offset_after_ethertype = 6; ethertype_data.fh_tree = vntag_tree; @@ -97,9 +109,7 @@ dissect_vntag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U ethertype_data.fcs_len = 0; call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, ðertype_data); -#if 0 } -#endif return tvb_captured_length(tvb); } @@ -111,19 +121,16 @@ proto_register_vntag(void) { "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 } + { "Direction", "vntag.dir", FT_BOOLEAN, 32, TFS(&vntag_dir_tfs), 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 } + { "Pointer", "vntag.ptr", FT_BOOLEAN, 32, TFS(&vntag_ptr_tfs), 0x40000000, NULL, HFILL } }, { &hf_vntag_dst, - { "Destination", "vntag.dst", FT_UINT32, BASE_DEC, NULL, 0x0FFF0000, NULL, HFILL } + { "Destination", "vntag.dst", FT_UINT32, BASE_DEC, NULL, 0x3FFF0000, NULL, HFILL } }, { &hf_vntag_looped, - { "Looped", "vntag.looped", FT_UINT32, BASE_DEC, NULL, 0x00008000, NULL, HFILL } + { "Looped", "vntag.looped", FT_BOOLEAN, 32, TFS(&tfs_yes_no), 0x00008000, NULL, HFILL } }, { &hf_vntag_r, { "Reserved", "vntag.r", FT_UINT32, BASE_DEC, NULL, 0x00004000, NULL, HFILL } @@ -134,12 +141,9 @@ proto_register_vntag(void) { &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 } }, -#endif { &hf_vntag_trailer, { "Trailer", "vntag.trailer", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } } @@ -149,9 +153,17 @@ proto_register_vntag(void) &ett_vntag }; + static ei_register_info ei[] = { + { &ei_vntag_len, { "vntag.len.past_end", PI_MALFORMED, PI_ERROR, "Length field value goes past the end of the payload", EXPFILL }}, + }; + expert_module_t* expert_vntag; + proto_vntag = proto_register_protocol("VN-Tag", "VNTAG", "vntag"); proto_register_field_array(proto_vntag, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + expert_vntag = expert_register_protocol(proto_vntag); + expert_register_field_array(expert_vntag, ei, array_length(ei)); + } void @@ -159,8 +171,6 @@ proto_reg_handoff_vntag(void) { dissector_handle_t vntag_handle; - /* XXX, add 0x8926 define to epan/etypes.h && etype_vals */ - vntag_handle = create_dissector_handle(dissect_vntag, proto_vntag); dissector_add_uint("ethertype", ETHERTYPE_VNTAG, vntag_handle); |