HACK: 2nd try to match RowsetProperties
[wireshark-wip.git] / epan / dissectors / packet-vmlab.c
blob7eec47b5e93358cb3aa94a0863a320017ba98e47
1 /* packet-vmlab.c
2 * Routines for VMware Lab Manager Frame Dis-assembly
4 * $Id$
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 /* History
28 * Apr 4, 2010 - David Aggeler
30 * - Initial version based on packet-vlan.c
32 * VMware Lab Manager is using this encapsulation directly as Ethernet Frames
33 * or inside VLANs. The Ethernet type was originally registered to Akimbi, but VMware
34 * acquired this company in 2006. No public information found, so the decoding here
35 * is an educated guess. Since one of the features of Lab Manager is to separate
36 * VMs with equal host name, IP and MAC Address, I expect the upper layer dissectors
37 * (namely ARP, ICMP, IP, TCP) to create false alerts, since identical configurations
38 * may communicate at the same time. The main goal of this dissector is to be able
39 * to troubleshoot connectivity, preferably pings. It's also a little to understand
40 * as to how host spanning fenced configurations actually talk.
44 #include "config.h"
46 #include <glib.h>
47 #include <epan/addr_resolv.h>
48 #include <epan/packet.h>
49 #include <epan/etypes.h>
51 static int proto_vmlab = -1;
53 static int hf_vmlab_flags_part1 = -1; /* Unknown so far */
54 static int hf_vmlab_flags_fragment = -1;
55 static int hf_vmlab_flags_part2 = -1; /* Unknown so far */
57 static int hf_vmlab_portgroup = -1;
58 static int hf_vmlab_eth_src = -1;
59 static int hf_vmlab_eth_dst = -1;
60 static int hf_vmlab_eth_addr = -1;
61 static int hf_vmlab_etype = -1;
62 static int hf_vmlab_trailer = -1;
64 static gint ett_vmlab = -1;
66 static const value_string fragment_vals[] = {
67 { 0, "Not set" },
68 { 1, "Set" },
69 { 0, NULL }
72 static void
73 dissect_vmlab(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
76 proto_tree* volatile vmlab_tree;
77 proto_item* ti;
79 guint32 offset=0;
81 const guint8* src_addr;
82 const guint8* dst_addr;
83 guint8 attributes;
84 guint8 portgroup;
86 volatile guint16 encap_proto;
88 col_set_str(pinfo->cinfo, COL_PROTOCOL, "VMLAB");
89 col_clear(pinfo->cinfo, COL_INFO);
91 ti = proto_tree_add_item(tree, proto_vmlab, tvb, 0, 24, ENC_NA);
92 vmlab_tree = proto_item_add_subtree(ti, ett_vmlab);
94 /* Flags*/
95 attributes = tvb_get_guint8(tvb, offset);
96 proto_tree_add_item(vmlab_tree, hf_vmlab_flags_part1, tvb, offset, 1, ENC_BIG_ENDIAN);
97 proto_tree_add_item(vmlab_tree, hf_vmlab_flags_fragment, tvb, offset, 1, ENC_BIG_ENDIAN);
98 proto_tree_add_item(vmlab_tree, hf_vmlab_flags_part2, tvb, offset, 1, ENC_BIG_ENDIAN);
99 if (attributes & 0x04) {
100 proto_item_append_text(ti, ", Fragment");
102 offset += 1;
104 /* Portgroup*/
105 portgroup = tvb_get_guint8(tvb, offset);
106 proto_tree_add_uint(vmlab_tree, hf_vmlab_portgroup, tvb, offset, 1, portgroup);
107 proto_item_append_text(ti, ", Portgroup: %d", portgroup);
108 offset += 1;
110 /* The next two bytes were always 0x0000 as far as I could tell*/
111 offset += 2;
113 /* Not really clear, what the difference between this and the next MAC address is
114 Both are usually equal*/
115 proto_tree_add_item(vmlab_tree, hf_vmlab_eth_addr, tvb, offset, 6, ENC_NA);
116 offset += 6;
118 dst_addr=tvb_get_ptr(tvb, offset, 6);
119 proto_tree_add_item(vmlab_tree, hf_vmlab_eth_dst, tvb, offset, 6, ENC_NA);
120 offset += 6;
122 /* Source MAC*/
123 src_addr=tvb_get_ptr(tvb, offset, 6);
124 proto_tree_add_item(vmlab_tree, hf_vmlab_eth_src, tvb, offset, 6, ENC_NA);
125 offset += 6;
127 proto_item_append_text(ti, ", Src: %s (%s), Dst: %s (%s)",
128 get_ether_name(src_addr), ether_to_str(src_addr), get_ether_name(dst_addr), ether_to_str(dst_addr));
130 /* Encapsulated Ethertype is also part of the block*/
131 encap_proto = tvb_get_ntohs(tvb, offset);
132 offset += 2;
134 /* Now call whatever was encapsulated*/
135 ethertype(encap_proto, tvb, offset, pinfo, tree, vmlab_tree, hf_vmlab_etype, hf_vmlab_trailer, 0);
139 void
140 proto_register_vmlab(void)
142 static hf_register_info hf[] = {
144 { &hf_vmlab_flags_part1, { "Unknown", "vmlab.unknown1",
145 FT_UINT8, BASE_HEX, NULL, 0xF8, NULL, HFILL }},
146 { &hf_vmlab_flags_fragment, { "More Fragments", "vmlab.fragment",
147 FT_UINT8, BASE_DEC, VALS(fragment_vals), 0x04, NULL, HFILL }},
148 { &hf_vmlab_flags_part2, { "Unknown", "vmlab.unknown2",
149 FT_UINT8, BASE_HEX, NULL, 0x03, NULL, HFILL }},
151 { &hf_vmlab_portgroup, { "Portgroup", "vmlab.pgrp",
152 FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL }},
153 { &hf_vmlab_eth_src, { "Source", "vmlab.src",
154 FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
155 { &hf_vmlab_eth_dst, { "Destination", "vmlab.dst",
156 FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
157 { &hf_vmlab_eth_addr, { "Address", "vmlab.addr",
158 FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }},
159 { &hf_vmlab_etype, { "Encapsulated Type", "vmlab.subtype",
160 FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, NULL, HFILL }},
161 { &hf_vmlab_trailer, { "Trailer", "vmlab.trailer",
162 FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}
164 static gint *ett[] = {
165 &ett_vmlab
168 proto_vmlab = proto_register_protocol("VMware Lab Manager", "VMLAB", "vmlab");
169 proto_register_field_array(proto_vmlab, hf, array_length(hf));
170 proto_register_subtree_array(ett, array_length(ett));
173 void
174 proto_reg_handoff_vmlab(void)
176 dissector_handle_t vmlab_handle;
178 vmlab_handle = create_dissector_handle(dissect_vmlab, proto_vmlab);
180 dissector_add_uint("ethertype", ETHERTYPE_VMLAB, vmlab_handle);