Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-netperfmeter.c
blob543703b338356571cbce962062d3542786246c14
1 /* packet-netperfmeter.c
2 * Routines for the NetPerfMeter protocol used by the Open Source
3 * network performance meter application NetPerfMeter:
4 * https://www.uni-due.de/~be0001/netperfmeter/
6 * Copyright 2009-2021 by Thomas Dreibholz <dreibh [AT] iem.uni-due.de>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * Copied from README.developer
14 * SPDX-License-Identifier: GPL-2.0-or-later
17 #include "config.h"
19 #include <epan/packet.h>
20 #include <epan/sctpppids.h>
21 #include <epan/stat_tap_ui.h>
22 #include <epan/tfs.h>
24 #include <wsutil/array.h>
26 void proto_register_npm(void);
27 void proto_reg_handoff_npm(void);
29 static dissector_handle_t npm_handle;
31 static int proto_npm;
32 static int tap_npm = -1;
33 static int ett_npm;
34 static int ett_addflow_flags;
35 static int ett_identifyflow_flags;
36 static int ett_start_flags;
37 static int ett_data_flags;
38 static int ett_results_flags;
39 static int ett_onoffarray;
41 static uint64_t npm_total_msgs;
42 static uint64_t npm_total_bytes;
45 #define PPID_NETPERFMETER_CONTROL_LEGACY 0x29097605
46 #define PPID_NETPERFMETER_DATA_LEGACY 0x29097606
49 /* Initialize the protocol and registered fields */
51 #define NETPERFMETER_ACKNOWLEDGE 0x01
52 #define NETPERFMETER_ADD_FLOW 0x02
53 #define NETPERFMETER_REMOVE_FLOW 0x03
54 #define NETPERFMETER_IDENTIFY_FLOW 0x04
55 #define NETPERFMETER_DATA 0x05
56 #define NETPERFMETER_START 0x06
57 #define NETPERFMETER_STOP 0x07
58 #define NETPERFMETER_RESULTS 0x08
60 static const value_string message_type_values[] = {
61 { NETPERFMETER_ACKNOWLEDGE, "NetPerfMeter Acknowledge" },
62 { NETPERFMETER_ADD_FLOW, "NetPerfMeter Add Flow" },
63 { NETPERFMETER_REMOVE_FLOW, "NetPerfMeter Remove Flow" },
64 { NETPERFMETER_IDENTIFY_FLOW, "NetPerfMeter Identify Flow" },
65 { NETPERFMETER_DATA, "NetPerfMeter Data" },
66 { NETPERFMETER_START, "NetPerfMeter Start Measurement" },
67 { NETPERFMETER_STOP, "NetPerfMeter Stop Measurement" },
68 { NETPERFMETER_RESULTS, "NetPerfMeter Results" },
69 { 0, NULL }
72 static int hf_message_type;
73 static int hf_message_flags;
74 static int hf_message_length;
76 static int hf_acknowledge_flowid;
77 static int hf_acknowledge_measurementid;
78 static int hf_acknowledge_streamid;
79 // static int hf_acknowledge_padding;
80 static int hf_acknowledge_status;
82 static int hf_addflow_flag_debug;
83 static int hf_addflow_flag_nodelay;
84 static int hf_addflow_flag_repeatonoff;
85 static int hf_addflow_flowid;
86 static int hf_addflow_measurementid;
87 static int hf_addflow_streamid;
88 static int hf_addflow_protocol;
89 static int hf_addflow_flags;
90 static int hf_addflow_description;
91 static int hf_addflow_ordered;
92 static int hf_addflow_reliable;
93 static int hf_addflow_retranstrials;
94 static int hf_addflow_framerate1;
95 static int hf_addflow_framerate2;
96 static int hf_addflow_framerate3;
97 static int hf_addflow_framerate4;
98 static int hf_addflow_framesize1;
99 static int hf_addflow_framesize2;
100 static int hf_addflow_framesize3;
101 static int hf_addflow_framesize4;
102 static int hf_addflow_frameraterng;
103 static int hf_addflow_framesizerng;
104 static int hf_addflow_rcvbuffersize;
105 static int hf_addflow_sndbuffersize;
106 static int hf_addflow_maxmsgsize;
107 static int hf_addflow_cmt;
108 static int hf_addflow_ccid;
109 static int hf_addflow_onoffevents;
110 static int hf_addflow_onoffeventarray;
112 static int hf_removeflow_flowid;
113 static int hf_removeflow_measurementid;
114 static int hf_removeflow_streamid;
116 static int hf_identifyflow_flag_compress_vectors;
117 static int hf_identifyflow_flag_no_vectors;
118 static int hf_identifyflow_flowid;
119 static int hf_identifyflow_magicnumber;
120 static int hf_identifyflow_measurementid;
121 static int hf_identifyflow_streamid;
123 #define NETPERFMETER_IDENTIFY_FLOW_MAGIC_NUMBER 0x4bcdf3aa303c6774ULL
125 static int hf_data_flag_frame_begin;
126 static int hf_data_flag_frame_end;
127 static int hf_data_flowid;
128 static int hf_data_measurementid;
129 static int hf_data_streamid;
130 static int hf_data_padding;
131 static int hf_data_frameid;
132 static int hf_data_packetseqnumber;
133 static int hf_data_byteseqnumber;
134 static int hf_data_timestamp;
135 static int hf_data_payload;
137 static int hf_start_flag_compress_vectors;
138 static int hf_start_flag_compress_scalars;
139 static int hf_start_flag_no_vectors;
140 static int hf_start_flag_no_scalars;
141 // static int hf_start_padding;
142 static int hf_start_measurementid;
144 // static int hf_stop_padding;
145 static int hf_stop_measurementid;
147 static int hf_results_flag_eof;
148 static int hf_results_data;
151 /* Setup list of Transport Layer protocol types */
152 static const value_string proto_type_values[] = {
153 { 6, "TCP" },
154 { 8, "MPTCP" },
155 { 17, "UDP" },
156 { 33, "DCCP" },
157 { 132, "SCTP" },
158 { 0, NULL }
161 /* Setup list of CMT values */
162 static const value_string cmt_values[] = {
163 { 0, "Off" },
164 { 1, "CMT" },
165 { 2, "CMT/RPv1" },
166 { 3, "CMT/RPv2" },
167 { 4, "MPTCP-Like" },
168 { 0, NULL }
171 /* Setup list of random number generator types */
172 static const value_string rng_type_values[] = {
173 { 0, "Constant" },
174 { 1, "Uniform" },
175 { 2, "Neg. Exponential" },
176 { 0, NULL }
179 /* Message flags */
180 #define NPMAFF_DEBUG (1 << 0)
181 #define NPMAFF_NODELAY (1 << 1)
182 #define NPMAFF_REPEATONOFF (1 << 2)
184 #define NPMIF_COMPRESS_VECTORS (1 << 0)
185 #define NPMIF_NO_VECTORS (1 << 1)
187 #define NPMSF_COMPRESS_VECTORS (1 << 0)
188 #define NPMSF_COMPRESS_SCALARS (1 << 1)
189 #define NPMSF_NO_VECTORS (1 << 2)
190 #define NPMSF_NO_SCALARS (1 << 3)
192 #define NPMDF_FRAME_BEGIN (1 << 0)
193 #define NPMDF_FRAME_END (1 << 1)
195 #define NPMRF_EOF (1 << 0)
198 /* Setup list of header fields */
199 static hf_register_info hf[] = {
200 { &hf_message_type, { "Type", "netperfmeter.message_type", FT_UINT8, BASE_DEC, VALS(message_type_values), 0x0, NULL, HFILL } },
201 { &hf_message_flags, { "Flags", "netperfmeter.message_flags", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
202 { &hf_message_length, { "Length", "netperfmeter.message_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
204 { &hf_acknowledge_flowid, { "Flow ID", "netperfmeter.acknowledge_flowid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
205 { &hf_acknowledge_measurementid, { "Measurement ID", "netperfmeter.acknowledge_measurementid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL } },
206 { &hf_acknowledge_streamid, { "Stream ID", "netperfmeter.acknowledge_streamid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
207 #if 0
208 { &hf_acknowledge_padding, { "Padding", "netperfmeter.acknowledge_padding", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
209 #endif
210 { &hf_acknowledge_status, { "Status", "netperfmeter.acknowledge_status", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
212 { &hf_addflow_flowid, { "Flow ID", "netperfmeter.addflow_flowid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
213 { &hf_addflow_measurementid, { "Measurement ID", "netperfmeter.addflow_measurementid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL } },
214 { &hf_addflow_streamid, { "Stream ID", "netperfmeter.addflow_streamid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
215 { &hf_addflow_protocol, { "Protocol", "netperfmeter.addflow_protocol", FT_UINT8, BASE_DEC, VALS(proto_type_values), 0x0, NULL, HFILL } },
216 { &hf_addflow_flags, { "Flags", "netperfmeter.addflow_flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
217 { &hf_addflow_description, { "Description", "netperfmeter.addflow_description", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
218 { &hf_addflow_ordered, { "Ordered", "netperfmeter.addflow_ordered", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL } },
219 { &hf_addflow_reliable, { "Reliable", "netperfmeter.addflow_reliable", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL } },
220 { &hf_addflow_retranstrials, { "Retransmission Trials", "netperfmeter.addflow_retranstrials", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
221 { &hf_addflow_frameraterng, { "Frame Rate RNG", "netperfmeter.addflow_frameraterng", FT_UINT8, BASE_DEC, VALS(rng_type_values), 0x0, NULL, HFILL } },
222 { &hf_addflow_framerate1, { "Frame Rate 1", "netperfmeter.addflow_framerate1", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL } },
223 { &hf_addflow_framerate2, { "Frame Rate 2", "netperfmeter.addflow_framerate2", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL } },
224 { &hf_addflow_framerate3, { "Frame Rate 3", "netperfmeter.addflow_framerate3", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL } },
225 { &hf_addflow_framerate4, { "Frame Rate 4", "netperfmeter.addflow_framerate4", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL } },
226 { &hf_addflow_framesizerng, { "Frame Size RNG", "netperfmeter.addflow_framesizerng", FT_UINT8, BASE_DEC, VALS(rng_type_values), 0x0, NULL, HFILL } },
227 { &hf_addflow_framesize1, { "Frame Size 1", "netperfmeter.addflow_framesize1", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL } },
228 { &hf_addflow_framesize2, { "Frame Size 2", "netperfmeter.addflow_framesize2", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL } },
229 { &hf_addflow_framesize3, { "Frame Size 3", "netperfmeter.addflow_framesize3", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL } },
230 { &hf_addflow_framesize4, { "Frame Size 4", "netperfmeter.addflow_framesize4", FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL } },
231 { &hf_addflow_rcvbuffersize, { "Receive Buffer Size", "netperfmeter.addflow_rcvbuffersize", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
232 { &hf_addflow_sndbuffersize, { "Send Buffer Size", "netperfmeter.addflow_sndbuffersize", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
233 { &hf_addflow_maxmsgsize, { "Max. Message Size", "netperfmeter.addflow_maxmsgsize", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
234 { &hf_addflow_cmt, { "CMT", "netperfmeter.addflow_cmt", FT_UINT8, BASE_HEX, VALS(cmt_values), 0x0, NULL, HFILL } },
235 { &hf_addflow_ccid, { "CCID", "netperfmeter.addflow_ccid", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
236 { &hf_addflow_onoffevents, { "On/Off Events", "netperfmeter.addflow_onoffevents", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
237 { &hf_addflow_onoffeventarray, { "On/Off Event", "netperfmeter.addflow_onoffeventarray", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
238 { &hf_addflow_flag_debug, { "Debug", "netperfmeter.addflow_flags.debug", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMAFF_DEBUG, NULL, HFILL } },
239 { &hf_addflow_flag_nodelay, { "No Delay", "netperfmeter.addflow_flags.nodelay", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMAFF_NODELAY, NULL, HFILL } },
240 { &hf_addflow_flag_repeatonoff, { "Repeat On/Off", "netperfmeter.addflow_flags.repeatonoff", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMAFF_REPEATONOFF, NULL, HFILL } },
242 { &hf_removeflow_flowid, { "Flow ID", "netperfmeter.removeflow_flowid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
243 { &hf_removeflow_measurementid, { "Measurement ID", "netperfmeter.removeflow_measurementid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL } },
244 { &hf_removeflow_streamid, { "Stream ID", "netperfmeter.removeflow_streamid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
246 { &hf_identifyflow_flowid, { "Flow ID", "netperfmeter.identifyflow_flowid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
247 { &hf_identifyflow_magicnumber, { "Magic Number", "netperfmeter.identifyflow_magicnumber", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL } },
248 { &hf_identifyflow_measurementid, { "Measurement ID", "netperfmeter.identifyflow_measurementid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL } },
249 { &hf_identifyflow_streamid, { "Stream ID", "netperfmeter.identifyflow_streamid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
250 { &hf_identifyflow_flag_compress_vectors, { "Compress Vectors", "netperfmeter.dentifyflow_flags.compress_vectors", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMIF_COMPRESS_VECTORS, NULL, HFILL } },
251 { &hf_identifyflow_flag_no_vectors, { "No Vectors", "netperfmeter.dentifyflow_flags.no_vectors", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMIF_NO_VECTORS, NULL, HFILL } },
253 { &hf_data_flowid, { "Flow ID", "netperfmeter.data_flowid", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
254 { &hf_data_measurementid, { "Measurement ID", "netperfmeter.data_measurementid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL } },
255 { &hf_data_streamid, { "Stream ID", "netperfmeter.data_streamid", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
256 { &hf_data_padding, { "Padding", "netperfmeter.data_padding", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
257 { &hf_data_frameid, { "Frame ID", "netperfmeter.data_frameid", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
258 { &hf_data_packetseqnumber, { "Packet Seq Number", "netperfmeter.data_packetseqnumber", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
259 { &hf_data_byteseqnumber, { "Byte Seq Number", "netperfmeter.data_byteseqnumber", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
260 { &hf_data_timestamp, { "Time Stamp", "netperfmeter.data_timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL } },
261 { &hf_data_payload, { "Payload", "netperfmeter.data_payload", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
262 { &hf_data_flag_frame_begin, { "Begin of Frame", "netperfmeter.data_flags.frame_begin", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMDF_FRAME_BEGIN, NULL, HFILL } },
263 { &hf_data_flag_frame_end, { "End of Frame", "netperfmeter.data_flags.frame_end", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMDF_FRAME_END, NULL, HFILL } },
265 #if 0
266 { &hf_start_padding, { "Padding", "netperfmeter.start_padding", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
267 #endif
268 { &hf_start_measurementid, { "Measurement ID", "netperfmeter.start_measurementid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL } },
269 { &hf_start_flag_compress_vectors,{ "Compress Vectors", "netperfmeter.start_flags.compress_vectors", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMSF_COMPRESS_VECTORS, NULL, HFILL } },
270 { &hf_start_flag_compress_scalars,{ "Compress Scalars", "netperfmeter.start_flags.compress_scalars", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMSF_COMPRESS_SCALARS, NULL, HFILL } },
271 { &hf_start_flag_no_vectors, { "No Vectors", "netperfmeter.start_flags.no_vectors", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMSF_NO_VECTORS, NULL, HFILL } },
272 { &hf_start_flag_no_scalars, { "No Scalars", "netperfmeter.start_flags.no_scalars", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMSF_NO_SCALARS, NULL, HFILL } },
274 #if 0
275 { &hf_stop_padding, { "Padding", "netperfmeter.stop_padding", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
276 #endif
277 { &hf_stop_measurementid, { "Measurement ID", "netperfmeter.stop_measurementid", FT_UINT64, BASE_HEX, NULL, 0x0, NULL, HFILL } },
279 { &hf_results_data, { "Data", "netperfmeter.results_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
280 { &hf_results_flag_eof, { "End of File", "netperfmeter.results_flags.eof", FT_BOOLEAN, 8, TFS(&tfs_set_notset), NPMRF_EOF, NULL, HFILL } }
284 typedef struct _tap_npm_rec_t {
285 uint8_t type;
286 uint16_t size;
287 const char* type_string;
288 } tap_npm_rec_t;
291 static void
292 dissect_npm_acknowledge_message(tvbuff_t *message_tvb, proto_tree *message_tree)
294 proto_tree_add_item(message_tree, hf_acknowledge_flowid, message_tvb, 4, 4, ENC_BIG_ENDIAN);
295 proto_tree_add_item(message_tree, hf_acknowledge_measurementid, message_tvb, 8, 8, ENC_BIG_ENDIAN);
296 proto_tree_add_item(message_tree, hf_acknowledge_streamid, message_tvb, 16, 2, ENC_BIG_ENDIAN);
297 /* proto_tree_add_item(message_tree, acknowledge_padding, message_tvb, 18, 2, ENC_BIG_ENDIAN); */
298 proto_tree_add_item(message_tree, hf_acknowledge_status, message_tvb, 20, 4, ENC_BIG_ENDIAN);
302 static void
303 dissect_npm_add_flow_message(tvbuff_t *message_tvb, proto_tree *message_tree, proto_item *flags_item)
305 uint32_t retranstrials;
306 proto_item* onoffitem;
307 proto_tree* onofftree;
308 proto_tree* flags_tree;
309 uint16_t onoffevents;
310 uint32_t onoffvalue;
311 unsigned int i;
313 flags_tree = proto_item_add_subtree(flags_item, ett_addflow_flags);
314 proto_tree_add_item(flags_tree, hf_addflow_flag_debug, message_tvb, 1, 1, ENC_BIG_ENDIAN);
315 proto_tree_add_item(flags_tree, hf_addflow_flag_nodelay, message_tvb, 1, 1, ENC_BIG_ENDIAN);
316 proto_tree_add_item(flags_tree, hf_addflow_flag_repeatonoff, message_tvb, 1, 1, ENC_BIG_ENDIAN);
318 proto_tree_add_item(message_tree, hf_addflow_flowid, message_tvb, 4, 4, ENC_BIG_ENDIAN);
319 proto_tree_add_item(message_tree, hf_addflow_measurementid, message_tvb, 8, 8, ENC_BIG_ENDIAN);
320 proto_tree_add_item(message_tree, hf_addflow_streamid, message_tvb, 16, 2, ENC_BIG_ENDIAN);
321 proto_tree_add_item(message_tree, hf_addflow_protocol, message_tvb, 18, 1, ENC_BIG_ENDIAN);
322 proto_tree_add_item(message_tree, hf_addflow_flags, message_tvb, 19, 1, ENC_BIG_ENDIAN);
323 proto_tree_add_item(message_tree, hf_addflow_description, message_tvb, 20, 32, ENC_UTF_8);
325 proto_tree_add_double_format_value(message_tree, hf_addflow_ordered, message_tvb, 52, 4,
326 100.0 * tvb_get_ntohl(message_tvb, 52) / (double)0xffffffff, "%1.3f%%",
327 100.0 * tvb_get_ntohl(message_tvb, 52) / (double)0xffffffff);
328 proto_tree_add_double_format_value(message_tree, hf_addflow_reliable, message_tvb, 56, 4,
329 100.0 * tvb_get_ntohl(message_tvb, 56) / (double)0xffffffff, "%1.3f%%",
330 100.0 * tvb_get_ntohl(message_tvb, 56) / (double)0xffffffff);
332 retranstrials = tvb_get_ntohl(message_tvb, 60);
333 proto_tree_add_uint_format_value(message_tree, hf_addflow_retranstrials, message_tvb, 60, 4,
334 retranstrials, (retranstrials & (1U << 31)) ? "%u ms" : "%u trials",
335 retranstrials &~ (1U << 31));
337 proto_tree_add_item(message_tree, hf_addflow_frameraterng, message_tvb, 128, 1, ENC_BIG_ENDIAN);
338 proto_tree_add_item(message_tree, hf_addflow_framerate1, message_tvb, 64, 8, ENC_BIG_ENDIAN);
339 proto_tree_add_item(message_tree, hf_addflow_framerate2, message_tvb, 72, 8, ENC_BIG_ENDIAN);
340 proto_tree_add_item(message_tree, hf_addflow_framerate3, message_tvb, 80, 8, ENC_BIG_ENDIAN);
341 proto_tree_add_item(message_tree, hf_addflow_framerate4, message_tvb, 88, 8, ENC_BIG_ENDIAN);
342 proto_tree_add_item(message_tree, hf_addflow_framesizerng, message_tvb, 129, 1, ENC_BIG_ENDIAN);
343 proto_tree_add_item(message_tree, hf_addflow_framesize1, message_tvb, 96, 8, ENC_BIG_ENDIAN);
344 proto_tree_add_item(message_tree, hf_addflow_framesize2, message_tvb, 104, 8, ENC_BIG_ENDIAN);
345 proto_tree_add_item(message_tree, hf_addflow_framesize3, message_tvb, 112, 8, ENC_BIG_ENDIAN);
346 proto_tree_add_item(message_tree, hf_addflow_framesize4, message_tvb, 120, 8, ENC_BIG_ENDIAN);
347 proto_tree_add_item(message_tree, hf_addflow_rcvbuffersize, message_tvb, 130, 4, ENC_BIG_ENDIAN);
348 proto_tree_add_item(message_tree, hf_addflow_sndbuffersize, message_tvb, 134, 4, ENC_BIG_ENDIAN);
349 proto_tree_add_item(message_tree, hf_addflow_maxmsgsize, message_tvb, 138, 2, ENC_BIG_ENDIAN);
350 proto_tree_add_item(message_tree, hf_addflow_cmt, message_tvb, 140, 1, ENC_BIG_ENDIAN);
351 proto_tree_add_item(message_tree, hf_addflow_ccid, message_tvb, 141, 1, ENC_BIG_ENDIAN);
353 onoffitem = proto_tree_add_item(message_tree, hf_addflow_onoffevents, message_tvb, 142, 2, ENC_BIG_ENDIAN);
355 onoffevents = tvb_get_ntohs(message_tvb, 142);
356 if (onoffevents > 0) {
357 onofftree = proto_item_add_subtree(onoffitem, ett_onoffarray);
358 for(i = 0;i < onoffevents;i++) {
359 onoffvalue = tvb_get_ntohl(message_tvb, 144 + (int)(sizeof(uint32_t) * i));
360 proto_tree_add_uint_format(onofftree, hf_addflow_onoffeventarray, message_tvb,
361 144 + (int)(sizeof(uint32_t) * i), (int)sizeof(uint32_t),
362 onoffvalue, "%1.3f s: set to %s", onoffvalue / 1000.0, (i & 1) ? "OFF" : "ON");
368 static void
369 dissect_npm_remove_flow_message(tvbuff_t *message_tvb, proto_tree *message_tree)
371 proto_tree_add_item(message_tree, hf_removeflow_flowid, message_tvb, 4, 4, ENC_BIG_ENDIAN);
372 proto_tree_add_item(message_tree, hf_removeflow_measurementid, message_tvb, 8, 8, ENC_BIG_ENDIAN);
373 proto_tree_add_item(message_tree, hf_removeflow_streamid, message_tvb, 16, 2, ENC_BIG_ENDIAN);
377 static void
378 dissect_npm_identify_flow_message(tvbuff_t *message_tvb, proto_tree *message_tree, proto_item *flags_item)
380 proto_tree* flags_tree;
382 flags_tree = proto_item_add_subtree(flags_item, ett_identifyflow_flags);
383 proto_tree_add_item(flags_tree, hf_identifyflow_flag_compress_vectors, message_tvb, 1, 1, ENC_BIG_ENDIAN);
384 proto_tree_add_item(flags_tree, hf_identifyflow_flag_no_vectors, message_tvb, 1, 1, ENC_BIG_ENDIAN);
386 proto_tree_add_item(message_tree, hf_identifyflow_flowid, message_tvb, 4, 4, ENC_BIG_ENDIAN);
387 proto_tree_add_item(message_tree, hf_identifyflow_magicnumber, message_tvb, 8, 8, ENC_BIG_ENDIAN);
388 proto_tree_add_item(message_tree, hf_identifyflow_measurementid, message_tvb, 16, 8, ENC_BIG_ENDIAN);
389 proto_tree_add_item(message_tree, hf_identifyflow_streamid, message_tvb, 24, 2, ENC_BIG_ENDIAN);
393 static void
394 dissect_npm_data_message(tvbuff_t *message_tvb, proto_tree *message_tree, proto_item *flags_item)
396 proto_tree* flags_tree;
397 const uint16_t message_length = tvb_get_ntohs(message_tvb, 2);
398 uint64_t timestamp;
399 nstime_t t;
401 flags_tree = proto_item_add_subtree(flags_item, ett_data_flags);
402 proto_tree_add_item(flags_tree, hf_data_flag_frame_begin, message_tvb, 1, 1, ENC_BIG_ENDIAN);
403 proto_tree_add_item(flags_tree, hf_data_flag_frame_end, message_tvb, 1, 1, ENC_BIG_ENDIAN);
405 proto_tree_add_item(message_tree, hf_data_flowid, message_tvb, 4, 4, ENC_BIG_ENDIAN);
406 proto_tree_add_item(message_tree, hf_data_measurementid, message_tvb, 8, 8, ENC_BIG_ENDIAN);
407 proto_tree_add_item(message_tree, hf_data_streamid, message_tvb, 16, 2, ENC_BIG_ENDIAN);
408 proto_tree_add_item(message_tree, hf_data_padding, message_tvb, 18, 2, ENC_BIG_ENDIAN);
409 proto_tree_add_item(message_tree, hf_data_frameid, message_tvb, 20, 4, ENC_BIG_ENDIAN);
410 proto_tree_add_item(message_tree, hf_data_packetseqnumber, message_tvb, 24, 8, ENC_BIG_ENDIAN);
411 proto_tree_add_item(message_tree, hf_data_byteseqnumber, message_tvb, 32, 8, ENC_BIG_ENDIAN);
413 timestamp = tvb_get_ntoh64(message_tvb, 40);
414 t.secs = (time_t)(timestamp / 1000000);
415 t.nsecs = (int)((timestamp - 1000000 * t.secs) * 1000);
417 proto_tree_add_time(message_tree, hf_data_timestamp, message_tvb, 40, 8, &t);
419 if (message_length > 4) {
420 proto_tree_add_item(message_tree, hf_data_payload, message_tvb, 48, message_length - 48, ENC_NA);
425 static void
426 dissect_npm_start_message(tvbuff_t *message_tvb, proto_tree *message_tree, proto_item *flags_item)
428 proto_tree* flags_tree;
430 flags_tree = proto_item_add_subtree(flags_item, ett_start_flags);
431 proto_tree_add_item(flags_tree, hf_start_flag_compress_vectors, message_tvb, 1, 1, ENC_BIG_ENDIAN);
432 proto_tree_add_item(flags_tree, hf_start_flag_compress_scalars, message_tvb, 1, 1, ENC_BIG_ENDIAN);
433 proto_tree_add_item(flags_tree, hf_start_flag_no_vectors, message_tvb, 1, 1, ENC_BIG_ENDIAN);
434 proto_tree_add_item(flags_tree, hf_start_flag_no_scalars, message_tvb, 1, 1, ENC_BIG_ENDIAN);
436 proto_tree_add_item(message_tree, hf_start_measurementid, message_tvb, 8, 8, ENC_BIG_ENDIAN);
440 static void
441 dissect_npm_stop_message(tvbuff_t *message_tvb, proto_tree *message_tree)
443 proto_tree_add_item(message_tree, hf_stop_measurementid, message_tvb, 8, 8, ENC_BIG_ENDIAN);
447 static void
448 dissect_npm_results_message(tvbuff_t *message_tvb, proto_tree *message_tree, proto_item *flags_item)
450 proto_tree* flags_tree;
452 flags_tree = proto_item_add_subtree(flags_item, ett_data_flags);
453 proto_tree_add_item(flags_tree, hf_results_flag_eof, message_tvb, 1, 1, ENC_BIG_ENDIAN);
455 const uint16_t message_length = tvb_get_ntohs(message_tvb, 2);
456 if (message_length > 4) {
457 proto_tree_add_item(message_tree, hf_results_data, message_tvb, 4, message_length - 4, ENC_NA);
462 static void
463 dissect_npm_message(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *npm_tree)
465 proto_tree* flags_tree;
467 tap_npm_rec_t* tap_rec = wmem_new0(pinfo->pool, tap_npm_rec_t);
468 tap_rec->type = tvb_get_uint8(message_tvb, 0);
469 tap_rec->size = tvb_get_ntohs(message_tvb, 2);
470 tap_rec->type_string = val_to_str_const(tap_rec->type, message_type_values, "Unknown NetPerfMeter message type");
471 tap_queue_packet(tap_npm, pinfo, tap_rec);
473 col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", tap_rec->type_string);
475 proto_tree_add_item(npm_tree, hf_message_type, message_tvb, 0, 1, ENC_BIG_ENDIAN);
476 flags_tree = proto_tree_add_item(npm_tree, hf_message_flags, message_tvb, 1, 1, ENC_BIG_ENDIAN);
477 proto_tree_add_item(npm_tree, hf_message_length, message_tvb, 2, 2, ENC_BIG_ENDIAN);
479 switch (tap_rec->type) {
480 case NETPERFMETER_ACKNOWLEDGE:
481 dissect_npm_acknowledge_message(message_tvb, npm_tree);
482 break;
483 case NETPERFMETER_ADD_FLOW:
484 dissect_npm_add_flow_message(message_tvb, npm_tree, flags_tree);
485 break;
486 case NETPERFMETER_REMOVE_FLOW:
487 dissect_npm_remove_flow_message(message_tvb, npm_tree);
488 break;
489 case NETPERFMETER_IDENTIFY_FLOW:
490 dissect_npm_identify_flow_message(message_tvb, npm_tree, flags_tree);
491 break;
492 case NETPERFMETER_DATA:
493 dissect_npm_data_message(message_tvb, npm_tree, flags_tree);
494 break;
495 case NETPERFMETER_START:
496 dissect_npm_start_message(message_tvb, npm_tree, flags_tree);
497 break;
498 case NETPERFMETER_STOP:
499 dissect_npm_stop_message(message_tvb, npm_tree);
500 break;
501 case NETPERFMETER_RESULTS:
502 dissect_npm_results_message(message_tvb, npm_tree, flags_tree);
503 break;
507 static int
508 dissect_npm(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
510 proto_item *npm_item;
511 proto_tree *npm_tree;
513 col_append_sep_fstr(pinfo->cinfo, COL_PROTOCOL, NULL, "NetPerfMeter");
515 /* In the interest of speed, if "tree" is NULL, don't do any work not
516 necessary to generate protocol tree items. */
517 if (tree) {
518 /* create the npm protocol tree */
519 npm_item = proto_tree_add_item(tree, proto_npm, message_tvb, 0, -1, ENC_NA);
520 npm_tree = proto_item_add_subtree(npm_item, ett_npm);
521 } else {
522 npm_tree = NULL;
524 /* dissect the message */
525 dissect_npm_message(message_tvb, pinfo, npm_tree);
526 return true;
530 static bool
531 dissect_npm_heur(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
533 const unsigned length = tvb_captured_length(message_tvb);
534 if (length < 4)
535 return false;
537 /* For TCP, UDP or DCCP:
538 Type must either be NETPERFMETER_DATA or NETPERFMETER_IDENTIFY_FLOW */
539 const uint8_t type = tvb_get_uint8(message_tvb, 0);
540 switch(type) {
541 case NETPERFMETER_DATA:
542 if (length < 48 + 8)
543 return false;
544 /* Identify NetPerfMeter flow by payload pattern */
545 for(int i = 0; i < 8; i++) {
546 uint8_t d = tvb_get_uint8(message_tvb, 48 + i);
547 if( (d != 30 + i) && (d != 127 - i) )
548 return false;
550 break;
551 case NETPERFMETER_IDENTIFY_FLOW:
552 if (length < 24 + 2)
553 return false;
554 if (tvb_get_ntoh64(message_tvb, 8) != NETPERFMETER_IDENTIFY_FLOW_MAGIC_NUMBER) {
555 /* Identify NetPerfMeter flow by NETPERFMETER_IDENTIFY_FLOW_MAGIC_NUMBER */
556 return false;
558 break;
559 default:
560 /* Not a NetPerfMeter packet */
561 return false;
562 break;
564 dissect_npm(message_tvb, pinfo, tree, data);
565 return true;
569 /* TAP STAT INFO */
570 typedef enum
572 MESSAGE_TYPE_COLUMN = 0,
573 MESSAGES_COLUMN,
574 MESSAGES_SHARE_COLUMN,
575 BYTES_COLUMN,
576 BYTES_SHARE_COLUMN,
577 FIRST_SEEN_COLUMN,
578 LAST_SEEN_COLUMN,
579 INTERVAL_COLUMN,
580 MESSAGE_RATE_COLUMN,
581 BYTE_RATE_COLUMN
582 } npm_stat_columns;
584 static stat_tap_table_item npm_stat_fields[] = {
585 { TABLE_ITEM_STRING, TAP_ALIGN_LEFT, "NetPerfMeter Message Type", "%-25s" },
586 { TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Messages ", "%u" },
587 { TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Messages Share (%)" , "%1.3f %%" },
588 { TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Bytes (B)", "%u" },
589 { TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Bytes Share (%) ", "%1.3f %%" },
590 { TABLE_ITEM_FLOAT, TAP_ALIGN_LEFT, "First Seen (s)", "%1.6f" },
591 { TABLE_ITEM_FLOAT, TAP_ALIGN_LEFT, "Last Seen (s)", "%1.6f" },
592 { TABLE_ITEM_FLOAT, TAP_ALIGN_LEFT, "Interval (s)", "%1.6f" },
593 { TABLE_ITEM_FLOAT, TAP_ALIGN_LEFT, "Message Rate (Msg/s)", "%1.2f" },
594 { TABLE_ITEM_FLOAT, TAP_ALIGN_LEFT, "Byte Rate (B/s)", "%1.2f" }
597 static void npm_stat_init(stat_tap_table_ui* new_stat)
599 const char *table_name = "NetPerfMeter Statistics";
600 int num_fields = array_length(npm_stat_fields);
601 stat_tap_table *table;
602 int i = 0;
603 stat_tap_table_item_type items[array_length(npm_stat_fields)];
605 table = stat_tap_find_table(new_stat, table_name);
606 if (table) {
607 if (new_stat->stat_tap_reset_table_cb) {
608 new_stat->stat_tap_reset_table_cb(table);
610 return;
613 table = stat_tap_init_table(table_name, num_fields, 0, NULL);
614 stat_tap_add_table(new_stat, table);
616 memset(items, 0x0, sizeof(items));
617 /* Add a row for each value type */
618 while (message_type_values[i].strptr) {
619 items[MESSAGE_TYPE_COLUMN].type = TABLE_ITEM_STRING;
620 items[MESSAGE_TYPE_COLUMN].value.string_value = message_type_values[i].strptr;
621 items[MESSAGES_COLUMN].type = TABLE_ITEM_UINT;
622 items[MESSAGES_COLUMN].value.uint_value = 0;
623 items[MESSAGES_SHARE_COLUMN].type = TABLE_ITEM_NONE;
624 items[MESSAGES_SHARE_COLUMN].value.float_value = -1.0;
625 items[BYTES_COLUMN].type = TABLE_ITEM_UINT;
626 items[BYTES_COLUMN].value.uint_value = 0;
627 items[BYTES_SHARE_COLUMN].type = TABLE_ITEM_NONE;
628 items[BYTES_SHARE_COLUMN].value.float_value = -1.0;
629 items[FIRST_SEEN_COLUMN].type = TABLE_ITEM_NONE;
630 items[FIRST_SEEN_COLUMN].value.float_value = DBL_MAX;
631 items[LAST_SEEN_COLUMN].type = TABLE_ITEM_NONE;
632 items[LAST_SEEN_COLUMN].value.float_value = DBL_MIN;
633 items[INTERVAL_COLUMN].type = TABLE_ITEM_NONE;
634 items[INTERVAL_COLUMN].value.float_value = -1.0;
635 items[MESSAGE_RATE_COLUMN].type = TABLE_ITEM_NONE;
636 items[MESSAGE_RATE_COLUMN].value.float_value = -1.0;
637 items[BYTE_RATE_COLUMN].type = TABLE_ITEM_NONE;
638 items[BYTE_RATE_COLUMN].value.float_value = -1.0;
639 stat_tap_init_table_row(table, i, num_fields, items);
640 i++;
644 static tap_packet_status
645 npm_stat_packet(void* tapdata, packet_info* pinfo _U_, epan_dissect_t* edt _U_, const void* data, tap_flags_t flags _U_)
647 stat_data_t* stat_data = (stat_data_t*)tapdata;
648 const tap_npm_rec_t* tap_rec = (const tap_npm_rec_t*)data;
649 stat_tap_table* table;
650 stat_tap_table_item_type* msg_data;
651 int idx;
652 uint64_t messages;
653 uint64_t bytes;
654 int i = 0;
655 double firstSeen = -1.0;
656 double lastSeen = -1.0;
658 idx = str_to_val_idx(tap_rec->type_string, message_type_values);
659 if (idx < 0)
660 return TAP_PACKET_DONT_REDRAW;
662 table = g_array_index(stat_data->stat_tap_data->tables, stat_tap_table*, 0);
664 /* Update packets counter */
665 npm_total_msgs++;
666 msg_data = stat_tap_get_field_data(table, idx, MESSAGES_COLUMN);
667 msg_data->value.uint_value++;
668 messages = msg_data->value.uint_value;
669 stat_tap_set_field_data(table, idx, MESSAGES_COLUMN, msg_data);
671 /* Update bytes counter */
672 npm_total_bytes += tap_rec->size;
673 msg_data = stat_tap_get_field_data(table, idx, BYTES_COLUMN);
674 msg_data->value.uint_value += tap_rec->size;
675 bytes = msg_data->value.uint_value;
676 stat_tap_set_field_data(table, idx, BYTES_COLUMN, msg_data);
678 /* Update messages and bytes share */
679 while (message_type_values[i].strptr) {
680 msg_data = stat_tap_get_field_data(table, i, MESSAGES_COLUMN);
681 const unsigned m = msg_data->value.uint_value;
682 msg_data = stat_tap_get_field_data(table, i, BYTES_COLUMN);
683 const unsigned b = msg_data->value.uint_value;
685 msg_data = stat_tap_get_field_data(table, i, MESSAGES_SHARE_COLUMN);
686 msg_data->type = TABLE_ITEM_FLOAT;
687 msg_data->value.float_value = 100.0 * m / (double)npm_total_msgs;
688 stat_tap_set_field_data(table, i, MESSAGES_SHARE_COLUMN, msg_data);
690 msg_data = stat_tap_get_field_data(table, i, BYTES_SHARE_COLUMN);
691 msg_data->type = TABLE_ITEM_FLOAT;
692 msg_data->value.float_value = 100.0 * b / (double)npm_total_bytes;
693 stat_tap_set_field_data(table, i, BYTES_SHARE_COLUMN, msg_data);
694 i++;
697 /* Update first seen time */
698 if (pinfo->presence_flags & PINFO_HAS_TS) {
699 msg_data = stat_tap_get_field_data(table, idx, FIRST_SEEN_COLUMN);
700 msg_data->type = TABLE_ITEM_FLOAT;
701 msg_data->value.float_value = MIN(msg_data->value.float_value, nstime_to_sec(&pinfo->rel_ts));
702 firstSeen = msg_data->value.float_value;
703 stat_tap_set_field_data(table, idx, FIRST_SEEN_COLUMN, msg_data);
706 /* Update last seen time */
707 if (pinfo->presence_flags & PINFO_HAS_TS) {
708 msg_data = stat_tap_get_field_data(table, idx, LAST_SEEN_COLUMN);
709 msg_data->type = TABLE_ITEM_FLOAT;
710 msg_data->value.float_value = MAX(msg_data->value.float_value, nstime_to_sec(&pinfo->rel_ts));
711 lastSeen = msg_data->value.float_value;
712 stat_tap_set_field_data(table, idx, LAST_SEEN_COLUMN, msg_data);
715 if ((lastSeen - firstSeen) > 0.0) {
716 /* Update interval */
717 msg_data = stat_tap_get_field_data(table, idx, INTERVAL_COLUMN);
718 msg_data->type = TABLE_ITEM_FLOAT;
719 msg_data->value.float_value = lastSeen - firstSeen;
720 stat_tap_set_field_data(table, idx, INTERVAL_COLUMN, msg_data);
722 /* Update message rate */
723 msg_data = stat_tap_get_field_data(table, idx, MESSAGE_RATE_COLUMN);
724 msg_data->type = TABLE_ITEM_FLOAT;
725 msg_data->value.float_value = messages / (lastSeen - firstSeen);
726 stat_tap_set_field_data(table, idx, MESSAGE_RATE_COLUMN, msg_data);
728 /* Update byte rate */
729 msg_data = stat_tap_get_field_data(table, idx, BYTE_RATE_COLUMN);
730 msg_data->type = TABLE_ITEM_FLOAT;
731 msg_data->value.float_value = bytes / (lastSeen - firstSeen);
732 stat_tap_set_field_data(table, idx, BYTE_RATE_COLUMN, msg_data);
735 return TAP_PACKET_REDRAW;
738 static void
739 npm_stat_reset(stat_tap_table* table)
741 unsigned element;
742 stat_tap_table_item_type* item_data;
744 for (element = 0; element < table->num_elements; element++) {
745 item_data = stat_tap_get_field_data(table, element, MESSAGES_COLUMN);
746 item_data->value.uint_value = 0;
747 stat_tap_set_field_data(table, element, MESSAGES_COLUMN, item_data);
749 item_data = stat_tap_get_field_data(table, element, MESSAGES_SHARE_COLUMN);
750 item_data->type = TABLE_ITEM_NONE;
751 item_data->value.float_value = -1.0;
752 stat_tap_set_field_data(table, element, MESSAGES_SHARE_COLUMN, item_data);
754 item_data = stat_tap_get_field_data(table, element, BYTES_COLUMN);
755 item_data->value.uint_value = 0;
756 stat_tap_set_field_data(table, element, BYTES_COLUMN, item_data);
758 item_data = stat_tap_get_field_data(table, element, BYTES_SHARE_COLUMN);
759 item_data->type = TABLE_ITEM_NONE;
760 item_data->value.float_value = -1.0;
761 stat_tap_set_field_data(table, element, BYTES_SHARE_COLUMN, item_data);
763 item_data = stat_tap_get_field_data(table, element, FIRST_SEEN_COLUMN);
764 item_data->type = TABLE_ITEM_NONE;
765 item_data->value.float_value = DBL_MAX;
766 stat_tap_set_field_data(table, element, FIRST_SEEN_COLUMN, item_data);
768 item_data = stat_tap_get_field_data(table, element, LAST_SEEN_COLUMN);
769 item_data->type = TABLE_ITEM_NONE;
770 item_data->value.float_value = DBL_MIN;
771 stat_tap_set_field_data(table, element, LAST_SEEN_COLUMN, item_data);
773 item_data = stat_tap_get_field_data(table, element, INTERVAL_COLUMN);
774 item_data->type = TABLE_ITEM_NONE;
775 item_data->value.float_value = -1.0;
776 stat_tap_set_field_data(table, element, INTERVAL_COLUMN, item_data);
778 item_data = stat_tap_get_field_data(table, element, MESSAGE_RATE_COLUMN);
779 item_data->type = TABLE_ITEM_NONE;
780 item_data->value.float_value = -1.0;
781 stat_tap_set_field_data(table, element, MESSAGE_RATE_COLUMN, item_data);
783 item_data = stat_tap_get_field_data(table, element, BYTE_RATE_COLUMN);
784 item_data->type = TABLE_ITEM_NONE;
785 item_data->value.float_value = -1.0;
786 stat_tap_set_field_data(table, element, BYTE_RATE_COLUMN, item_data);
788 npm_total_msgs = 0;
789 npm_total_bytes = 0;
793 /* Register the protocol with Wireshark */
794 void
795 proto_register_npm(void)
797 /* Setup protocol subtree array */
798 static int *ett[] = {
799 &ett_npm,
800 &ett_addflow_flags,
801 &ett_identifyflow_flags,
802 &ett_start_flags,
803 &ett_data_flags,
804 &ett_results_flags,
805 &ett_onoffarray
808 static tap_param npm_stat_params[] = {
809 { PARAM_FILTER, "filter", "Filter", NULL, true }
812 static stat_tap_table_ui npm_stat_table = {
813 REGISTER_PACKET_STAT_GROUP_UNSORTED,
814 "NetPerfMeter Statistics",
815 "npm",
816 "npm,stat",
817 npm_stat_init,
818 npm_stat_packet,
819 npm_stat_reset,
820 NULL,
821 NULL,
822 array_length(npm_stat_fields), npm_stat_fields,
823 array_length(npm_stat_params), npm_stat_params,
824 NULL,
828 /* Register the protocol name and description */
829 proto_npm = proto_register_protocol("NetPerfMeter Protocol", "NetPerfMeter", "netperfmeter");
831 /* Required function calls to register the header fields and subtrees used */
832 proto_register_field_array(proto_npm, hf, array_length(hf));
833 proto_register_subtree_array(ett, array_length(ett));
834 tap_npm = register_tap("npm");
836 register_stat_tap_table_ui(&npm_stat_table);
838 /* Register the dissector */
839 npm_handle = register_dissector("netperfmeter", dissect_npm, proto_npm);
843 void
844 proto_reg_handoff_npm(void)
846 /* NetPerfMeter protocol over SCTP is detected by PPIDs */
847 dissector_add_uint("sctp.ppi", PPID_NETPERFMETER_CONTROL_LEGACY, npm_handle);
848 dissector_add_uint("sctp.ppi", PPID_NETPERFMETER_DATA_LEGACY, npm_handle);
849 dissector_add_uint("sctp.ppi", NPMP_CTRL_PAYLOAD_PROTOCOL_ID, npm_handle);
850 dissector_add_uint("sctp.ppi", NPMP_DATA_PAYLOAD_PROTOCOL_ID, npm_handle);
852 /* Heuristic dissector for TCP, UDP and DCCP */
853 heur_dissector_add("tcp", dissect_npm_heur, "NetPerfMeter over TCP", "netperfmeter_tcp", proto_npm, HEURISTIC_ENABLE);
854 heur_dissector_add("udp", dissect_npm_heur, "NetPerfMeter over UDP", "netperfmeter_udp", proto_npm, HEURISTIC_ENABLE);
855 heur_dissector_add("dccp", dissect_npm_heur, "NetPerfMeter over DCCP", "netperfmeter_dccp", proto_npm, HEURISTIC_ENABLE);
859 * Editor modelines - https://www.wireshark.org/tools/modelines.html
861 * Local Variables:
862 * c-basic-offset: 2
863 * tab-width: 8
864 * indent-tabs-mode: nil
865 * End:
867 * ex: set shiftwidth=2 tabstop=8 expandtab:
868 * :indentSize=2:tabSize=8:noTabs=true: