/src/wireshark/epan/dissectors/packet-cisco-marker.c
Line | Count | Source |
1 | | /* packet-cisco-marker.c |
2 | | * Routines for CISCO's ERSPAN3 Marker Packet |
3 | | * See: http://www.cisco.com/c/en/us/products/collateral/switches/nexus-9000-series-switches/white-paper-c11-733921.html#_Toc413144488 |
4 | | * See: https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/93x/system-management/b-cisco-nexus-9000-series-nx-os-system-management-configuration-guide-93x/b-cisco-nexus-9000-series-nx-os-system-management-configuration-guide-93x_chapter_011110.html |
5 | | * Copyright 2015, Peter Membrey |
6 | | * |
7 | | * Wireshark - Network traffic analyzer |
8 | | * By Gerald Combs <gerald@wireshark.org> |
9 | | * Copyright 1998 Gerald Combs |
10 | | * |
11 | | * Copied from packet-time.c |
12 | | * Fixed with additional documentation from Cisco and real-life observations |
13 | | * by Stéphane Lapie <stephane.lapie@darkbsd.org> |
14 | | * |
15 | | * SPDX-License-Identifier: GPL-2.0-or-later |
16 | | */ |
17 | | #include "config.h" |
18 | | |
19 | | #include <epan/packet.h> |
20 | | |
21 | | void proto_register_erspan_marker(void); |
22 | | void proto_reg_handoff_erspan_marker(void); |
23 | | |
24 | | |
25 | | static dissector_handle_t marker_handle; |
26 | | |
27 | | static int proto_marker; |
28 | | |
29 | | static int hf_cisco_erspan_granularity; |
30 | | static int hf_cisco_erspan_info; |
31 | | static int hf_cisco_erspan_prop_header; |
32 | | static int hf_cisco_erspan_reserved; |
33 | | static int hf_cisco_erspan_sequence_number; |
34 | | static int hf_cisco_erspan_ssid; |
35 | | static int hf_cisco_erspan_tail; |
36 | | static int hf_cisco_erspan_timestamp; |
37 | | static int hf_cisco_erspan_type; |
38 | | static int hf_cisco_erspan_utc_sec; |
39 | | static int hf_cisco_erspan_utc_usec; |
40 | | static int hf_cisco_erspan_utcoffset; |
41 | | static int hf_cisco_erspan_version; |
42 | | |
43 | | |
44 | | static int ett_marker; |
45 | | |
46 | | |
47 | | static int |
48 | | dissect_marker(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
49 | 0 | { |
50 | 0 | proto_tree *marker_tree; |
51 | 0 | proto_item *ti; |
52 | |
|
53 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "CISCO ERSPAN3 MARKER"); |
54 | | |
55 | |
|
56 | 0 | if (tree) { |
57 | | |
58 | | /* Skip the proprietary CISCO header - no docs have been released for this */ |
59 | 0 | uint32_t offset = 20; |
60 | |
|
61 | 0 | ti = proto_tree_add_item(tree, proto_marker, tvb, 0, -1, ENC_NA); |
62 | 0 | marker_tree = proto_item_add_subtree(ti, ett_marker); |
63 | |
|
64 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_prop_header, tvb, 0, 20, ENC_NA); |
65 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_info, tvb, offset, 2, ENC_LITTLE_ENDIAN); |
66 | 0 | offset += 2; |
67 | |
|
68 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_version, tvb, offset, 2, ENC_BIG_ENDIAN); |
69 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_type, tvb, offset, 2, ENC_BIG_ENDIAN); |
70 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_ssid, tvb, offset, 2, ENC_BIG_ENDIAN); |
71 | 0 | offset += 2; |
72 | |
|
73 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_granularity, tvb, offset, 2, ENC_BIG_ENDIAN); |
74 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_utcoffset, tvb, offset, 2, ENC_BIG_ENDIAN); |
75 | 0 | offset+= 2; |
76 | | |
77 | | /* TODO: is this field really 6 bytes?? */ |
78 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_timestamp, tvb, offset, 8, ENC_BIG_ENDIAN); |
79 | 0 | offset+=8; |
80 | |
|
81 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_utc_sec, tvb, offset, 4, ENC_BIG_ENDIAN); |
82 | 0 | offset+=4; |
83 | |
|
84 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_utc_usec, tvb, offset, 4, ENC_BIG_ENDIAN); |
85 | 0 | offset+=4; |
86 | |
|
87 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_sequence_number, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
88 | 0 | offset+=4; |
89 | |
|
90 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_reserved, tvb, offset, 4, ENC_LITTLE_ENDIAN); |
91 | 0 | offset+=4; |
92 | |
|
93 | 0 | proto_tree_add_item(marker_tree, hf_cisco_erspan_tail, tvb, offset, 8, ENC_BIG_ENDIAN); |
94 | 0 | } |
95 | 0 | return tvb_captured_length(tvb); |
96 | 0 | } |
97 | | |
98 | | |
99 | | void |
100 | | proto_register_erspan_marker(void) |
101 | 16 | { |
102 | 16 | static hf_register_info hf[] = { |
103 | 16 | { &hf_cisco_erspan_prop_header, |
104 | 16 | { "Proprietary CISCO Header", "erspan-marker.prop_header", |
105 | 16 | FT_BYTES, BASE_NONE, NULL, 0x0, |
106 | 16 | NULL, HFILL } |
107 | 16 | }, |
108 | 16 | { &hf_cisco_erspan_info, |
109 | 16 | { "Header", "erspan-marker.header", |
110 | 16 | FT_BOOLEAN, BASE_NONE, NULL, 0x0, |
111 | 16 | NULL, HFILL } |
112 | 16 | }, |
113 | 16 | { &hf_cisco_erspan_version, |
114 | 16 | { "Version", "erspan-marker.version", |
115 | 16 | FT_UINT16, BASE_DEC, NULL, 0x0f00, |
116 | 16 | NULL, HFILL } |
117 | 16 | }, |
118 | 16 | { &hf_cisco_erspan_type, |
119 | 16 | { "Type", "erspan-marker.type", |
120 | 16 | FT_UINT16, BASE_DEC, NULL, 0xf000, |
121 | 16 | NULL, HFILL } |
122 | 16 | }, |
123 | 16 | { &hf_cisco_erspan_ssid, |
124 | 16 | { "SSID", "erspan-marker.ssid", |
125 | 16 | FT_UINT16, BASE_DEC, NULL, 0x00ff, |
126 | 16 | NULL, HFILL } |
127 | 16 | }, |
128 | 16 | { &hf_cisco_erspan_granularity, |
129 | 16 | { "Granularity", "erspan-marker.granularity", |
130 | 16 | FT_UINT16, BASE_DEC, NULL, 0xff00, |
131 | 16 | NULL, HFILL } |
132 | 16 | }, |
133 | 16 | { &hf_cisco_erspan_utcoffset, |
134 | 16 | { "UTC Offset", "erspan-marker.utc_offset", |
135 | 16 | FT_UINT16, BASE_DEC, NULL, 0x00ff, |
136 | 16 | NULL, HFILL } |
137 | 16 | }, |
138 | | /* Timestamp is actually a 48-bit value, packed across 2 32-bit integers |
139 | | * Timestamp_hi : 0000 ffff (high 16-bits) |
140 | | * Timestamp_lo : ffff ffff (low 32-bits) */ |
141 | 16 | { &hf_cisco_erspan_timestamp, |
142 | 16 | { "ASIC 48-bit Timestamp", "erspan-marker.timestamp", |
143 | 16 | FT_UINT48, BASE_DEC, NULL, 0xffffffffffff, |
144 | 16 | NULL, HFILL } |
145 | 16 | }, |
146 | | /* Comparison between the actual packet arrival time and this field |
147 | | * indicated that the Ethernet packet's arrival time was behind |
148 | | * the below field value by the value of the UTC offset |
149 | | * (37 seconds as of Nov 2021) */ |
150 | 16 | { &hf_cisco_erspan_utc_sec, |
151 | 16 | { "UTC Seconds", "erspan-marker.utc_sec", |
152 | 16 | FT_UINT32, BASE_DEC, NULL, 0x0, |
153 | 16 | NULL, HFILL } |
154 | 16 | }, |
155 | 16 | { &hf_cisco_erspan_utc_usec, |
156 | 16 | { "UTC Microseconds", "erspan-marker.utc_usec", |
157 | 16 | FT_UINT32, BASE_DEC, NULL, 0x0, |
158 | 16 | NULL, HFILL } |
159 | 16 | }, |
160 | 16 | { &hf_cisco_erspan_sequence_number, |
161 | 16 | { "Sequence Number", "erspan-marker.sequence_number", |
162 | 16 | FT_UINT32, BASE_DEC, NULL, 0x0, |
163 | 16 | NULL, HFILL } |
164 | 16 | }, |
165 | 16 | { &hf_cisco_erspan_reserved, |
166 | 16 | { "Reserved", "erspan-marker.reserved", |
167 | 16 | FT_UINT32, BASE_HEX, NULL, 0x0, |
168 | 16 | NULL, HFILL } |
169 | 16 | }, |
170 | | /* The 32-bit signature is expected to be 0xA5A5A5A5, |
171 | | * and while the Cisco documentation does not mention packing details, |
172 | | * it does mention padding values to enforce alignment */ |
173 | 16 | { &hf_cisco_erspan_tail, |
174 | 16 | { "TAIL", "erspan-marker.tail", |
175 | 16 | FT_UINT64, BASE_HEX, NULL, 0x00000000ffffffff, |
176 | 16 | NULL, HFILL } |
177 | 16 | }, |
178 | 16 | }; |
179 | | |
180 | 16 | static int *ett[] = { |
181 | 16 | &ett_marker, |
182 | 16 | }; |
183 | | |
184 | | |
185 | 16 | proto_marker = proto_register_protocol("CISCO ERSPAN3 Marker Packet", "CISCO3 ERSPAN MARKER", "erspan-marker"); |
186 | | |
187 | 16 | proto_register_field_array(proto_marker, hf, array_length(hf)); |
188 | 16 | proto_register_subtree_array(ett, array_length(ett)); |
189 | | |
190 | 16 | marker_handle = register_dissector("erspan-marker", dissect_marker, proto_marker); |
191 | 16 | } |
192 | | |
193 | | void |
194 | | proto_reg_handoff_erspan_marker(void) |
195 | 16 | { |
196 | 16 | dissector_add_for_decode_as_with_preference("udp.port", marker_handle); |
197 | 16 | } |
198 | | |
199 | | /* |
200 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
201 | | * |
202 | | * Local Variables: |
203 | | * c-basic-offset: 2 |
204 | | * tab-width: 8 |
205 | | * indent-tabs-mode: nil |
206 | | * End: |
207 | | * |
208 | | * ex: set shiftwidth=2 tabstop=8 expandtab: |
209 | | * :indentSize=2:tabSize=8:noTabs=true: |
210 | | */ |