3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include <epan/packet.h>
13 #include <epan/etypes.h>
14 #include <epan/expert.h>
16 #include "packet-ieee8023.h"
18 void proto_register_vntag(void);
19 void proto_reg_handoff_vntag(void);
21 static dissector_handle_t vntag_handle
;
22 static dissector_handle_t ethertype_handle
;
24 static int proto_vntag
;
26 static int hf_vntag_etype
;
27 static int hf_vntag_dir
;
28 static int hf_vntag_ptr
;
29 static int hf_vntag_dst
;
30 static int hf_vntag_looped
;
31 static int hf_vntag_r
;
32 static int hf_vntag_version
;
33 static int hf_vntag_src
;
34 static int hf_vntag_len
;
35 static int hf_vntag_trailer
;
39 static expert_field ei_vntag_len
;
41 static const true_false_string vntag_dir_tfs
= {
45 static const true_false_string vntag_ptr_tfs
= {
51 dissect_vntag(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
54 proto_tree
*vntag_tree
= NULL
;
55 ethertype_data_t ethertype_data
;
58 https://d2zmdbbm9feqrf.cloudfront.net/2012/usa/pdf/BRKDCT-2340.pdf p.61
59 http://www.definethecloud.net/access-layer-network-virtualization-vn-tag-and-vepa
61 static int * const fields
[] = {
72 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "VNTAG");
73 col_clear(pinfo
->cinfo
, COL_INFO
);
76 proto_item
*ti
= proto_tree_add_item(tree
, proto_vntag
, tvb
, 0, 4, ENC_NA
);
77 vntag_tree
= proto_item_add_subtree(ti
, ett_vntag
);
79 proto_tree_add_bitmask_list(vntag_tree
, tvb
, 0, 4, fields
, ENC_BIG_ENDIAN
);
82 encap_proto
= tvb_get_ntohs(tvb
, 4);
84 /* VNTAG may also carry 802.2 encapsulated data */
85 if (encap_proto
<= IEEE_802_3_MAX_LEN
) {
88 /* Is there an 802.2 layer? I can tell by looking at the first 2
89 bytes after the VLAN header. If they are 0xffff, then what
90 follows the VLAN header is an IPX payload, meaning no 802.2.
91 (IPX/SPX is they only thing that can be contained inside a
92 straight 802.3 packet, so presumably the same applies for
93 Ethernet VLAN packets). A non-0xffff value means that there's an
94 802.2 layer inside the VLAN layer */
97 /* Don't throw an exception for this check (even a BoundsError) */
98 if (tvb_captured_length_remaining(tvb
, 6) >= 2) {
99 if (tvb_get_ntohs(tvb
, 6) == 0xffff)
103 dissect_802_3(encap_proto
, is_802_2
, tvb
, 6, pinfo
, tree
, vntag_tree
, hf_vntag_len
, hf_vntag_trailer
, &ei_vntag_len
, 0);
105 proto_tree_add_uint(vntag_tree
, hf_vntag_etype
, tvb
, 4, 2,
108 ethertype_data
.etype
= encap_proto
;
109 ethertype_data
.payload_offset
= 6;
110 ethertype_data
.fh_tree
= vntag_tree
;
111 ethertype_data
.trailer_id
= hf_vntag_trailer
;
112 ethertype_data
.fcs_len
= 0;
114 call_dissector_with_data(ethertype_handle
, tvb
, pinfo
, tree
, ðertype_data
);
116 return tvb_captured_length(tvb
);
120 proto_register_vntag(void)
122 static hf_register_info hf
[] = {
124 { "Type", "vntag.etype", FT_UINT16
, BASE_HEX
, VALS(etype_vals
), 0x0, NULL
, HFILL
}
127 { "Direction", "vntag.dir", FT_BOOLEAN
, 32, TFS(&vntag_dir_tfs
), 0x80000000, NULL
, HFILL
}
130 { "Pointer", "vntag.ptr", FT_BOOLEAN
, 32, TFS(&vntag_ptr_tfs
), 0x40000000, NULL
, HFILL
}
133 { "Destination", "vntag.dst", FT_UINT32
, BASE_DEC
, NULL
, 0x3FFF0000, NULL
, HFILL
}
136 { "Looped", "vntag.looped", FT_BOOLEAN
, 32, TFS(&tfs_yes_no
), 0x00008000, NULL
, HFILL
}
139 { "Reserved", "vntag.r", FT_UINT32
, BASE_DEC
, NULL
, 0x00004000, NULL
, HFILL
}
142 { "Version", "vntag.version", FT_UINT32
, BASE_DEC
, NULL
, 0x00003000, NULL
, HFILL
}
145 { "Source", "vntag.src", FT_UINT32
, BASE_DEC
, NULL
, 0x00000FFF, NULL
, HFILL
}
148 { "Length", "vntag.len", FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}
151 { "Trailer", "vntag.trailer", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
155 static int *ett
[] = {
159 static ei_register_info ei
[] = {
160 { &ei_vntag_len
, { "vntag.len.past_end", PI_MALFORMED
, PI_ERROR
, "Length field value goes past the end of the payload", EXPFILL
}},
162 expert_module_t
* expert_vntag
;
164 proto_vntag
= proto_register_protocol("VN-Tag", "VNTAG", "vntag");
165 proto_register_field_array(proto_vntag
, hf
, array_length(hf
));
166 proto_register_subtree_array(ett
, array_length(ett
));
167 expert_vntag
= expert_register_protocol(proto_vntag
);
168 expert_register_field_array(expert_vntag
, ei
, array_length(ei
));
169 vntag_handle
= register_dissector("vntag", dissect_vntag
, proto_vntag
);
173 proto_reg_handoff_vntag(void)
175 dissector_add_uint("ethertype", ETHERTYPE_VNTAG
, vntag_handle
);
177 ethertype_handle
= find_dissector_add_dependency("ethertype", proto_vntag
);
181 * Editor modelines - https://www.wireshark.org/tools/modelines.html
186 * indent-tabs-mode: t
189 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
190 * :indentSize=8:tabSize=8:noTabs=false: