2 * Routines for the disassembly of Cisco's ERSPAN protocol
6 * Copyright 2005 Joerg Mayer (see AUTHORS file)
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 * Find out the Unknown values
32 * No real specs exist. Some general description can be found at:
33 * http://www.cisco.com/en/US/products/hw/routers/ps368/products_configuration_guide_chapter09186a008069952a.html
35 * For ERSPAN packets, the "protocol type" field value in the GRE header
38 * 0000000: d4c3 b2a1 0200 0400 0000 0000 0000 0000 <-- pcap header
40 * 0000010: 7100 0000 <-- 0x71 (DLT_TYPE) = linux_cooked_capture (of course not)
41 * 0000010: 7507 f845 11d1 0500 <-- pcap record header
42 * 0000020: 7a00 0000 7a00 0000
43 * 0000020: 0000 030a 0000 0000 <-- unknown
45 * 0000030: 0000 88be <-- GRE header
46 * 0000030: 1002 0001 0000 0380 <-- ERSPAN header (01: erspan-id)
47 * 0000040: 00d0 b7a7 7480 0015 c721 75c0 0800 4500 <-- Ethernet packet
58 #include <epan/packet.h>
59 #include <epan/greproto.h>
61 static int proto_erspan = -1;
63 static gint ett_erspan = -1;
65 static int hf_erspan_unknown1 = -1;
66 static int hf_erspan_vlan = -1;
67 static int hf_erspan_priority = -1;
68 static int hf_erspan_unknown2 = -1;
69 static int hf_erspan_direction = -1;
70 static int hf_erspan_unknown3 = -1;
71 static int hf_erspan_spanid = -1;
72 static int hf_erspan_unknown4 = -1;
74 #define PROTO_SHORT_NAME "ERSPAN"
75 #define PROTO_LONG_NAME "ER Switch Packet Analysis"
77 #define ERSPAN_DIRECTION_INCOMING 0
78 #define ERSPAN_DIRECTION_OUTGOING 1
79 static const value_string erspan_direction_vals[] = {
80 {ERSPAN_DIRECTION_INCOMING, "Incoming"},
81 {ERSPAN_DIRECTION_OUTGOING, "Outgoing"},
85 static dissector_handle_t ethnofcs_handle;
88 dissect_erspan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
91 proto_tree *erspan_tree = NULL;
95 if (check_col(pinfo->cinfo, COL_PROTOCOL))
96 col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_SHORT_NAME);
97 if (check_col(pinfo->cinfo, COL_INFO))
98 col_set_str(pinfo->cinfo, COL_INFO, PROTO_SHORT_NAME ":");
101 ti = proto_tree_add_item(tree, proto_erspan, tvb, offset, -1,
103 erspan_tree = proto_item_add_subtree(ti, ett_erspan);
105 proto_tree_add_item(erspan_tree, hf_erspan_unknown1, tvb, offset, 2,
108 proto_tree_add_item(erspan_tree, hf_erspan_vlan, tvb, offset, 2,
112 proto_tree_add_item(erspan_tree, hf_erspan_priority, tvb, offset, 2,
115 proto_tree_add_item(erspan_tree, hf_erspan_unknown2, tvb, offset, 2,
118 proto_tree_add_item(erspan_tree, hf_erspan_direction, tvb, offset, 2,
121 proto_tree_add_item(erspan_tree, hf_erspan_unknown3, tvb, offset, 2,
124 proto_tree_add_item(erspan_tree, hf_erspan_spanid, tvb, offset, 2,
128 proto_tree_add_item(erspan_tree, hf_erspan_unknown4, tvb, offset, 4,
136 eth_tvb = tvb_new_subset_remaining(tvb, offset);
137 call_dissector(ethnofcs_handle, eth_tvb, pinfo, tree);
141 proto_register_erspan(void)
143 static hf_register_info hf[] = {
145 { &hf_erspan_unknown1,
146 { "Unknown1", "erspan.unknown1", FT_UINT16, BASE_HEX, NULL,
147 0xf000, NULL, HFILL }},
150 { "Vlan", "erspan.vlan", FT_UINT16, BASE_DEC, NULL,
151 0x0fff, NULL, HFILL }},
153 { &hf_erspan_priority,
154 { "Priority", "erspan.priority", FT_UINT16, BASE_DEC, NULL,
155 0xe000, NULL, HFILL }},
157 { &hf_erspan_unknown2,
158 { "Unknown2", "erspan.unknown2", FT_UINT16, BASE_DEC, NULL,
159 0x1000, NULL, HFILL }},
161 { &hf_erspan_direction,
162 { "Direction", "erspan.direction", FT_UINT16, BASE_DEC, VALS(erspan_direction_vals),
163 0x0800, NULL, HFILL }},
165 { &hf_erspan_unknown3,
166 { "Unknown3", "erspan.unknown3", FT_UINT16, BASE_DEC, NULL,
167 0x0400, NULL, HFILL }},
170 { "SpanID", "erspan.spanid", FT_UINT16, BASE_DEC, NULL,
171 0x03ff, NULL, HFILL }},
173 { &hf_erspan_unknown4,
174 { "Unknown4", "erspan.unknown4", FT_BYTES, BASE_NONE, NULL,
178 static gint *ett[] = {
182 proto_erspan = proto_register_protocol(PROTO_LONG_NAME,
183 PROTO_SHORT_NAME, "erspan");
184 proto_register_field_array(proto_erspan, hf, array_length(hf));
185 proto_register_subtree_array(ett, array_length(ett));
189 proto_reg_handoff_erspan(void)
191 dissector_handle_t erspan_handle;
193 ethnofcs_handle = find_dissector("eth_withoutfcs");
195 erspan_handle = create_dissector_handle(dissect_erspan, proto_erspan);
196 dissector_add("gre.proto", GRE_ERSPAN, erspan_handle);