1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
/* packet-vssmonitoring.c
* Routines for dissection of VSS Monitoring timestamp and portstamp
*
* Copyright VSS Monitoring 2011
*
* 20111205 - First edition by Sake Blok (sake.blok@SYN-bit.nl)
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
#include <epan/prefs.h>
#define VSS_NS_MASK 0x3fffffff
#define CLKSRC_SHIFT 30
#define CLKSRC_LOCAL 0
#define CLKSRC_NTP 1
#define CLKSRC_GPS 2
#define CLKSRC_PTP 3
static const value_string clksrc_vals[] = {
{ CLKSRC_LOCAL, "Not Synced" },
{ CLKSRC_NTP, "NTP" },
{ CLKSRC_GPS, "GPS" },
{ CLKSRC_PTP, "PTP" },
{ 0, NULL }
};
void proto_register_vssmonitoring(void);
void proto_reg_handoff_vssmonitoring(void);
static int proto_vssmonitoring = -1;
static int hf_vssmonitoring_time = -1;
static int hf_vssmonitoring_clksrc = -1;
static int hf_vssmonitoring_srcport = -1;
static gint ett_vssmonitoring = -1;
static gboolean vss_dissect_portstamping_only = FALSE;
static gboolean vss_two_byte_portstamps = FALSE;
static int
dissect_vssmonitoring(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
proto_tree *ti = NULL;
proto_tree *vssmonitoring_tree = NULL;
guint offset = 0;
guint trailer_len;
guint portstamp_len = (vss_two_byte_portstamps) ? 2 : 1;
nstime_t vssmonitoring_time;
guint8 vssmonitoring_clksrc = 0;
guint32 vssmonitoring_srcport = 0;
struct tm *tmp;
/* First get the length of the trailer */
trailer_len = tvb_reported_length(tvb);
/* The trailer length is a sum (of any combination) of:
* timestamp (8 bytes)
* port stamp (1 or 2 bytes)
* fcs (4 bytes)
*
* Our caller might pass in the trailer with FCS included, so we check for
* a trailer with a length that includes one or more of a time stamp,
* a 1-byte or 2-byte port stamp, and optionally an FCS.
*
* See
*
* https://web.archive.org/web/20160402091604/http://www.vssmonitoring.com/resources/feature-brief/Port-and-Time-Stamping.pdf
*
* which speaks of 2-byte port stamps as being for a "future release".
*
* Iris Packet Broker user manuals when VSS Monitoring was owned by
* Tektronix also mentioned only a 1-byte port stamp.
*
* VSS Monitoring has since been acquired by NetScout.
* Products released in 2019:
* https://www.netscout.com/sites/default/files/2019-01/PFSPDS_002_EN-1803-nGenius-4200-Series-Packet-Flow-Switch.pdf
* https://www.netscout.com/sites/default/files/2019-12/PFSPDS_003_EN-1901%20-%20nGenius%206010%20Packet%20Flow%20Switch.pdf
* mention both Port Stamping and VLAN tagging under "traffic port tagging,"
* and also note separately that up to _256_ ports can be meshed together
* across hardware to act as a single device.
*
* Products released in 2021:
* https://www.netscout.com/sites/default/files/2021-07/PFSPDS_021_EN-2102%20-%20nGenius%207000%20Series%20Packet%20Flow%20Switches.pdf
* https://www.netscout.com/sites/default/files/2021-07/PFSPDS_022_EN-2102%20-%20nGenius%205000%20Series%20Packet%20Flow%20Switches.pdf
* mention only VLAN tagging, and not Port Stamping in the port tagging
* feature section.
*
* VSS Monitoring has apparently never released a product with 2 byte
* port stamps, and it seems going forward that port stamping is going
* to be deprecrated in favor of VLAN tagging.
*
* So by default we'll assume port stamps are 1 byte, with 2 bytes
* port stamps supported via preference (disabled by default.)
*
* This means a trailer length must not be more than 14 bytes,
* and:
*
* must not be 3 modulo 4 (as it can't have both a 1-byte
* and a 2-byte port stamp);
*
* can only be either 1 or 2 module 4, depending on the size
* of port stamp we accept;
*
* if it's less than 8 bytes, must not be 0 modulo 4 (as
* it must have a 1-byte or 2-byte port stamp, given that
* it has no timestamp).
*/
if ( trailer_len > 12 + portstamp_len )
return 0;
if ( (trailer_len & 3) != 0 && (trailer_len & 3) != portstamp_len )
return 0;
/*
* If we have a time stamp, check it for validity.
*/
if ( trailer_len >= 8 ) {
vssmonitoring_time.secs = tvb_get_ntohl(tvb, offset);
vssmonitoring_time.nsecs = tvb_get_ntohl(tvb, offset + 4);
vssmonitoring_clksrc = (guint8)(((guint32)vssmonitoring_time.nsecs) >> CLKSRC_SHIFT);
vssmonitoring_time.nsecs &= VSS_NS_MASK;
/* Probably padding passed to this dissector (e.g., a 802.1Q tagged
* packet where the minimum frame length was increased to account
* for the tag, see IEEE Std 802.1Q-2014 G.2.3 "Minimum PDU Size")
* FIXME: Should be made even stricter.
*/
if (vssmonitoring_time.secs == 0)
return 0;
/* The timestamp will be based on the uptime until the TAP is completely
* booted, this takes about 60s, but use 1 hour to be sure
*/
if (vssmonitoring_time.secs > 3600) {
/* Check whether the timestamp in the PCAP header and the VSS-Monitoring
* differ less than 30 days, otherwise, this might not be a VSS-Monitoring
* timestamp
*/
if ( vssmonitoring_time.secs > pinfo->abs_ts.secs ) {
if ( vssmonitoring_time.secs - pinfo->abs_ts.secs > 2592000 ) /* 30 days */
return 0;
} else {
if ( pinfo->abs_ts.secs - vssmonitoring_time.secs > 2592000 ) /* 30 days */
return 0;
}
}
/* The nanoseconds field should be less than 1000000000
*/
if ( vssmonitoring_time.nsecs >= 1000000000 )
return 0;
} else if (!vss_dissect_portstamping_only || (trailer_len & 3) == 0) {
/* No timestamp, so we need a port stamp and be willing to accept
* packets with port stamping but not time stamping.
*
* Unfortunately, the port stamp can be zero or any other value, so
* this means that a one-byte or two-byte all-zero trailer that's just
* padding can be misinterpreted as a VSS monitoring trailer, among
* other false positives, so we disable that by default.
*/
return 0;
}
/* All systems are go, lets dissect the VSS-Monitoring trailer */
if (tree) {
ti = proto_tree_add_item(tree, proto_vssmonitoring,
tvb, 0, (trailer_len & 0xb), ENC_NA);
vssmonitoring_tree = proto_item_add_subtree(ti, ett_vssmonitoring);
}
/* Do we have a timestamp? */
if ( trailer_len >= 8 ) {
if (tree) {
proto_tree_add_time(vssmonitoring_tree, hf_vssmonitoring_time, tvb, offset, 8, &vssmonitoring_time);
proto_tree_add_uint(vssmonitoring_tree, hf_vssmonitoring_clksrc, tvb, offset + 4, 1, vssmonitoring_clksrc);
tmp = localtime(&vssmonitoring_time.secs);
if (tmp)
proto_item_append_text(ti, ", Timestamp: %02d:%02d:%02d.%09ld",
tmp->tm_hour, tmp->tm_min, tmp->tm_sec,(long)vssmonitoring_time.nsecs);
else
proto_item_append_text(ti, ", Timestamp: <Not representable>");
}
offset += 8;
}
/* Do we have a port stamp? */
if ( (trailer_len & 3) == portstamp_len) {
if (tree) {
proto_tree_add_item_ret_uint(vssmonitoring_tree, hf_vssmonitoring_srcport, tvb, offset, portstamp_len, ENC_BIG_ENDIAN, &vssmonitoring_srcport);
proto_item_append_text(ti, ", Source Port: %d", vssmonitoring_srcport);
}
offset += portstamp_len;
}
return offset;
}
void
proto_register_vssmonitoring(void)
{
static hf_register_info hf[] = {
{ &hf_vssmonitoring_time, {
"Time Stamp", "vssmonitoring.time",
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
"VSS Monitoring Time Stamp", HFILL }},
{ &hf_vssmonitoring_clksrc, {
"Clock Source", "vssmonitoring.clksrc",
FT_UINT8, BASE_DEC, VALS(clksrc_vals), 0x0,
"VSS Monitoring Clock Source", HFILL }},
{ &hf_vssmonitoring_srcport, {
"Src Port", "vssmonitoring.srcport",
FT_UINT16, BASE_DEC, NULL, 0x0,
"VSS Monitoring Source Port", HFILL }}
};
static gint *ett[] = {
&ett_vssmonitoring
};
module_t *vssmonitoring_module;
proto_vssmonitoring = proto_register_protocol("VSS Monitoring Ethernet trailer", "VSS Monitoring", "vssmonitoring");
proto_register_field_array(proto_vssmonitoring, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
vssmonitoring_module = prefs_register_protocol(proto_vssmonitoring, NULL);
prefs_register_obsolete_preference(vssmonitoring_module, "use_heuristics");
prefs_register_bool_preference(vssmonitoring_module, "dissect_portstamping_only",
"Dissect trailers with only port stamping",
"Whether the VSS Monitoring dissector should attempt to dissect trailers with no timestamp, only port stamping. Note that this can result in a large number of false positives.",
&vss_dissect_portstamping_only);
prefs_register_bool_preference(vssmonitoring_module, "two_byte_portstamps",
"Two byte port stamps",
"Whether the VSS Monitoring dissector should assume that the port stamp is two bytes, instead of the standard one byte.",
&vss_two_byte_portstamps);
}
void
proto_reg_handoff_vssmonitoring(void)
{
heur_dissector_add("eth.trailer", dissect_vssmonitoring, "VSS Monitoring ethernet trailer", "vssmonitoring_eth", proto_vssmonitoring, HEURISTIC_ENABLE);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 2
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=2 tabstop=8 expandtab:
* :indentSize=2:tabSize=8:noTabs=true:
*/
|