epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-extreme-exeh.c
blobec7d5b6585ee5a83380669ee3b5fcc7746beae16
1 /* packet-extreme-internal-eth.c
2 * Routines for the disassembly of Extreme Networks internal
3 * Ethernet capture headers
5 * Copyright 2021 Joerg Mayer (see AUTHORS file)
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
15 * It is possible to create internal capture in EXOS with
16 * debug packet capture ...
18 * List of interfaces on all VRs:
19 * run script shell.py cat /proc/net/dev
20 * on older software the following should work as well:
21 * debug packet capture on cmd-args "-D -1"
23 * See:
24 * https://extremeportal.force.com/ExtrArticleDetail?an=000079573
25 * https://extremeportal.force.com/ExtrArticleDetail?an=000082238
26 * https://extremeportal.force.com/ExtrArticleDetail?an=000079220
28 * This capture begins with an internal header (maybe containing some HiGig variant?),
29 * followed by the "original" Ethernet frame.
33 * TODO
34 * 00 - 01: Unknown
35 * always zero for incoming(?)
36 * often non-zero for outgoing
37 * 10 - 23: Unknown (traffic properties?)
38 * 28 - 29: Unknown
39 * always zero(?)
40 * 32 - 33: Unknown
41 * always zero(?)
44 #include "config.h"
46 #include <epan/packet.h>
47 #include <epan/etypes.h>
48 #include <epan/expert.h>
49 #include <epan/tfs.h>
51 void proto_register_exeh(void);
52 void proto_reg_handoff_exeh(void);
54 static dissector_handle_t exeh_handle;
56 static dissector_handle_t ethnofcs_handle;
58 static int proto_exeh;
59 /* EXEH data */
60 static int hf_exeh_unknown_00_01;
61 static int hf_exeh_module1;
62 static int hf_exeh_port1;
63 static int hf_exeh_module2; /* m2 + p2 always zero for outgoing(?) */
64 static int hf_exeh_port2;
65 static int hf_exeh_unknown_10_16;
66 static int hf_exeh_unknown_17_0xfd;
67 static int hf_exeh_unknown_17_0x02;
68 static int hf_exeh_unknown_18_21;
69 static int hf_exeh_unknown_22_23;
70 static int hf_exeh_incoming_framesource;
71 static int hf_exeh_outgoing_framesource;
72 static int hf_exeh_vlan;
73 static int hf_exeh_unknown_28_29;
74 static int hf_exeh_dir;
75 static int hf_exeh_unknown_32_33;
76 static int hf_exeh_etype;
77 static int hf_exeh_etypelen;
78 static int hf_exeh_etypedata;
80 static expert_field ei_exeh_unexpected_value;
81 static expert_field ei_exeh_unequal_ports;
82 static expert_field ei_exeh_incoming_framesource;
83 static expert_field ei_exeh_outgoing_framesource;
85 static int ett_exeh;
87 #define PROTO_SHORT_NAME "EXEH"
88 #define PROTO_LONG_NAME "EXtreme extra Eth Header"
90 static const value_string exeh_direction_vals[] = {
91 {0x07, "Incoming"},
92 {0xff, "Outgoing"},
94 {0, NULL},
97 static const value_string exeh_outgoing_vlanid_vals[] = {
98 {0x0000, "No tag or VLAN ID = 0"},
99 {0x000f, "Has VLAN ID"},
101 {0, NULL},
104 static const value_string exeh_incoming_framesource_vals[] = {
105 {0x0000, "N/A"},
107 {0, NULL},
110 static const value_string exeh_outgoing_framesource_vals[] = {
111 {0x0000, "CPU"},
112 {0x4248, "Broadcom Hardware"},
114 {0, NULL},
118 static int
119 dissect_exeh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
121 proto_item *ti;
122 proto_tree *exeh_tree;
123 uint32_t offset = 0;
124 uint32_t etype, module1, port1, module2, port2, direction, framesource;
125 int32_t databytes;
126 tvbuff_t *frame_tvb;
128 col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_SHORT_NAME);
129 col_set_str(pinfo->cinfo, COL_INFO, PROTO_SHORT_NAME ":");
131 ti = proto_tree_add_item(tree, proto_exeh, tvb, offset, -1,
132 ENC_NA);
133 exeh_tree = proto_item_add_subtree(ti, ett_exeh);
135 direction = tvb_get_ntohs(tvb, 30);
136 proto_tree_add_item(exeh_tree, hf_exeh_unknown_00_01, tvb, offset, 2, ENC_NA);
137 offset += 2;
138 proto_tree_add_item_ret_uint(exeh_tree, hf_exeh_module1, tvb, offset, 2, ENC_BIG_ENDIAN, &module1);
139 offset += 2;
140 proto_tree_add_item_ret_uint(exeh_tree, hf_exeh_port1, tvb, offset, 2, ENC_BIG_ENDIAN, &port1);
141 offset += 2;
142 proto_tree_add_item_ret_uint(exeh_tree, hf_exeh_module2, tvb, offset, 2, ENC_BIG_ENDIAN, &module2);
143 offset += 2;
144 ti = proto_tree_add_item_ret_uint(exeh_tree, hf_exeh_port2, tvb, offset, 2, ENC_BIG_ENDIAN, &port2);
145 if ( !(direction == 255 && module2 == 0) && (module1 != module2 || port1 != port2) )
146 expert_add_info(pinfo, ti, &ei_exeh_unequal_ports);
147 offset += 2;
148 proto_tree_add_item(exeh_tree, hf_exeh_unknown_10_16, tvb, offset, 7, ENC_NA);
149 offset += 7;
150 proto_tree_add_item(exeh_tree, hf_exeh_unknown_17_0xfd, tvb, offset, 1, ENC_NA);
151 proto_tree_add_item(exeh_tree, hf_exeh_unknown_17_0x02, tvb, offset, 1, ENC_NA);
152 offset += 1;
153 proto_tree_add_item(exeh_tree, hf_exeh_unknown_18_21, tvb, offset, 4, ENC_NA);
154 offset += 4;
155 proto_tree_add_item(exeh_tree, hf_exeh_unknown_22_23, tvb, offset, 2, ENC_BIG_ENDIAN);
156 offset += 2;
157 if ( direction == 7 ) {
158 ti = proto_tree_add_item_ret_uint(exeh_tree, hf_exeh_incoming_framesource, tvb, offset, 2, ENC_BIG_ENDIAN, &framesource);
159 if ( framesource != 0 )
160 expert_add_info(pinfo, ti, &ei_exeh_incoming_framesource);
161 } else { /* Direction == 255 */
162 ti = proto_tree_add_item_ret_uint(exeh_tree, hf_exeh_outgoing_framesource, tvb, offset, 2, ENC_BIG_ENDIAN, &framesource);
163 if ( framesource != 0 && framesource != 0x4248 )
164 expert_add_info(pinfo, ti, &ei_exeh_outgoing_framesource);
166 offset += 2;
167 proto_tree_add_item(exeh_tree, hf_exeh_vlan, tvb, offset, 2, ENC_BIG_ENDIAN);
168 offset += 2;
169 proto_tree_add_item(exeh_tree, hf_exeh_unknown_28_29, tvb, offset, 2, ENC_NA);
170 offset += 2;
171 proto_tree_add_item(exeh_tree, hf_exeh_dir, tvb, offset, 2, ENC_BIG_ENDIAN);
172 offset += 2;
173 proto_tree_add_item(exeh_tree, hf_exeh_unknown_32_33, tvb, offset, 2, ENC_NA);
174 offset += 2;
175 proto_tree_add_item_ret_uint(exeh_tree, hf_exeh_etype, tvb, offset, 2, ENC_BIG_ENDIAN, &etype);
176 switch (etype) {
177 case 0x8100: /* VLAN/VMAN Tag */
178 ti = proto_tree_add_item_ret_int(exeh_tree, hf_exeh_etypelen, tvb, offset+2, 2, ENC_BIG_ENDIAN, &databytes);
179 if (tvb_reported_length_remaining(tvb, offset) != databytes)
180 expert_add_info(pinfo, ti, &ei_exeh_unexpected_value);
181 break;
182 default:
183 proto_tree_add_item(exeh_tree, hf_exeh_etypedata, tvb, offset+2, 2, ENC_BIG_ENDIAN);
185 offset += 4;
187 frame_tvb = tvb_new_subset_remaining(tvb, offset);
188 call_dissector(ethnofcs_handle, frame_tvb, pinfo, tree);
190 return tvb_captured_length(tvb);
193 void
194 proto_register_exeh(void)
196 static hf_register_info hf[] = {
198 /* EXEH data */
199 { &hf_exeh_unknown_00_01,
200 { "Unknown_00", "exeh.unknown00", FT_BYTES, BASE_NONE, NULL,
201 0x0, NULL, HFILL }},
203 { &hf_exeh_module1,
204 { "Module", "exeh.module1", FT_UINT16, BASE_DEC, NULL,
205 0x0, NULL, HFILL }},
207 { &hf_exeh_port1,
208 { "Port", "exeh.port1", FT_UINT16, BASE_DEC, NULL,
209 0x0, NULL, HFILL }},
211 { &hf_exeh_module2,
212 { "Module", "exeh.module2", FT_UINT16, BASE_DEC, NULL,
213 0x0, NULL, HFILL }},
215 { &hf_exeh_port2,
216 { "Port", "exeh.port2", FT_UINT16, BASE_DEC, NULL,
217 0x0, NULL, HFILL }},
219 { &hf_exeh_unknown_10_16,
220 { "Unknown_10 (incoming specific?)", "exeh.unknown10", FT_BYTES, BASE_NONE, NULL,
221 0x0, NULL, HFILL }},
223 { &hf_exeh_unknown_17_0xfd,
224 { "Unknown_17", "exeh.unknown17", FT_UINT8, BASE_HEX, NULL,
225 0xfd, NULL, HFILL }},
227 { &hf_exeh_unknown_17_0x02,
228 { "Unknown_17 (Add dot1Q?)", "exeh.unknown17.dot1q", FT_BOOLEAN, 8, TFS(&tfs_no_yes),
229 0x02, NULL, HFILL }},
231 { &hf_exeh_unknown_18_21,
232 { "Unknown_18 (outgoing specific?)", "exeh.unknown18", FT_BYTES, BASE_NONE, NULL,
233 0x0, NULL, HFILL }},
235 { &hf_exeh_unknown_22_23,
236 { "Add VLAN ID?", "exeh.unknown22", FT_UINT16, BASE_NONE, VALS(exeh_outgoing_vlanid_vals),
237 0x0, NULL, HFILL }},
239 { &hf_exeh_incoming_framesource,
240 { "Frame source", "exeh.framesource", FT_UINT16, BASE_HEX, VALS(exeh_incoming_framesource_vals),
241 0x0, NULL, HFILL }},
243 { &hf_exeh_outgoing_framesource,
244 { "Frame source", "exeh.framesource", FT_UINT16, BASE_HEX, VALS(exeh_outgoing_framesource_vals),
245 0x0, NULL, HFILL }},
247 { &hf_exeh_vlan,
248 { "Transport VLAN", "exeh.vlan", FT_UINT16, BASE_DEC, NULL,
249 0x0, NULL, HFILL }},
251 { &hf_exeh_unknown_28_29,
252 { "Unknown_28", "exeh.unknown28", FT_BYTES, BASE_NONE, NULL,
253 0x0, NULL, HFILL }},
255 { &hf_exeh_dir,
256 { "Direction", "exeh.direction", FT_UINT16, BASE_HEX, VALS(exeh_direction_vals),
257 0x0, NULL, HFILL }},
259 { &hf_exeh_unknown_32_33,
260 { "Unknown_32", "exeh.unknown32", FT_BYTES, BASE_NONE, NULL,
261 0x0, NULL, HFILL }},
263 { &hf_exeh_etype,
264 { "Etype", "exeh.etype", FT_UINT16, BASE_HEX, NULL,
265 0x0, NULL, HFILL }},
267 { &hf_exeh_etypedata,
268 { "Etype data", "exeh.etypedata", FT_UINT16, BASE_HEX, NULL,
269 0x0, NULL, HFILL }},
271 { &hf_exeh_etypelen,
272 { "Length", "exeh.etypelen", FT_INT16, BASE_DEC, NULL,
273 0x0, "Bytes from 8100 to end of frame", HFILL }},
277 static int *ett[] = {
278 &ett_exeh,
281 static ei_register_info ei[] = {
282 { &ei_exeh_unexpected_value, { "exeh.unexpected_value", PI_PROTOCOL, PI_WARN, "Unexpected length", EXPFILL }},
283 { &ei_exeh_unequal_ports, { "exeh.unequal_ports", PI_PROTOCOL, PI_WARN, "Unequal ports", EXPFILL }},
284 { &ei_exeh_incoming_framesource, { "exeh.incoming_framesource", PI_PROTOCOL, PI_WARN, "Incoming framesource non-zero", EXPFILL }},
285 { &ei_exeh_outgoing_framesource, { "exeh.outgoing_framesource", PI_PROTOCOL, PI_WARN, "Outgoing framesource unknown magic", EXPFILL }},
288 expert_module_t* expert_exeh;
290 proto_exeh = proto_register_protocol(PROTO_LONG_NAME, PROTO_SHORT_NAME, "exeh");
291 proto_register_field_array(proto_exeh, hf, array_length(hf));
292 proto_register_subtree_array(ett, array_length(ett));
293 expert_exeh = expert_register_protocol(proto_exeh);
294 expert_register_field_array(expert_exeh, ei, array_length(ei));
296 exeh_handle = register_dissector("exeh", dissect_exeh, proto_exeh);
299 void
300 proto_reg_handoff_exeh(void)
302 ethnofcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_exeh);
304 dissector_add_uint("ethertype", ETHERTYPE_EXEH, exeh_handle);
308 * Editor modelines - https://www.wireshark.org/tools/modelines.html
310 * Local variables:
311 * c-basic-offset: 8
312 * tab-width: 8
313 * indent-tabs-mode: t
314 * End:
316 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
317 * :indentSize=8:tabSize=8:noTabs=false: