MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / epan / dissectors / packet-vntag.c
blob37c9d677437be7ec3769bdec7e5121b572684c5b
1 /* packet-vntag.c
3 * $Id$
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "config.h"
26 #include <glib.h>
27 #include <epan/packet.h>
28 #include <epan/etypes.h>
30 static int proto_vntag = -1;
32 static int hf_vntag_etype = -1;
33 /* static int hf_vntag_len = -1; */
34 static int hf_vntag_trailer = -1;
36 static gint ett_vntag = -1;
38 static void
39 dissect_vntag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
41 guint16 encap_proto;
42 proto_tree *vntag_tree = NULL;
44 col_set_str(pinfo->cinfo, COL_PROTOCOL, "VNTAG");
45 col_clear(pinfo->cinfo, COL_INFO);
47 if (tree) {
48 proto_item *ti = proto_tree_add_item(tree, proto_vntag, tvb, 0, 4, ENC_NA);
50 vntag_tree = proto_item_add_subtree(ti, ett_vntag);
52 /* XXX, 4 bytes of data */
54 /* from scapy (http://hg.secdev.org/scapy-com/rev/37acec891993) GPLv2:
56 BitField("dir", 0, 1),
57 BitField("ptr", 0, 1),
58 BitField("dst", 0, 14),
59 BitField("looped", 0, 1),
60 BitField("r", 0, 1),
61 BitField("version", 0, 2),
62 BitField("src", 0, 12) ]
64 /* another: http://www.definethecloud.net/access-layer-network-virtualization-vn-tag-and-vepa */
67 encap_proto = tvb_get_ntohs(tvb, 4);
69 /* copied from packet-vlan.c do we need it also for VNTAG? */
70 #if 0
71 if (encap_proto <= IEEE_802_3_MAX_LEN) {
72 gboolean is_802_2;
74 /* Is there an 802.2 layer? I can tell by looking at the first 2
75 bytes after the VLAN header. If they are 0xffff, then what
76 follows the VLAN header is an IPX payload, meaning no 802.2.
77 (IPX/SPX is they only thing that can be contained inside a
78 straight 802.3 packet, so presumably the same applies for
79 Ethernet VLAN packets). A non-0xffff value means that there's an
80 802.2 layer inside the VLAN layer */
81 is_802_2 = TRUE;
83 /* Don't throw an exception for this check (even a BoundsError) */
84 if (tvb_length_remaining(tvb, 4) >= 2) {
85 if (tvb_get_ntohs(tvb, 4) == 0xffff)
86 is_802_2 = FALSE;
89 dissect_802_3(encap_proto, is_802_2, tvb, 4, pinfo, tree, vntag_tree, hf_vntag_len, hf_vntag_trailer, 0);
90 } else
91 #endif
92 ethertype(encap_proto, tvb, 6, pinfo, tree, vntag_tree, hf_vntag_etype, hf_vntag_trailer, 0);
95 void
96 proto_register_vntag(void)
98 static hf_register_info hf[] = {
99 { &hf_vntag_etype,
100 { "Type", "vntag.etype", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, NULL, HFILL }
102 #if 0
103 { &hf_vntag_len,
104 { "Length", "vntag.len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
106 #endif
107 { &hf_vntag_trailer,
108 { "Trailer", "vntag.trailer", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
112 static gint *ett[] = {
113 &ett_vntag
116 proto_vntag = proto_register_protocol("VN-Tag", "VNTAG", "vntag");
117 proto_register_field_array(proto_vntag, hf, array_length(hf));
118 proto_register_subtree_array(ett, array_length(ett));
121 void
122 proto_reg_handoff_vntag(void)
124 dissector_handle_t vntag_handle;
126 /* XXX, add 0x8926 define to epan/etypes.h && etype_vals */
128 vntag_handle = create_dissector_handle(dissect_vntag, proto_vntag);
129 dissector_add_uint("ethertype", 0x8926, vntag_handle);