/src/wireshark/epan/dissectors/packet-rtnet.c
Line | Count | Source |
1 | | /* packet-rtnet.c |
2 | | * Routines for RTnet packet disassembly |
3 | | * |
4 | | * Copyright (c) 2003 by Erwin Rol <erwin@erwinrol.com> |
5 | | * Copyright (c) 2004 by Jan Kiszka <jan.kiszka@web.de> |
6 | | * |
7 | | * Wireshark - Network traffic analyzer |
8 | | * By Gerald Combs <gerald@wireshark.org> |
9 | | * Copyright 1999 Gerald Combs |
10 | | * |
11 | | * SPDX-License-Identifier: GPL-2.0-or-later |
12 | | */ |
13 | | |
14 | | /* Include files */ |
15 | | |
16 | | #include "config.h" |
17 | | |
18 | | #include <epan/packet.h> |
19 | | #include <epan/addr_resolv.h> |
20 | | #include <epan/etypes.h> |
21 | | #include <epan/tfs.h> |
22 | | #include <wsutil/array.h> |
23 | | /* |
24 | | * See |
25 | | * |
26 | | * http://www.rtnet.org/ |
27 | | * |
28 | | * https://github.com/iocroblab/rtnet/blob/master/Documentation/RTcfg.spec |
29 | | * https://github.com/iocroblab/rtnet/blob/master/Documentation/RTmac.spec |
30 | | */ |
31 | | |
32 | | void proto_register_rtmac(void); |
33 | | void proto_reg_handoff_rtmac(void); |
34 | | |
35 | | static dissector_handle_t rtmac_handle; |
36 | | static dissector_handle_t rtcfg_handle; |
37 | | |
38 | | void proto_register_rtcfg(void); |
39 | | void proto_reg_handoff_rtcfg(void); |
40 | | |
41 | 0 | #define RTMAC_TYPE_TDMA 0x0001 /* since version 2 */ |
42 | 0 | #define RTMAC_TYPE_TDMA_V1 0x9031 /* first TDMA version */ |
43 | | |
44 | | static const value_string rtmac_type_vals[] = { |
45 | | { RTMAC_TYPE_TDMA, "TDMA" }, |
46 | | { RTMAC_TYPE_TDMA_V1, "TDMA-V1" }, |
47 | | { 0, NULL } |
48 | | }; |
49 | | |
50 | 24 | #define RTMAC_FLAG_TUNNEL 0x01 |
51 | 15 | #define RTMAC_FLAGS_RES 0xFE |
52 | | |
53 | 0 | #define RTCFG_MSG_S1_CONFIG 0x0 |
54 | 0 | #define RTCFG_MSG_ANN_NEW 0x1 |
55 | 0 | #define RTCFG_MSG_ANN_REPLY 0x2 |
56 | 0 | #define RTCFG_MSG_S2_CONFIG 0x3 |
57 | 0 | #define RTCFG_MSG_S2_FRAG 0x4 |
58 | 0 | #define RTCFG_MSG_ACK 0x5 |
59 | 0 | #define RTCFG_MSG_READY 0x6 |
60 | 0 | #define RTCFG_MSG_HBEAT 0x7 |
61 | 1 | #define RTCFG_MSG_DEAD_STN 0x8 |
62 | | |
63 | | static const value_string rtcfg_msg_vals[] = { |
64 | | { RTCFG_MSG_S1_CONFIG, "Stage 1 Config" }, |
65 | | { RTCFG_MSG_ANN_NEW, "New Announce" }, |
66 | | { RTCFG_MSG_ANN_REPLY, "Reply Announce" }, |
67 | | { RTCFG_MSG_S2_CONFIG, "Stage 2 Config" }, |
68 | | { RTCFG_MSG_S2_FRAG, "Stage 2 Fragment" }, |
69 | | { RTCFG_MSG_ACK, "Acknowledge" }, |
70 | | { RTCFG_MSG_READY, "Ready" }, |
71 | | { RTCFG_MSG_HBEAT, "Heartbeat" }, |
72 | | { RTCFG_MSG_DEAD_STN, "Dead Station" }, |
73 | | { 0, NULL } |
74 | | }; |
75 | | |
76 | 1 | #define RTCFG_ADDRESS_TYPE_MAC 0x00 |
77 | 0 | #define RTCFG_ADDRESS_TYPE_IP 0x01 |
78 | | |
79 | | static const value_string rtcfg_address_type_vals[] = { |
80 | | { RTCFG_ADDRESS_TYPE_MAC, "MAC" }, |
81 | | { RTCFG_ADDRESS_TYPE_IP, "IP" }, |
82 | | { 0, NULL } |
83 | | }; |
84 | | |
85 | 0 | #define TDMA_V1_MSG_NOTIFY_MASTER 0x10 |
86 | 0 | #define TDMA_V1_MSG_REQUEST_TEST 0x11 |
87 | 0 | #define TDMA_V1_MSG_ACK_TEST 0x12 |
88 | 0 | #define TDMA_V1_MSG_REQUEST_CONF 0x13 |
89 | 0 | #define TDMA_V1_MSG_ACK_CONF 0x14 |
90 | 0 | #define TDMA_V1_MSG_ACK_ACK_CONF 0x15 |
91 | 0 | #define TDMA_V1_MSG_STATION_LIST 0x16 |
92 | 0 | #define TDMA_V1_MSG_REQUEST_CHANGE_OFFSET 0x17 |
93 | 0 | #define TDMA_V1_MSG_START_OF_FRAME 0x18 |
94 | | |
95 | | static const value_string tdma_v1_msg_vals[] = { |
96 | | { TDMA_V1_MSG_NOTIFY_MASTER, "Notify Master" }, |
97 | | { TDMA_V1_MSG_REQUEST_TEST, "Request Test" }, |
98 | | { TDMA_V1_MSG_ACK_TEST, "Acknowledge Test" }, |
99 | | { TDMA_V1_MSG_REQUEST_CONF, "Request Config" }, |
100 | | { TDMA_V1_MSG_ACK_CONF, "Acknowledge Config" }, |
101 | | { TDMA_V1_MSG_ACK_ACK_CONF, "Ack Ack Config" }, |
102 | | { TDMA_V1_MSG_STATION_LIST, "Station List" }, |
103 | | { TDMA_V1_MSG_REQUEST_CHANGE_OFFSET, "Request Change Offset" }, |
104 | | { TDMA_V1_MSG_START_OF_FRAME, "Start of Frame" }, |
105 | | { 0, NULL } |
106 | | }; |
107 | | |
108 | 0 | #define TDMA_MSG_SYNC 0x0000 |
109 | 0 | #define TDMA_MSG_CAL_REQUEST 0x0010 |
110 | 0 | #define TDMA_MSG_CAL_REPLY 0x0011 |
111 | | |
112 | | static const value_string tdma_msg_vals[] = { |
113 | | { TDMA_MSG_SYNC, "Synchronisation" }, |
114 | | { TDMA_MSG_CAL_REQUEST, "Request Calibration" }, |
115 | | { TDMA_MSG_CAL_REPLY, "Reply Calibration" }, |
116 | | { 0, NULL } |
117 | | }; |
118 | | |
119 | | static dissector_table_t ethertype_table; |
120 | | static dissector_handle_t data_handle; |
121 | | |
122 | | /* Define the rtnet proto */ |
123 | | static int proto_rtmac; |
124 | | static int proto_tdma; |
125 | | static int proto_rtcfg; |
126 | | |
127 | | /* RTmac Header */ |
128 | | static int hf_rtmac_header_type; |
129 | | static int hf_rtmac_header_ver; |
130 | | static int hf_rtmac_header_flags; |
131 | | static int hf_rtmac_header_flags_tunnel; |
132 | | static int hf_rtmac_header_flags_res; |
133 | | static int hf_rtmac_header_res_v1; |
134 | | |
135 | | |
136 | | /* RTcfg */ |
137 | | static int hf_rtcfg_vers_id; |
138 | | static int hf_rtcfg_vers; |
139 | | static int hf_rtcfg_id; |
140 | | static int hf_rtcfg_address_type; |
141 | | static int hf_rtcfg_client_ip_address; |
142 | | static int hf_rtcfg_server_ip_address; |
143 | | static int hf_rtcfg_burst_rate; |
144 | | static int hf_rtcfg_padding; |
145 | | static int hf_rtcfg_s1_config_length; |
146 | | static int hf_rtcfg_config_data; |
147 | | static int hf_rtcfg_client_flags; |
148 | | static int hf_rtcfg_client_flags_available; |
149 | | static int hf_rtcfg_client_flags_ready; |
150 | | static int hf_rtcfg_client_flags_res; |
151 | | static int hf_rtcfg_server_flags; |
152 | | static int hf_rtcfg_server_flags_res0; |
153 | | static int hf_rtcfg_server_flags_ready; |
154 | | static int hf_rtcfg_server_flags_res2; |
155 | | static int hf_rtcfg_active_stations; |
156 | | static int hf_rtcfg_heartbeat_period; |
157 | | static int hf_rtcfg_s2_config_length; |
158 | | static int hf_rtcfg_config_offset; |
159 | | static int hf_rtcfg_ack_length; |
160 | | static int hf_rtcfg_client_hw_address; |
161 | | |
162 | | |
163 | | /* TDMA-V1 */ |
164 | | static int hf_tdma_v1_msg; |
165 | | |
166 | | /* TDMA REQUEST_CONF */ |
167 | | static int hf_tdma_v1_msg_request_conf_station; |
168 | | static int hf_tdma_v1_msg_request_conf_padding; |
169 | | static int hf_tdma_v1_msg_request_conf_mtu; |
170 | | static int hf_tdma_v1_msg_request_conf_cycle; |
171 | | |
172 | | /* TDMA ACK_CONF */ |
173 | | static int hf_tdma_v1_msg_ack_conf_station; |
174 | | static int hf_tdma_v1_msg_ack_conf_padding; |
175 | | static int hf_tdma_v1_msg_ack_conf_mtu; |
176 | | static int hf_tdma_v1_msg_ack_conf_cycle; |
177 | | |
178 | | /* TDMA ACK_ACK_CONF */ |
179 | | static int hf_tdma_v1_msg_ack_ack_conf_station; |
180 | | static int hf_tdma_v1_msg_ack_ack_conf_padding; |
181 | | |
182 | | /* TDMA REQUEST_TEST */ |
183 | | static int hf_tdma_v1_msg_request_test_counter; |
184 | | static int hf_tdma_v1_msg_request_test_tx; |
185 | | |
186 | | /* TDMA ACK_TEST */ |
187 | | static int hf_tdma_v1_msg_ack_test_counter; |
188 | | static int hf_tdma_v1_msg_ack_test_tx; |
189 | | |
190 | | /* TDMA STATION_LIST */ |
191 | | static int hf_tdma_v1_msg_station_list_nr_stations; |
192 | | static int hf_tdma_v1_msg_station_list_padding; |
193 | | |
194 | | static int hf_tdma_v1_msg_station_list_ip; |
195 | | static int hf_tdma_v1_msg_station_list_nr; |
196 | | |
197 | | /* TDMA CHANGE_OFFSET */ |
198 | | static int hf_tdma_v1_msg_request_change_offset_offset; |
199 | | |
200 | | /* TDMA START_OF_FRAME */ |
201 | | static int hf_tdma_v1_msg_start_of_frame_timestamp; |
202 | | |
203 | | |
204 | | /* TDMA since version 2 */ |
205 | | static int hf_tdma_ver; |
206 | | static int hf_tdma_id; |
207 | | |
208 | | /* TDMA Sync */ |
209 | | static int hf_tdma_sync_cycle; |
210 | | static int hf_tdma_sync_xmit_stamp; |
211 | | static int hf_tdma_sync_sched_xmit; |
212 | | |
213 | | /* TDMA Request Calibration */ |
214 | | static int hf_tdma_req_cal_xmit_stamp; |
215 | | static int hf_tdma_req_cal_rpl_cycle; |
216 | | static int hf_tdma_req_cal_rpl_slot; |
217 | | |
218 | | /* TDMA Reply Calibration */ |
219 | | static int hf_tdma_rpl_cal_req_stamp; |
220 | | static int hf_tdma_rpl_cal_rcv_stamp; |
221 | | static int hf_tdma_rpl_cal_xmit_stamp; |
222 | | |
223 | | |
224 | | /* Define the tree for rtnet */ |
225 | | static int ett_rtmac; |
226 | | static int ett_rtmac_flags; |
227 | | static int ett_tdma; |
228 | | static int ett_rtcfg; |
229 | | |
230 | | static unsigned |
231 | | dissect_rtnet_tdma_notify_master(tvbuff_t *tvb _U_, unsigned offset, proto_tree *tree _U_) |
232 | 0 | { |
233 | 0 | return offset; |
234 | 0 | } |
235 | | |
236 | | static unsigned |
237 | | dissect_rtnet_tdma_request_test(tvbuff_t *tvb, unsigned offset, proto_tree *tree) |
238 | 0 | { |
239 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_request_test_counter, tvb, |
240 | 0 | offset, 4, ENC_LITTLE_ENDIAN ); |
241 | 0 | offset += 4; |
242 | |
|
243 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_request_test_tx, tvb, |
244 | 0 | offset, 8, ENC_LITTLE_ENDIAN ); |
245 | 0 | offset += 8; |
246 | |
|
247 | 0 | return offset; |
248 | 0 | } |
249 | | |
250 | | static unsigned |
251 | | dissect_rtnet_tdma_ack_test(tvbuff_t *tvb, unsigned offset, proto_tree *tree) |
252 | 0 | { |
253 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_ack_test_counter, tvb, |
254 | 0 | offset, 4, ENC_LITTLE_ENDIAN ); |
255 | 0 | offset += 4; |
256 | |
|
257 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_ack_test_tx, tvb, |
258 | 0 | offset, 8, ENC_LITTLE_ENDIAN ); |
259 | 0 | offset += 8; |
260 | |
|
261 | 0 | return offset; |
262 | 0 | } |
263 | | |
264 | | static unsigned |
265 | | dissect_rtnet_tdma_request_conf(tvbuff_t *tvb, unsigned offset, proto_tree *tree) |
266 | 0 | { |
267 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_request_conf_station, tvb, |
268 | 0 | offset, 1, ENC_BIG_ENDIAN ); |
269 | 0 | offset += 1; |
270 | |
|
271 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_request_conf_padding, tvb, |
272 | 0 | offset, 1, ENC_BIG_ENDIAN ); |
273 | 0 | offset += 1; |
274 | |
|
275 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_request_conf_mtu, tvb, |
276 | 0 | offset, 2, ENC_BIG_ENDIAN ); |
277 | 0 | offset += 2; |
278 | |
|
279 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_request_conf_cycle, tvb, |
280 | 0 | offset, 4, ENC_BIG_ENDIAN ); |
281 | 0 | offset += 4; |
282 | |
|
283 | 0 | return offset; |
284 | 0 | } |
285 | | |
286 | | |
287 | | static unsigned |
288 | | dissect_rtnet_tdma_ack_conf(tvbuff_t *tvb, unsigned offset, proto_tree *tree) |
289 | 0 | { |
290 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_ack_conf_station, tvb, |
291 | 0 | offset, 1, ENC_BIG_ENDIAN ); |
292 | 0 | offset += 1; |
293 | |
|
294 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_ack_conf_padding, tvb, |
295 | 0 | offset, 1, ENC_BIG_ENDIAN ); |
296 | 0 | offset += 1; |
297 | |
|
298 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_ack_conf_mtu, tvb, |
299 | 0 | offset, 2, ENC_BIG_ENDIAN ); |
300 | 0 | offset += 2; |
301 | |
|
302 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_ack_conf_cycle, tvb, |
303 | 0 | offset, 4, ENC_BIG_ENDIAN ); |
304 | 0 | offset += 4; |
305 | |
|
306 | 0 | return offset; |
307 | 0 | } |
308 | | |
309 | | static unsigned |
310 | 0 | dissect_rtnet_tdma_ack_ack_conf(tvbuff_t *tvb, unsigned offset, proto_tree *tree) { |
311 | |
|
312 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_ack_ack_conf_station, tvb, |
313 | 0 | offset, 1, ENC_BIG_ENDIAN ); |
314 | |
|
315 | 0 | offset += 1; |
316 | |
|
317 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_ack_ack_conf_padding, tvb, |
318 | 0 | offset, 3, ENC_NA ); |
319 | 0 | offset += 3; |
320 | |
|
321 | 0 | return offset; |
322 | 0 | } |
323 | | |
324 | | static unsigned |
325 | | dissect_rtnet_tdma_station_list(tvbuff_t *tvb, unsigned offset, proto_tree *tree) |
326 | 0 | { |
327 | 0 | uint8_t nr_stations; |
328 | 0 | uint8_t i; |
329 | |
|
330 | 0 | nr_stations = tvb_get_uint8(tvb, offset); |
331 | 0 | proto_tree_add_uint(tree, hf_tdma_v1_msg_station_list_nr_stations, tvb, |
332 | 0 | offset, 1, nr_stations); |
333 | |
|
334 | 0 | offset += 1; |
335 | |
|
336 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_station_list_padding, tvb, |
337 | 0 | offset, 3, ENC_NA ); |
338 | 0 | offset += 3; |
339 | | |
340 | |
|
341 | 0 | for( i = 0; i < nr_stations; i++ ) |
342 | 0 | { |
343 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_station_list_ip, tvb, |
344 | 0 | offset, 4, ENC_BIG_ENDIAN ); |
345 | |
|
346 | 0 | offset += 4; |
347 | |
|
348 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_station_list_nr, tvb, |
349 | 0 | offset, 1, ENC_BIG_ENDIAN ); |
350 | |
|
351 | 0 | offset += 1; |
352 | |
|
353 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_station_list_padding, tvb, |
354 | 0 | offset, 3, ENC_NA ); |
355 | 0 | offset += 3; |
356 | 0 | } |
357 | |
|
358 | 0 | return offset; |
359 | 0 | } |
360 | | |
361 | | static unsigned |
362 | | dissect_rtnet_tdma_request_change_offset(tvbuff_t *tvb, unsigned offset, proto_tree *tree) |
363 | 0 | { |
364 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_request_change_offset_offset, tvb, |
365 | 0 | offset, 4, ENC_BIG_ENDIAN ); |
366 | |
|
367 | 0 | offset += 4; |
368 | |
|
369 | 0 | return offset; |
370 | 0 | } |
371 | | |
372 | | static unsigned |
373 | | dissect_rtnet_tdma_start_of_frame(tvbuff_t *tvb, unsigned offset, proto_tree *tree) |
374 | 0 | { |
375 | 0 | proto_tree_add_item(tree, hf_tdma_v1_msg_start_of_frame_timestamp, tvb, |
376 | 0 | offset, 8, ENC_BIG_ENDIAN ); |
377 | 0 | offset += 8; |
378 | |
|
379 | 0 | return offset; |
380 | 0 | } |
381 | | |
382 | | static void |
383 | 0 | dissect_rtnet_tdma_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root) { |
384 | 0 | unsigned offset = 0; |
385 | 0 | uint32_t msg; |
386 | 0 | proto_tree *tree; |
387 | 0 | proto_item *ti; |
388 | 0 | char* str_msg; |
389 | | |
390 | | /* Set the protocol column */ |
391 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "TDMA-V1"); |
392 | |
|
393 | 0 | ti = proto_tree_add_item(root, proto_tdma, tvb, 0, -1, ENC_NA); |
394 | 0 | tree = proto_item_add_subtree(ti, ett_tdma); |
395 | |
|
396 | 0 | proto_tree_add_item_ret_uint(tree, hf_tdma_v1_msg, tvb, |
397 | 0 | offset, 4, ENC_BIG_ENDIAN, &msg); |
398 | 0 | offset += 4; |
399 | |
|
400 | 0 | str_msg = val_to_str(pinfo->pool, msg, tdma_v1_msg_vals, "Unknown (0x%04x)"); |
401 | 0 | proto_item_append_text(ti, ", Version 1, %s", str_msg); |
402 | | |
403 | | /* set the info column */ |
404 | 0 | col_add_str(pinfo->cinfo, COL_INFO, str_msg); |
405 | |
|
406 | 0 | switch( msg ) { |
407 | 0 | case TDMA_V1_MSG_NOTIFY_MASTER: |
408 | 0 | dissect_rtnet_tdma_notify_master(tvb, offset, tree); |
409 | 0 | break; |
410 | | |
411 | 0 | case TDMA_V1_MSG_REQUEST_TEST: |
412 | 0 | dissect_rtnet_tdma_request_test(tvb, offset, tree); |
413 | 0 | break; |
414 | | |
415 | 0 | case TDMA_V1_MSG_ACK_TEST: |
416 | 0 | dissect_rtnet_tdma_ack_test(tvb, offset, tree); |
417 | 0 | break; |
418 | | |
419 | 0 | case TDMA_V1_MSG_REQUEST_CONF: |
420 | 0 | dissect_rtnet_tdma_request_conf(tvb, offset, tree); |
421 | 0 | break; |
422 | | |
423 | 0 | case TDMA_V1_MSG_ACK_CONF: |
424 | 0 | dissect_rtnet_tdma_ack_conf(tvb, offset, tree); |
425 | 0 | break; |
426 | | |
427 | 0 | case TDMA_V1_MSG_ACK_ACK_CONF: |
428 | 0 | dissect_rtnet_tdma_ack_ack_conf(tvb, offset, tree); |
429 | 0 | break; |
430 | | |
431 | 0 | case TDMA_V1_MSG_STATION_LIST: |
432 | 0 | dissect_rtnet_tdma_station_list (tvb, offset, tree); |
433 | 0 | break; |
434 | | |
435 | 0 | case TDMA_V1_MSG_REQUEST_CHANGE_OFFSET: |
436 | 0 | dissect_rtnet_tdma_request_change_offset(tvb, offset, tree); |
437 | 0 | break; |
438 | | |
439 | 0 | case TDMA_V1_MSG_START_OF_FRAME: |
440 | 0 | dissect_rtnet_tdma_start_of_frame(tvb, offset, tree); |
441 | 0 | break; |
442 | | |
443 | 0 | default: |
444 | 0 | break; |
445 | 0 | } |
446 | 0 | } |
447 | | |
448 | | static void |
449 | 0 | dissect_tdma_sync(tvbuff_t *tvb, unsigned offset, proto_tree *tree) { |
450 | 0 | int64_t timestamp; |
451 | 0 | proto_item *ti; |
452 | |
|
453 | 0 | proto_tree_add_item(tree, hf_tdma_sync_cycle, tvb, offset, 4, ENC_BIG_ENDIAN); |
454 | 0 | offset += 4; |
455 | |
|
456 | 0 | ti = proto_tree_add_item(tree, hf_tdma_sync_xmit_stamp, tvb, offset, 8, ENC_BIG_ENDIAN); |
457 | 0 | timestamp = tvb_get_ntoh64(tvb, offset) - tvb_get_ntoh64(tvb, offset+8); |
458 | 0 | proto_item_append_text(ti, " (%s%" PRId64 ")", (timestamp > 0) ? "+" : "", timestamp); |
459 | 0 | offset += 8; |
460 | |
|
461 | 0 | proto_tree_add_item(tree, hf_tdma_sync_sched_xmit, tvb, offset, 8, ENC_BIG_ENDIAN); |
462 | 0 | } |
463 | | |
464 | | static void |
465 | 0 | dissect_tdma_request_cal(tvbuff_t *tvb, unsigned offset, proto_tree *tree) { |
466 | |
|
467 | 0 | proto_tree_add_item(tree, hf_tdma_req_cal_xmit_stamp, tvb, offset, 8, ENC_BIG_ENDIAN); |
468 | 0 | offset += 8; |
469 | |
|
470 | 0 | proto_tree_add_item(tree, hf_tdma_req_cal_rpl_cycle, tvb, offset, 4, ENC_BIG_ENDIAN); |
471 | 0 | offset += 4; |
472 | |
|
473 | 0 | proto_tree_add_item(tree, hf_tdma_req_cal_rpl_slot, tvb, offset, 8, ENC_BIG_ENDIAN); |
474 | 0 | } |
475 | | |
476 | | static void |
477 | 0 | dissect_tdma_reply_cal(tvbuff_t *tvb, unsigned offset, proto_tree *tree) { |
478 | 0 | int64_t timestamp; |
479 | 0 | proto_item *ti; |
480 | |
|
481 | 0 | proto_tree_add_item(tree, hf_tdma_rpl_cal_req_stamp, tvb, offset, 8, ENC_BIG_ENDIAN); |
482 | 0 | offset += 8; |
483 | |
|
484 | 0 | proto_tree_add_item(tree, hf_tdma_rpl_cal_rcv_stamp, tvb, offset, 8, ENC_BIG_ENDIAN); |
485 | |
|
486 | 0 | timestamp = tvb_get_ntoh64(tvb, offset+8) - tvb_get_ntoh64(tvb, offset); |
487 | 0 | offset += 8; |
488 | |
|
489 | 0 | ti = proto_tree_add_item(tree, hf_tdma_rpl_cal_xmit_stamp, tvb, offset, 8, ENC_BIG_ENDIAN); |
490 | 0 | proto_item_append_text(ti, " (%s%" PRId64 ")", (timestamp > 0) ? "+" : "", timestamp); |
491 | 0 | } |
492 | | |
493 | | static void |
494 | 0 | dissect_rtnet_tdma(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root) { |
495 | 0 | unsigned offset = 0; |
496 | 0 | uint32_t msg; |
497 | 0 | proto_item *ti; |
498 | 0 | proto_tree *tree; |
499 | 0 | char* str_msg; |
500 | | |
501 | | /* Set the protocol column */ |
502 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "TDMA"); |
503 | |
|
504 | 0 | ti = proto_tree_add_item(root, proto_tdma, tvb, 0, -1, ENC_NA); |
505 | 0 | tree = proto_item_add_subtree(ti, ett_tdma); |
506 | |
|
507 | 0 | proto_tree_add_item(tree, hf_tdma_ver, tvb, offset, 2, ENC_BIG_ENDIAN); |
508 | 0 | offset += 2; |
509 | |
|
510 | 0 | proto_tree_add_item_ret_uint(tree, hf_tdma_id, tvb, offset, 2, ENC_BIG_ENDIAN, &msg); |
511 | 0 | str_msg = val_to_str(pinfo->pool, msg, tdma_msg_vals, "Unknown (0x%04x)"); |
512 | 0 | offset += 2; |
513 | |
|
514 | 0 | proto_item_append_text(ti, ", %s", str_msg); |
515 | | /* Set the info column */ |
516 | 0 | col_add_str(pinfo->cinfo, COL_INFO, str_msg); |
517 | |
|
518 | 0 | switch (msg) { |
519 | 0 | case TDMA_MSG_SYNC: |
520 | 0 | dissect_tdma_sync(tvb, offset, tree); |
521 | 0 | break; |
522 | | |
523 | 0 | case TDMA_MSG_CAL_REQUEST: |
524 | 0 | dissect_tdma_request_cal(tvb, offset, tree); |
525 | 0 | break; |
526 | | |
527 | 0 | case TDMA_MSG_CAL_REPLY: |
528 | 0 | dissect_tdma_reply_cal(tvb, offset, tree); |
529 | 0 | break; |
530 | | |
531 | 0 | default: |
532 | 0 | break; |
533 | 0 | } |
534 | 0 | } |
535 | | |
536 | | static int |
537 | 4 | dissect_rtmac(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { |
538 | 4 | int offset = 0; |
539 | 4 | uint8_t ver,flags; |
540 | 4 | uint16_t type; |
541 | 4 | tvbuff_t *next_tvb; |
542 | 4 | proto_tree *ti=NULL, *rtmac_tree=NULL; |
543 | 4 | proto_item *item; |
544 | 4 | dissector_handle_t dissector=NULL; |
545 | 4 | const char *type_str=NULL; |
546 | | |
547 | | /* Read the header */ |
548 | 4 | type = tvb_get_ntohs(tvb, offset); |
549 | 4 | ver = tvb_get_uint8(tvb, offset+2); |
550 | 4 | flags = tvb_get_uint8(tvb, offset+3); |
551 | | |
552 | 4 | if (ver == 1) { |
553 | 1 | type_str = try_val_to_str(type, rtmac_type_vals); |
554 | 1 | if (!type_str) { |
555 | 1 | dissector = dissector_get_uint_handle(ethertype_table, type); |
556 | 1 | } |
557 | 3 | } else { |
558 | 3 | if (flags & RTMAC_FLAG_TUNNEL) { |
559 | 2 | dissector = dissector_get_uint_handle(ethertype_table, type); |
560 | 2 | } |
561 | 3 | } |
562 | 4 | if (!dissector) |
563 | 4 | dissector = data_handle; |
564 | | |
565 | 4 | if (tree) { |
566 | 4 | ti = proto_tree_add_item(tree, proto_rtmac, tvb, offset, 4, ENC_NA); |
567 | 4 | rtmac_tree = proto_item_add_subtree(ti, ett_rtmac); |
568 | 4 | proto_item_append_text(ti, ", Version %d", ver); |
569 | 4 | } |
570 | | |
571 | | /* Set the protocol column */ |
572 | 4 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTmac"); |
573 | | |
574 | | /* set the info column */ |
575 | 4 | col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown (0x%04x)",type); |
576 | | |
577 | 4 | if (rtmac_tree) { |
578 | 4 | if (ver == 1) { |
579 | 1 | if (!type_str) { |
580 | 1 | if (dissector != data_handle) |
581 | 0 | type_str = dissector_handle_get_protocol_short_name(dissector); |
582 | 1 | else |
583 | 1 | type_str = "Unknown"; |
584 | 1 | } |
585 | 3 | } else { |
586 | 3 | if (!(flags & RTMAC_FLAG_TUNNEL)) |
587 | 1 | type_str = val_to_str_const(type, rtmac_type_vals, "Unknown"); |
588 | 2 | else { |
589 | 2 | if (dissector != data_handle) |
590 | 0 | type_str = dissector_handle_get_protocol_short_name(dissector); |
591 | 2 | else |
592 | 2 | type_str = "Unknown"; |
593 | 2 | } |
594 | 3 | } |
595 | 4 | proto_tree_add_string_format_value(rtmac_tree, hf_rtmac_header_type, tvb, offset, 2, |
596 | 4 | type_str, "%s (0x%04x)", type_str, type); |
597 | 4 | offset += 2; |
598 | | |
599 | 4 | proto_tree_add_item(rtmac_tree, hf_rtmac_header_ver, tvb, offset, 1, ENC_BIG_ENDIAN); |
600 | 4 | offset += 1; |
601 | | |
602 | 4 | if (ver == 1) |
603 | 1 | proto_tree_add_item(rtmac_tree, hf_rtmac_header_res_v1, tvb, offset, 1, ENC_BIG_ENDIAN); |
604 | 3 | else { |
605 | 3 | item = proto_tree_add_item(rtmac_tree, hf_rtmac_header_flags, tvb, offset, 1, ENC_BIG_ENDIAN); |
606 | 3 | ti = proto_item_add_subtree(item, ett_rtmac_flags); |
607 | 3 | proto_tree_add_item(ti, hf_rtmac_header_flags_res, tvb, offset, 1, ENC_BIG_ENDIAN); |
608 | 3 | proto_tree_add_item(ti, hf_rtmac_header_flags_tunnel, tvb, offset, 1, ENC_BIG_ENDIAN); |
609 | 3 | } |
610 | 4 | offset += 1; |
611 | 4 | } |
612 | 0 | else |
613 | 0 | offset += 4; |
614 | | |
615 | 4 | next_tvb = tvb_new_subset_remaining(tvb, offset); |
616 | | |
617 | 4 | if (ver == 1) { |
618 | 1 | switch (type) { |
619 | 0 | case RTMAC_TYPE_TDMA_V1: |
620 | 0 | dissect_rtnet_tdma_v1(next_tvb, pinfo, tree); |
621 | 0 | break; |
622 | | |
623 | 1 | default: |
624 | 1 | call_dissector(dissector, next_tvb, pinfo, tree); |
625 | 1 | break; |
626 | 1 | } |
627 | 3 | } else { |
628 | 3 | if (flags & RTMAC_FLAG_TUNNEL) |
629 | 2 | call_dissector(dissector, next_tvb, pinfo, tree); |
630 | 1 | else { |
631 | 1 | switch (type) { |
632 | 0 | case RTMAC_TYPE_TDMA: |
633 | 0 | dissect_rtnet_tdma(next_tvb, pinfo, tree); |
634 | 0 | break; |
635 | | |
636 | 1 | default: |
637 | 1 | call_dissector(data_handle, next_tvb, pinfo, tree); |
638 | 1 | break; |
639 | 1 | } |
640 | 1 | } |
641 | 3 | } |
642 | | |
643 | 4 | return tvb_captured_length(tvb); |
644 | 4 | } |
645 | | |
646 | | static int |
647 | 1 | dissect_rtcfg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { |
648 | 1 | int offset = 0; |
649 | 1 | proto_tree *vers_id_tree, *vers_id_item, *flags_tree, *flags_item; |
650 | 1 | uint32_t vers_id; |
651 | 1 | uint8_t addr_type; |
652 | 1 | uint32_t config_length,len; |
653 | 1 | proto_tree *ti=NULL,*rtcfg_tree=NULL; |
654 | 1 | char* str_vers_id; |
655 | | |
656 | | /* Set the protocol column */ |
657 | 1 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "RTcfg"); |
658 | | |
659 | | /* Clear out stuff in the info column */ |
660 | 1 | col_clear(pinfo->cinfo, COL_INFO); |
661 | | |
662 | 1 | if (tree) { |
663 | 1 | ti = proto_tree_add_item(tree, proto_rtcfg, tvb, offset, -1, ENC_NA); |
664 | 1 | rtcfg_tree = proto_item_add_subtree(ti, ett_rtcfg); |
665 | 1 | } |
666 | | |
667 | 1 | vers_id_item = proto_tree_add_item_ret_uint(rtcfg_tree, hf_rtcfg_vers_id, tvb, |
668 | 1 | offset, 1, ENC_NA, &vers_id); |
669 | | |
670 | 1 | vers_id_tree=proto_item_add_subtree(vers_id_item, ett_rtcfg); |
671 | 1 | proto_tree_add_item(vers_id_tree, hf_rtcfg_vers, tvb, offset, 1, ENC_BIG_ENDIAN); |
672 | 1 | proto_tree_add_item(vers_id_tree, hf_rtcfg_id, tvb, offset, 1, ENC_BIG_ENDIAN); |
673 | 1 | offset += 1; |
674 | | |
675 | 1 | str_vers_id = val_to_str(pinfo->pool, vers_id, rtcfg_msg_vals, "Unknown (0x%04x)"); |
676 | 1 | proto_item_append_text(ti, ", Version %d, %s", (vers_id >> 5), str_vers_id); |
677 | | |
678 | 1 | col_add_str(pinfo->cinfo, COL_INFO, str_vers_id); |
679 | | |
680 | 1 | switch( vers_id & 0x1f ) |
681 | 1 | { |
682 | 0 | case RTCFG_MSG_S1_CONFIG: |
683 | 0 | addr_type = tvb_get_uint8(tvb, offset); |
684 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_address_type, tvb, offset, 1, ENC_BIG_ENDIAN ); |
685 | 0 | offset += 1; |
686 | |
|
687 | 0 | switch( addr_type ) |
688 | 0 | { |
689 | 0 | case RTCFG_ADDRESS_TYPE_MAC: |
690 | | /* nothing */ |
691 | 0 | break; |
692 | | |
693 | 0 | case RTCFG_ADDRESS_TYPE_IP: |
694 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_client_ip_address, tvb, offset, 4, ENC_BIG_ENDIAN ); |
695 | 0 | offset += 4; |
696 | |
|
697 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_server_ip_address, tvb, offset, 4, ENC_BIG_ENDIAN ); |
698 | 0 | offset += 4; |
699 | |
|
700 | 0 | break; |
701 | 0 | } |
702 | | |
703 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_burst_rate, tvb, offset, 1, ENC_BIG_ENDIAN ); |
704 | 0 | offset += 1; |
705 | |
|
706 | 0 | config_length = tvb_get_ntohs( tvb, offset ); |
707 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_s1_config_length, tvb, offset, 2, ENC_BIG_ENDIAN ); |
708 | 0 | offset += 2; |
709 | |
|
710 | 0 | if( config_length > 0 ) { |
711 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_config_data, tvb, offset, config_length, ENC_NA ); |
712 | | /*offset += config_length;*/ |
713 | 0 | } |
714 | |
|
715 | 0 | break; |
716 | | |
717 | 0 | case RTCFG_MSG_ANN_NEW: |
718 | 0 | addr_type = tvb_get_uint8(tvb, offset); |
719 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_address_type, tvb, offset, 1, ENC_BIG_ENDIAN ); |
720 | 0 | offset += 1; |
721 | |
|
722 | 0 | switch( addr_type ) |
723 | 0 | { |
724 | 0 | case RTCFG_ADDRESS_TYPE_MAC: |
725 | | /* nothing */ |
726 | 0 | break; |
727 | | |
728 | 0 | case RTCFG_ADDRESS_TYPE_IP: |
729 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_client_ip_address, tvb, offset, 4, ENC_BIG_ENDIAN ); |
730 | 0 | offset += 4; |
731 | 0 | break; |
732 | 0 | } |
733 | | |
734 | 0 | flags_item = proto_tree_add_item(rtcfg_tree, hf_rtcfg_client_flags, tvb, |
735 | 0 | offset, 1, ENC_BIG_ENDIAN); |
736 | |
|
737 | 0 | flags_tree=proto_item_add_subtree(flags_item, ett_rtcfg); |
738 | 0 | proto_tree_add_item(flags_tree, hf_rtcfg_client_flags_available, tvb, offset, 1, ENC_BIG_ENDIAN); |
739 | 0 | proto_tree_add_item(flags_tree, hf_rtcfg_client_flags_ready, tvb, offset, 1, ENC_BIG_ENDIAN); |
740 | 0 | proto_tree_add_item(flags_tree, hf_rtcfg_client_flags_res, tvb, offset, 1, ENC_BIG_ENDIAN); |
741 | 0 | offset += 1; |
742 | |
|
743 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_burst_rate, tvb, offset, 1, ENC_BIG_ENDIAN ); |
744 | | /*offset += 1;*/ |
745 | |
|
746 | 0 | break; |
747 | | |
748 | 0 | case RTCFG_MSG_ANN_REPLY: |
749 | 0 | addr_type = tvb_get_uint8(tvb, offset); |
750 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_address_type, tvb, offset, 1, ENC_BIG_ENDIAN ); |
751 | 0 | offset += 1; |
752 | |
|
753 | 0 | switch( addr_type ) |
754 | 0 | { |
755 | 0 | case RTCFG_ADDRESS_TYPE_MAC: |
756 | | /* nothing */ |
757 | 0 | break; |
758 | | |
759 | 0 | case RTCFG_ADDRESS_TYPE_IP: |
760 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_client_ip_address, tvb, offset, 4, ENC_BIG_ENDIAN ); |
761 | 0 | offset += 4; |
762 | 0 | break; |
763 | 0 | } |
764 | | |
765 | 0 | flags_item = proto_tree_add_item(rtcfg_tree, hf_rtcfg_client_flags, tvb, |
766 | 0 | offset, 1, ENC_BIG_ENDIAN); |
767 | |
|
768 | 0 | flags_tree=proto_item_add_subtree(flags_item, ett_rtcfg); |
769 | 0 | proto_tree_add_item(flags_tree, hf_rtcfg_client_flags_available, tvb, offset, 1, ENC_BIG_ENDIAN); |
770 | 0 | proto_tree_add_item(flags_tree, hf_rtcfg_client_flags_ready, tvb, offset, 1, ENC_BIG_ENDIAN); |
771 | 0 | proto_tree_add_item(flags_tree, hf_rtcfg_client_flags_res, tvb, offset, 1, ENC_BIG_ENDIAN); |
772 | 0 | offset += 1; |
773 | |
|
774 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_padding, tvb, offset, 1, ENC_BIG_ENDIAN ); |
775 | | /*offset += 1;*/ |
776 | |
|
777 | 0 | break; |
778 | | |
779 | 0 | case RTCFG_MSG_S2_CONFIG: |
780 | 0 | flags_item = proto_tree_add_item(rtcfg_tree, hf_rtcfg_server_flags, tvb, |
781 | 0 | offset, 1, ENC_BIG_ENDIAN); |
782 | |
|
783 | 0 | flags_tree=proto_item_add_subtree(flags_item, ett_rtcfg); |
784 | 0 | proto_tree_add_item(flags_tree, hf_rtcfg_server_flags_res0, tvb, offset, 1, ENC_BIG_ENDIAN); |
785 | 0 | proto_tree_add_item(flags_tree, hf_rtcfg_server_flags_ready, tvb, offset, 1, ENC_BIG_ENDIAN); |
786 | 0 | proto_tree_add_item(flags_tree, hf_rtcfg_server_flags_res2, tvb, offset, 1, ENC_BIG_ENDIAN); |
787 | 0 | offset += 1; |
788 | |
|
789 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_active_stations, tvb, offset, 4, ENC_BIG_ENDIAN ); |
790 | 0 | offset += 4; |
791 | |
|
792 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_heartbeat_period, tvb, offset, 2, ENC_BIG_ENDIAN ); |
793 | 0 | offset += 2; |
794 | |
|
795 | 0 | config_length = tvb_get_ntohl( tvb, offset ); |
796 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_s2_config_length, tvb, offset, 4, ENC_BIG_ENDIAN ); |
797 | 0 | offset += 4; |
798 | |
|
799 | 0 | if( config_length > 0 ) { |
800 | 0 | len = tvb_reported_length_remaining(tvb, offset); |
801 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_config_data, tvb, offset, len, ENC_NA ); |
802 | | /*offset += len;*/ |
803 | 0 | } |
804 | |
|
805 | 0 | break; |
806 | | |
807 | 0 | case RTCFG_MSG_S2_FRAG: |
808 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_config_offset, tvb, offset, 4, ENC_BIG_ENDIAN ); |
809 | 0 | offset += 4; |
810 | |
|
811 | 0 | len = tvb_reported_length_remaining(tvb, offset); |
812 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_config_data, tvb, offset, len, ENC_NA ); |
813 | | /*offset += len;*/ |
814 | 0 | break; |
815 | | |
816 | 0 | case RTCFG_MSG_ACK: |
817 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_ack_length, tvb, offset, 4, ENC_BIG_ENDIAN ); |
818 | | /*offset += 4;*/ |
819 | |
|
820 | 0 | break; |
821 | | |
822 | 0 | case RTCFG_MSG_READY: |
823 | 0 | break; |
824 | | |
825 | 0 | case RTCFG_MSG_HBEAT: |
826 | 0 | break; |
827 | | |
828 | 1 | case RTCFG_MSG_DEAD_STN: |
829 | 1 | addr_type = tvb_get_uint8(tvb, offset); |
830 | 1 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_address_type, tvb, offset, 1, ENC_BIG_ENDIAN ); |
831 | 1 | offset += 1; |
832 | | |
833 | 1 | switch( addr_type ) |
834 | 1 | { |
835 | 1 | case RTCFG_ADDRESS_TYPE_MAC: |
836 | | /* nothing */ |
837 | 1 | break; |
838 | | |
839 | 0 | case RTCFG_ADDRESS_TYPE_IP: |
840 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_client_ip_address, tvb, offset, 4, ENC_BIG_ENDIAN ); |
841 | 0 | offset += 4; |
842 | 0 | break; |
843 | 1 | } |
844 | | |
845 | | /* |
846 | | * Infer the type of the physical address from the type of the |
847 | | * source address of this packet. |
848 | | */ |
849 | 1 | switch( pinfo->dl_src.type ) |
850 | 1 | { |
851 | 1 | case AT_ETHER: |
852 | 1 | proto_tree_add_bytes_format_value( rtcfg_tree, hf_rtcfg_client_hw_address, tvb, offset, 32, |
853 | 1 | NULL, "%s", |
854 | 1 | tvb_ether_to_str(pinfo->pool, tvb, offset)); |
855 | 1 | break; |
856 | | |
857 | 0 | default: |
858 | 0 | proto_tree_add_item( rtcfg_tree, hf_rtcfg_client_hw_address, tvb, offset, 32, ENC_NA ); |
859 | 0 | break; |
860 | 1 | } |
861 | | /*offset += 32;*/ |
862 | | |
863 | 0 | break; |
864 | | |
865 | 1 | } |
866 | | |
867 | 0 | return tvb_captured_length(tvb); |
868 | 1 | } |
869 | | |
870 | | void |
871 | 15 | proto_register_rtmac(void) { |
872 | 15 | static hf_register_info hf_array_rtmac[] = { |
873 | | |
874 | | /* RTmac header */ |
875 | 15 | { &hf_rtmac_header_type, |
876 | 15 | { "Type", |
877 | 15 | "rtmac.header.type", |
878 | 15 | FT_STRING, BASE_NONE, NULL, 0x0, |
879 | 15 | "RTmac Type", HFILL }}, |
880 | | |
881 | 15 | { &hf_rtmac_header_ver, |
882 | 15 | { "Version", |
883 | 15 | "rtmac.header.ver", |
884 | 15 | FT_UINT16, BASE_DEC, NULL, 0x0, |
885 | 15 | "RTmac Version", HFILL }}, |
886 | | |
887 | 15 | { &hf_rtmac_header_flags, |
888 | 15 | { "Flags", |
889 | 15 | "rtmac.header.flags", |
890 | 15 | FT_UINT8, BASE_HEX, NULL, 0x0, |
891 | 15 | "RTmac Flags", HFILL }}, |
892 | | |
893 | 15 | { &hf_rtmac_header_flags_tunnel, |
894 | 15 | { "Tunnelling Flag", |
895 | 15 | "rtmac.header.flags.tunnel", |
896 | 15 | FT_BOOLEAN, 8, TFS(&tfs_set_notset), RTMAC_FLAG_TUNNEL, |
897 | 15 | "RTmac Tunnelling Flag", HFILL }}, |
898 | | |
899 | 15 | { &hf_rtmac_header_flags_res, |
900 | 15 | { "Reserved Flags", |
901 | 15 | "rtmac.header.flags.res", |
902 | 15 | FT_UINT8, BASE_HEX, NULL, RTMAC_FLAGS_RES, |
903 | 15 | "RTmac Reserved Flags", HFILL }}, |
904 | | |
905 | 15 | { &hf_rtmac_header_res_v1, |
906 | 15 | { "Reserved", |
907 | 15 | "rtmac.header.res", |
908 | 15 | FT_UINT8, BASE_HEX, NULL, 0x0, |
909 | 15 | "RTmac Reserved", HFILL }}, |
910 | 15 | }; |
911 | | |
912 | 15 | static hf_register_info hf_array_tdma[] = { |
913 | | |
914 | | /* TDMA msg */ |
915 | 15 | { &hf_tdma_v1_msg, |
916 | 15 | { "Message", |
917 | 15 | "tdma-v1.msg", |
918 | 15 | FT_UINT32, BASE_HEX, VALS(tdma_v1_msg_vals), 0x0, |
919 | 15 | "TDMA-V1 Message", HFILL }}, |
920 | | |
921 | | /* TDMA request conf */ |
922 | | |
923 | 15 | { &hf_tdma_v1_msg_request_conf_station, |
924 | 15 | { "Station", |
925 | 15 | "tdma-v1.msg.request_conf.station", |
926 | 15 | FT_UINT8, BASE_DEC, NULL, 0x0, |
927 | 15 | "TDMA Station", HFILL }}, |
928 | | |
929 | 15 | { &hf_tdma_v1_msg_request_conf_padding, |
930 | 15 | { "Padding", |
931 | 15 | "tdma-v1.msg.request_conf.padding", |
932 | 15 | FT_UINT8, BASE_HEX, NULL, 0x0, |
933 | 15 | "TDMA Padding", HFILL }}, |
934 | | |
935 | 15 | { &hf_tdma_v1_msg_request_conf_mtu, |
936 | 15 | { "MTU", |
937 | 15 | "tdma-v1.msg.request_conf.mtu", |
938 | 15 | FT_UINT16, BASE_DEC, NULL, 0x0, |
939 | 15 | "TDMA MTU", HFILL }}, |
940 | | |
941 | 15 | { &hf_tdma_v1_msg_request_conf_cycle, |
942 | 15 | { "Cycle", |
943 | 15 | "tdma-v1.msg.request_conf.cycle", |
944 | 15 | FT_UINT32, BASE_DEC, NULL, 0x0, |
945 | 15 | "TDMA Cycle", HFILL }}, |
946 | | |
947 | | /* TDMA ack conf */ |
948 | | |
949 | 15 | { &hf_tdma_v1_msg_ack_conf_station, |
950 | 15 | { "Station", |
951 | 15 | "tdma-v1.msg.ack_conf.station", |
952 | 15 | FT_UINT8, BASE_DEC, NULL, 0x0, |
953 | 15 | "TDMA Station", HFILL }}, |
954 | | |
955 | 15 | { &hf_tdma_v1_msg_ack_conf_padding, |
956 | 15 | { "Padding", |
957 | 15 | "tdma-v1.msg.ack_conf.padding", |
958 | 15 | FT_UINT8, BASE_HEX, NULL, 0x0, |
959 | 15 | "TDMA Padding", HFILL }}, |
960 | | |
961 | 15 | { &hf_tdma_v1_msg_ack_conf_mtu, |
962 | 15 | { "MTU", |
963 | 15 | "tdma-v1.msg.ack_conf.mtu", |
964 | 15 | FT_UINT16, BASE_DEC, NULL, 0x0, |
965 | 15 | "TDMA MTU", HFILL }}, |
966 | | |
967 | 15 | { &hf_tdma_v1_msg_ack_conf_cycle, |
968 | 15 | { "Cycle", |
969 | 15 | "tdma-v1.msg.ack_conf.cycle", |
970 | 15 | FT_UINT32, BASE_DEC, NULL, 0x0, |
971 | 15 | "TDMA Cycle", HFILL }}, |
972 | | |
973 | | /* TDMA ack ack conf */ |
974 | | |
975 | 15 | { &hf_tdma_v1_msg_ack_ack_conf_station, |
976 | 15 | { "Station", |
977 | 15 | "tdma-v1.msg.ack_ack_conf.station", |
978 | 15 | FT_UINT8, BASE_DEC, NULL, 0x0, |
979 | 15 | "TDMA Station", HFILL }}, |
980 | | |
981 | 15 | { &hf_tdma_v1_msg_ack_ack_conf_padding, |
982 | 15 | { "Padding", |
983 | 15 | "tdma-v1.msg.ack_ack_conf.padding", |
984 | 15 | FT_BYTES, BASE_NONE, NULL, 0x0, |
985 | 15 | "TDMA Padding", HFILL }}, |
986 | | |
987 | | /* TDMA request test */ |
988 | | |
989 | 15 | { &hf_tdma_v1_msg_request_test_counter, |
990 | 15 | { "Counter", |
991 | 15 | "tdma-v1.msg.request_test.counter", |
992 | 15 | FT_UINT32, BASE_DEC, NULL, 0x0, |
993 | 15 | "TDMA Counter", HFILL }}, |
994 | | |
995 | 15 | { &hf_tdma_v1_msg_request_test_tx, |
996 | 15 | { "TX", |
997 | 15 | "tdma-v1.msg.request_test.tx", |
998 | 15 | FT_UINT64, BASE_DEC, NULL, 0x0, |
999 | 15 | "TDMA TX", HFILL }}, |
1000 | | |
1001 | | /* TDMA ack test */ |
1002 | | |
1003 | 15 | { &hf_tdma_v1_msg_ack_test_counter, |
1004 | 15 | { "Counter", |
1005 | 15 | "tdma-v1.msg.ack_test.counter", |
1006 | 15 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1007 | 15 | "TDMA Counter", HFILL }}, |
1008 | | |
1009 | 15 | { &hf_tdma_v1_msg_ack_test_tx, |
1010 | 15 | { "TX", |
1011 | 15 | "tdma-v1.msg.ack_test.tx", |
1012 | 15 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1013 | 15 | "TDMA TX", HFILL }}, |
1014 | | |
1015 | | /* TDMA ack test */ |
1016 | | |
1017 | 15 | { &hf_tdma_v1_msg_request_change_offset_offset, |
1018 | 15 | { "Offset", |
1019 | 15 | "tdma-v1.msg.request_change_offset.offset", |
1020 | 15 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1021 | 15 | "TDMA Offset", HFILL }}, |
1022 | | |
1023 | | /* TDMA start of frame */ |
1024 | | |
1025 | | |
1026 | 15 | { &hf_tdma_v1_msg_start_of_frame_timestamp, |
1027 | 15 | { "Timestamp", |
1028 | 15 | "tdma-v1.msg.start_of_frame.timestamp", |
1029 | 15 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1030 | 15 | "TDMA Timestamp", HFILL }}, |
1031 | | |
1032 | | /* TDMA station list */ |
1033 | | |
1034 | 15 | { &hf_tdma_v1_msg_station_list_nr_stations, |
1035 | 15 | { "Nr. Stations", |
1036 | 15 | "tdma-v1.msg.station_list.nr_stations", |
1037 | 15 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1038 | 15 | "TDMA Nr. Stations", HFILL }}, |
1039 | | |
1040 | 15 | { &hf_tdma_v1_msg_station_list_nr, |
1041 | 15 | { "Nr.", |
1042 | 15 | "tdma-v1.msg.station_list.nr", |
1043 | 15 | FT_UINT8, BASE_DEC, NULL, 0x0, |
1044 | 15 | "TDMA Station Number", HFILL }}, |
1045 | | |
1046 | 15 | { &hf_tdma_v1_msg_station_list_ip, |
1047 | 15 | { "IP", |
1048 | 15 | "tdma-v1.msg.station_list.ip", |
1049 | 15 | FT_IPv4, BASE_NONE, NULL, 0x0, |
1050 | 15 | "TDMA Station IP", HFILL }}, |
1051 | | |
1052 | 15 | { &hf_tdma_v1_msg_station_list_padding, |
1053 | 15 | { "Padding", |
1054 | 15 | "tdma-v1.msg.station_list.padding", |
1055 | 15 | FT_BYTES, BASE_NONE, NULL, 0x0, |
1056 | 15 | "TDMA Padding", HFILL }}, |
1057 | | |
1058 | | |
1059 | | /* TDMA since version 2 */ |
1060 | | |
1061 | 15 | { &hf_tdma_ver, |
1062 | 15 | { "Version", |
1063 | 15 | "tdma.ver", |
1064 | 15 | FT_UINT16, BASE_HEX, NULL, 0x0, |
1065 | 15 | "TDMA Version", HFILL }}, |
1066 | | |
1067 | 15 | { &hf_tdma_id, |
1068 | 15 | { "Message ID", |
1069 | 15 | "tdma.id", |
1070 | 15 | FT_UINT16, BASE_HEX, VALS(tdma_msg_vals), 0x0, |
1071 | 15 | "TDMA Message ID", HFILL }}, |
1072 | | |
1073 | | /* TDMA sync */ |
1074 | | |
1075 | 15 | { &hf_tdma_sync_cycle, |
1076 | 15 | { "Cycle Number", |
1077 | 15 | "tdma.sync.cycle", |
1078 | 15 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1079 | 15 | "TDMA Sync Cycle Number", HFILL }}, |
1080 | | |
1081 | 15 | { &hf_tdma_sync_xmit_stamp, |
1082 | 15 | { "Transmission Time Stamp", |
1083 | 15 | "tdma.sync.xmit_stamp", |
1084 | 15 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1085 | 15 | "TDMA Sync Transmission Time Stamp", HFILL }}, |
1086 | | |
1087 | 15 | { &hf_tdma_sync_sched_xmit, |
1088 | 15 | { "Scheduled Transmission Time", |
1089 | 15 | "tdma.sync.sched_xmit", |
1090 | 15 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1091 | 15 | "TDMA Sync Scheduled Transmission Time", HFILL }}, |
1092 | | |
1093 | | /* TDMA request calibration */ |
1094 | | |
1095 | 15 | { &hf_tdma_req_cal_xmit_stamp, |
1096 | 15 | { "Transmission Time Stamp", |
1097 | 15 | "tdma.req_cal.xmit_stamp", |
1098 | 15 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1099 | 15 | "TDMA Request Calibration Transmission Time Stamp", HFILL }}, |
1100 | | |
1101 | 15 | { &hf_tdma_req_cal_rpl_cycle, |
1102 | 15 | { "Reply Cycle Number", |
1103 | 15 | "tdma.req_cal.rpl_cycle", |
1104 | 15 | FT_UINT32, BASE_DEC, NULL, 0x0, |
1105 | 15 | "TDMA Request Calibration Reply Cycle Number", HFILL }}, |
1106 | | |
1107 | 15 | { &hf_tdma_req_cal_rpl_slot, |
1108 | 15 | { "Reply Slot Offset", |
1109 | 15 | "tdma.req_cal.rpl_slot", |
1110 | 15 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1111 | 15 | "TDMA Request Calibration Reply Slot Offset", HFILL }}, |
1112 | | |
1113 | | /* TDMA reply calibration */ |
1114 | | |
1115 | 15 | { &hf_tdma_rpl_cal_req_stamp, |
1116 | 15 | { "Request Transmission Time", |
1117 | 15 | "tdma.rpl_cal.req_stamp", |
1118 | 15 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1119 | 15 | "TDMA Reply Calibration Request Transmission Time", HFILL }}, |
1120 | | |
1121 | 15 | { &hf_tdma_rpl_cal_rcv_stamp, |
1122 | 15 | { "Reception Time Stamp", |
1123 | 15 | "tdma.rpl_cal.rcv_stamp", |
1124 | 15 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1125 | 15 | "TDMA Reply Calibration Reception Time Stamp", HFILL }}, |
1126 | | |
1127 | 15 | { &hf_tdma_rpl_cal_xmit_stamp, |
1128 | 15 | { "Transmission Time Stamp", |
1129 | 15 | "tdma.rpl_cal.xmit_stamp", |
1130 | 15 | FT_UINT64, BASE_DEC, NULL, 0x0, |
1131 | 15 | "TDMA Reply Calibration Transmission Time Stamp", HFILL }}, |
1132 | 15 | }; |
1133 | | |
1134 | 15 | static int *ett_array_rtmac[] = { |
1135 | 15 | &ett_rtmac, |
1136 | 15 | &ett_rtmac_flags, |
1137 | 15 | }; |
1138 | | |
1139 | 15 | static int *ett_array_tdma[] = { |
1140 | 15 | &ett_tdma, |
1141 | 15 | }; |
1142 | | |
1143 | 15 | proto_rtmac = proto_register_protocol("Real-Time Media Access Control", "RTmac", "rtmac"); |
1144 | 15 | proto_register_field_array(proto_rtmac, hf_array_rtmac, array_length(hf_array_rtmac)); |
1145 | 15 | proto_register_subtree_array(ett_array_rtmac, array_length(ett_array_rtmac)); |
1146 | | |
1147 | 15 | rtmac_handle = register_dissector("rtmac", dissect_rtmac, proto_rtmac); |
1148 | | |
1149 | 15 | proto_tdma = proto_register_protocol("TDMA RTmac Discipline", "TDMA", "tdma"); |
1150 | 15 | proto_register_field_array(proto_rtmac, hf_array_tdma, array_length(hf_array_tdma)); |
1151 | 15 | proto_register_subtree_array(ett_array_tdma, array_length(ett_array_tdma)); |
1152 | 15 | } |
1153 | | |
1154 | | |
1155 | | void |
1156 | 15 | proto_register_rtcfg(void) { |
1157 | 15 | static hf_register_info hf[] = { |
1158 | 15 | { &hf_rtcfg_vers_id, |
1159 | 15 | { "Version and ID", |
1160 | 15 | "rtcfg.vers_id", |
1161 | 15 | FT_UINT8, BASE_HEX, NULL, 0x0, |
1162 | 15 | "RTcfg Version and ID", HFILL }}, |
1163 | | |
1164 | 15 | { &hf_rtcfg_vers, |
1165 | 15 | { "Version", |
1166 | 15 | "rtcfg.vers", |
1167 | 15 | FT_UINT8, BASE_DEC, NULL, 0xe0, |
1168 | 15 | "RTcfg Version", HFILL }}, |
1169 | | |
1170 | 15 | { &hf_rtcfg_id, |
1171 | 15 | { "ID", |
1172 | 15 | "rtcfg.id", |
1173 | 15 | FT_UINT8, BASE_HEX, VALS(rtcfg_msg_vals), 0x1f, |
1174 | 15 | "RTcfg ID", HFILL }}, |
1175 | | |
1176 | 15 | { &hf_rtcfg_address_type, |
1177 | 15 | { "Address Type", |
1178 | 15 | "rtcfg.address_type", |
1179 | 15 | FT_UINT8, BASE_DEC, VALS(rtcfg_address_type_vals), 0x00, |
1180 | 15 | "RTcfg Address Type", HFILL }}, |
1181 | | |
1182 | 15 | { &hf_rtcfg_client_ip_address, |
1183 | 15 | { "Client IP Address", |
1184 | 15 | "rtcfg.client_ip_address", |
1185 | 15 | FT_IPv4, BASE_NONE, NULL, 0x0, |
1186 | 15 | "RTcfg Client IP Address", HFILL }}, |
1187 | | |
1188 | 15 | { &hf_rtcfg_server_ip_address, |
1189 | 15 | { "Server IP Address", |
1190 | 15 | "rtcfg.server_ip_address", |
1191 | 15 | FT_IPv4, BASE_NONE, NULL, 0x0, |
1192 | 15 | "RTcfg Server IP Address", HFILL }}, |
1193 | | |
1194 | 15 | { &hf_rtcfg_burst_rate, |
1195 | 15 | { "Stage 2 Burst Rate", |
1196 | 15 | "rtcfg.burst_rate", |
1197 | 15 | FT_UINT8, BASE_DEC, NULL, 0x00, |
1198 | 15 | "RTcfg Stage 2 Burst Rate", HFILL }}, |
1199 | | |
1200 | 15 | { &hf_rtcfg_s1_config_length, |
1201 | 15 | { "Stage 1 Config Length", |
1202 | 15 | "rtcfg.s1_config_length", |
1203 | 15 | FT_UINT16, BASE_DEC, NULL, 0x00, |
1204 | 15 | "RTcfg Stage 1 Config Length", HFILL }}, |
1205 | | |
1206 | 15 | { &hf_rtcfg_config_data, |
1207 | 15 | { "Config Data", |
1208 | 15 | "rtcfg.config_data", |
1209 | 15 | FT_BYTES, BASE_NONE, NULL, 0x00, |
1210 | 15 | "RTcfg Config Data", HFILL }}, |
1211 | | |
1212 | 15 | { &hf_rtcfg_padding, |
1213 | 15 | { "Padding", |
1214 | 15 | "rtcfg.padding", |
1215 | 15 | FT_UINT8, BASE_DEC, NULL, 0x00, |
1216 | 15 | "RTcfg Padding", HFILL }}, |
1217 | | |
1218 | 15 | { &hf_rtcfg_client_flags, |
1219 | 15 | { "Flags", |
1220 | 15 | "rtcfg.client_flags", |
1221 | 15 | FT_UINT8, BASE_HEX, NULL, 0x00, |
1222 | 15 | "RTcfg Client Flags", HFILL }}, |
1223 | | |
1224 | 15 | { &hf_rtcfg_client_flags_available, |
1225 | 15 | { "Req. Available", |
1226 | 15 | "rtcfg.client_flags.available", |
1227 | 15 | FT_UINT8, BASE_DEC, NULL, 0x01, |
1228 | 15 | "Request Available", HFILL }}, |
1229 | | |
1230 | 15 | { &hf_rtcfg_client_flags_ready, |
1231 | 15 | { "Client Ready", |
1232 | 15 | "rtcfg.client_flags.ready", |
1233 | 15 | FT_UINT8, BASE_DEC, NULL, 0x02, |
1234 | 15 | NULL, HFILL }}, |
1235 | | |
1236 | 15 | { &hf_rtcfg_client_flags_res, |
1237 | 15 | { "Reserved", |
1238 | 15 | "rtcfg.client_flags.res", |
1239 | 15 | FT_UINT8, BASE_HEX, NULL, 0xfc, |
1240 | 15 | NULL, HFILL }}, |
1241 | | |
1242 | 15 | { &hf_rtcfg_server_flags, |
1243 | 15 | { "Flags", |
1244 | 15 | "rtcfg.server_flags", |
1245 | 15 | FT_UINT8, BASE_HEX, NULL, 0x00, |
1246 | 15 | "RTcfg Server Flags", HFILL }}, |
1247 | | |
1248 | 15 | { &hf_rtcfg_server_flags_res0, |
1249 | 15 | { "Reserved", |
1250 | 15 | "rtcfg.server_flags.res0", |
1251 | 15 | FT_UINT8, BASE_HEX, NULL, 0x01, |
1252 | 15 | NULL, HFILL }}, |
1253 | | |
1254 | 15 | { &hf_rtcfg_server_flags_ready, |
1255 | 15 | { "Server Ready", |
1256 | 15 | "rtcfg.server_flags.ready", |
1257 | 15 | FT_UINT8, BASE_DEC, NULL, 0x02, |
1258 | 15 | NULL, HFILL }}, |
1259 | | |
1260 | 15 | { &hf_rtcfg_server_flags_res2, |
1261 | 15 | { "Reserved", |
1262 | 15 | "rtcfg.server_flags.res2", |
1263 | 15 | FT_UINT8, BASE_HEX, NULL, 0xfc, |
1264 | 15 | NULL, HFILL }}, |
1265 | | |
1266 | 15 | { &hf_rtcfg_active_stations, |
1267 | 15 | { "Active Stations", |
1268 | 15 | "rtcfg.active_stations", |
1269 | 15 | FT_UINT32, BASE_DEC, NULL, 0x00, |
1270 | 15 | "RTcfg Active Stations", HFILL }}, |
1271 | | |
1272 | 15 | { &hf_rtcfg_heartbeat_period, |
1273 | 15 | { "Heartbeat Period", |
1274 | 15 | "rtcfg.hearbeat_period", |
1275 | 15 | FT_UINT16, BASE_DEC, NULL, 0x00, |
1276 | 15 | "RTcfg Heartbeat Period", HFILL }}, |
1277 | | |
1278 | 15 | { &hf_rtcfg_s2_config_length, |
1279 | 15 | { "Stage 2 Config Length", |
1280 | 15 | "rtcfg.s2_config_length", |
1281 | 15 | FT_UINT32, BASE_DEC, NULL, 0x00, |
1282 | 15 | "RTcfg Stage 2 Config Length", HFILL }}, |
1283 | | |
1284 | 15 | { &hf_rtcfg_config_offset, |
1285 | 15 | { "Config Offset", |
1286 | 15 | "rtcfg.config_offset", |
1287 | 15 | FT_UINT32, BASE_DEC, NULL, 0x00, |
1288 | 15 | "RTcfg Config Offset", HFILL }}, |
1289 | | |
1290 | 15 | { &hf_rtcfg_ack_length, |
1291 | 15 | { "Ack Length", |
1292 | 15 | "rtcfg.ack_length", |
1293 | 15 | FT_UINT32, BASE_DEC, NULL, 0x00, |
1294 | 15 | "RTcfg Ack Length", HFILL }}, |
1295 | | |
1296 | 15 | { &hf_rtcfg_client_hw_address, |
1297 | 15 | { "Client Hardware Address", |
1298 | 15 | "rtcfg.client_hw_address", |
1299 | 15 | FT_BYTES, BASE_NONE, NULL, 0x00, |
1300 | 15 | "RTcfg Client Hardware Address", HFILL }} |
1301 | 15 | }; |
1302 | | |
1303 | 15 | static int *ett[] = { |
1304 | 15 | &ett_rtcfg, |
1305 | 15 | }; |
1306 | | |
1307 | 15 | proto_rtcfg = proto_register_protocol("RTcfg","RTcfg","rtcfg"); |
1308 | 15 | proto_register_field_array(proto_rtcfg,hf,array_length(hf)); |
1309 | 15 | proto_register_subtree_array(ett,array_length(ett)); |
1310 | | |
1311 | 15 | rtcfg_handle = register_dissector("rtcfg", dissect_rtcfg, proto_rtcfg); |
1312 | 15 | } |
1313 | | |
1314 | | /* The registration hand-off routing */ |
1315 | | |
1316 | | void |
1317 | 15 | proto_reg_handoff_rtmac(void) { |
1318 | 15 | dissector_add_uint("ethertype", ETHERTYPE_RTMAC, rtmac_handle); |
1319 | 15 | ethertype_table = find_dissector_table("ethertype"); |
1320 | 15 | } |
1321 | | |
1322 | | void |
1323 | 15 | proto_reg_handoff_rtcfg(void) { |
1324 | 15 | data_handle = find_dissector("data"); |
1325 | 15 | dissector_add_uint("ethertype", ETHERTYPE_RTCFG, rtcfg_handle); |
1326 | 15 | } |
1327 | | |
1328 | | /* |
1329 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
1330 | | * |
1331 | | * Local Variables: |
1332 | | * c-basic-offset: 2 |
1333 | | * tab-width: 8 |
1334 | | * indent-tabs-mode: nil |
1335 | | * End: |
1336 | | * |
1337 | | * ex: set shiftwidth=2 tabstop=8 expandtab: |
1338 | | * :indentSize=2:tabSize=8:noTabs=true: |
1339 | | */ |