/src/wireshark/epan/dissectors/packet-uavcan-dsdl.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* packet-uavcan-dsdl.c |
2 | | * Routines for dissection of DSDL used in UAVCAN |
3 | | * |
4 | | * Copyright 2020-2021 NXP |
5 | | * |
6 | | * Wireshark - Network traffic analyzer |
7 | | * By Gerald Combs <gerald@wireshark.org> |
8 | | * Copyright 1998 Gerald Combs |
9 | | * |
10 | | * SPDX-License-Identifier: GPL-2.0-or-later |
11 | | */ |
12 | | #include "config.h" |
13 | | |
14 | | #include <inttypes.h> |
15 | | #include <epan/packet.h> |
16 | | #include <epan/prefs.h> |
17 | | #include <epan/address_types.h> |
18 | | #include <epan/to_str.h> |
19 | | #include <epan/proto_data.h> |
20 | | |
21 | | #include "packet-uavcan-dsdl.h" |
22 | | |
23 | | void proto_register_dsdl(void); |
24 | | void proto_reg_handoff_dsdl(void); |
25 | | |
26 | | static int proto_dsdl; |
27 | | |
28 | | static int hf_heartbeat_uptime; |
29 | | static int hf_heartbeat_health; |
30 | | static int hf_heartbeat_mode; |
31 | | static int hf_heartbeat_status_code; |
32 | | |
33 | | static int hf_list_index; |
34 | | static int hf_register_name; |
35 | | static int hf_register_access_mutable; |
36 | | static int hf_register_access_persistent; |
37 | | static int hf_register_value_tag; |
38 | | static int hf_register_value_size; |
39 | | |
40 | | |
41 | | static int hf_node_id; |
42 | | static int hf_pnp_unique_id; |
43 | | static int hf_pnp_unique_id_hash; |
44 | | static int hf_pnp_alloc; |
45 | | |
46 | | static int hf_uavcan_primitive_Empty; |
47 | | static int hf_uavcan_primitive_String; |
48 | | static int hf_uavcan_primitive_Unstructured; |
49 | | static int hf_uavcan_primitive_array_Integer64; |
50 | | static int hf_uavcan_primitive_array_Integer32; |
51 | | static int hf_uavcan_primitive_array_Integer16; |
52 | | static int hf_uavcan_primitive_array_Integer8; |
53 | | static int hf_uavcan_primitive_array_Natural64; |
54 | | static int hf_uavcan_primitive_array_Natural32; |
55 | | static int hf_uavcan_primitive_array_Natural16; |
56 | | static int hf_uavcan_primitive_array_Natural8; |
57 | | static int hf_uavcan_primitive_array_Real64; |
58 | | static int hf_uavcan_primitive_array_Real32; |
59 | | static int hf_uavcan_primitive_array_Real16; |
60 | | |
61 | | |
62 | | static int hf_uavcan_getinfo_path; |
63 | | static int hf_uavcan_getinfo_error; |
64 | | static int hf_uavcan_getinfo_size; |
65 | | static int hf_uavcan_getinfo_timestamp; |
66 | | static int hf_uavcan_getinfo_is_file_not_directory; |
67 | | static int hf_uavcan_getinfo_is_link; |
68 | | static int hf_uavcan_getinfo_is_readable; |
69 | | static int hf_uavcan_getinfo_is_writeable; |
70 | | static int hf_uavcan_directory_path; |
71 | | static int hf_uavcan_entry_base_name; |
72 | | static int hf_uavcan_modify_error; |
73 | | static int hf_uavcan_modify_source_path; |
74 | | static int hf_uavcan_modify_destination_path; |
75 | | static int hf_uavcan_modify_preserve_source; |
76 | | static int hf_uavcan_modify_overwrite_destination; |
77 | | static int hf_uavcan_read_offset; |
78 | | static int hf_uavcan_read_path; |
79 | | static int hf_uavcan_read_error; |
80 | | static int hf_uavcan_write_offset; |
81 | | static int hf_uavcan_write_path; |
82 | | static int hf_uavcan_write_error; |
83 | | static int hf_uavcan_entry_index; |
84 | | |
85 | | static int hf_uavcan_time_syncronizedtimestamp; |
86 | | static int hf_uavcan_diagnostic_severity; |
87 | | |
88 | | static int ett_dsdl; |
89 | | |
90 | | const range_string uavcan_subject_id_vals[] = { |
91 | | { 0, 6143, "Unregulated identifier" }, |
92 | | { 6144, 7167, "Non-standard fixed regulated identifier"}, |
93 | | { 7168, 7168, "Synchronization.1.0" }, |
94 | | { 7509, 7509, "Heartbeat.1.0" }, |
95 | | { 7510, 7510, "List.0.1" }, |
96 | | { 8165, 8165, "NodeIDAllocationData.2.0" }, |
97 | | { 8166, 8166, "NodeIDAllocationData.1.0" }, |
98 | | { 8184, 8184, "Record.1.X" }, |
99 | | { 0, 0, NULL } |
100 | | }; |
101 | | |
102 | | const range_string uavcan_service_id_vals[] = { |
103 | | { 0, 255, "Unregulated identifier" }, |
104 | | { 256, 383, "Non-standard fixed regulated identifier"}, |
105 | | { 384, 384, "Access.1.0" }, |
106 | | { 385, 385, "List.1.0" }, |
107 | | { 405, 405, "GetInfo.0.X" }, |
108 | | { 406, 406, "List.0.X" }, |
109 | | { 407, 407, "Modify.1.X" }, |
110 | | { 408, 408, "Read.1.X" }, |
111 | | { 409, 409, "Write.1.X" }, |
112 | | { 430, 430, "GetInfo.1.0" }, |
113 | | { 434, 434, "GetTransportStatistics.1.0" }, |
114 | | { 435, 435, "ExecuteCommand.1.X" }, |
115 | | { 0, 0, NULL } |
116 | | }; |
117 | | |
118 | | static const address anonymous_address = ADDRESS_INIT(AT_NONE, 9, "Anonymous"); |
119 | | |
120 | | static const value_string uavcan_file_error_vals[] = { |
121 | | { 0, "Ok" }, |
122 | | { 2, "Not found" }, |
123 | | { 5, "I/O error" }, |
124 | | { 13, "Access denied" }, |
125 | | { 21, "Is directory" }, |
126 | | { 22, "Invalid value" }, |
127 | | { 27, "File too large" }, |
128 | | { 28, "Out of space" }, |
129 | | { 38, "Not supported" }, |
130 | | { 65535, "Unknown" }, |
131 | | { 0, NULL } |
132 | | }; |
133 | | |
134 | | static const value_string uavcan_diagnostic_severity_vals[] = { |
135 | | { 0, "Trace" }, |
136 | | { 1, "Debug" }, |
137 | | { 2, "Info" }, |
138 | | { 3, "Notice" }, |
139 | | { 4, "Warning" }, |
140 | | { 5, "Error" }, |
141 | | { 6, "Critical" }, |
142 | | { 7, "Alert" }, |
143 | | { 0, NULL } |
144 | | }; |
145 | | |
146 | | static const value_string uavcan_heartbeat_mode_vals[] = { |
147 | | { 0, "Operational" }, |
148 | | { 1, "Initialization" }, |
149 | | { 2, "Maintenance" }, |
150 | | { 3, "Software update" }, |
151 | | { 0, NULL } |
152 | | }; |
153 | | |
154 | | static const value_string uavcan_heartbeat_health_vals[] = { |
155 | | { 0, "Nominal" }, |
156 | | { 1, "Advisory" }, |
157 | | { 2, "Caution" }, |
158 | | { 3, "Warning" }, |
159 | | { 0, NULL } |
160 | | }; |
161 | | |
162 | | static const value_string uavcan_value_tag_vals[] = { |
163 | | { 0, "Empty" }, |
164 | | { 1, "String" }, |
165 | | { 2, "Unstructured" }, |
166 | | { 3, "Bit array" }, |
167 | | { 4, "Integer 64 Array" }, |
168 | | { 5, "Integer 32 Array" }, |
169 | | { 6, "Integer 16 Array" }, |
170 | | { 7, "Integer 8 Array" }, |
171 | | { 8, "Natural 64 Array" }, |
172 | | { 9, "Natural 32 Array" }, |
173 | | { 10, "Natural 16 Array" }, |
174 | | { 11, "Natural 8 Array" }, |
175 | | { 12, "Real 64 Array" }, |
176 | | { 13, "Real 32 Array" }, |
177 | | { 14, "Real 16 Array" }, |
178 | | { 0, NULL } |
179 | | }; |
180 | | |
181 | | static const value_string uavcan_nodeid_alloc_vals[] = { |
182 | | { 0, "request message" }, |
183 | | { 1, "response message" }, |
184 | | { 0, NULL } |
185 | | }; |
186 | | |
187 | | static void |
188 | | dissect_list_service_data(tvbuff_t *tvb, int tvb_offset, proto_tree *tree, bool is_request) |
189 | 0 | { |
190 | 0 | if (is_request == true) { |
191 | 0 | proto_tree_add_item(tree, hf_list_index, tvb, tvb_offset, 2, ENC_LITTLE_ENDIAN); |
192 | 0 | } else { |
193 | | /* FT_UINT_STRING counted string, with count being the first byte */ |
194 | 0 | proto_tree_add_item(tree, hf_register_name, |
195 | 0 | tvb, tvb_offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); |
196 | 0 | } |
197 | 0 | } |
198 | | |
199 | | static void |
200 | | dissect_access_service_data(tvbuff_t *tvb, int tvb_offset, proto_tree *tree, bool is_request) |
201 | 0 | { |
202 | 0 | uint32_t tag; |
203 | 0 | int offset; |
204 | |
|
205 | 0 | offset = tvb_offset; |
206 | |
|
207 | 0 | if (is_request == true) { |
208 | 0 | int len; |
209 | | /* FT_UINT_STRING counted string, with count being the first byte */ |
210 | 0 | proto_tree_add_item_ret_length(tree, hf_register_name, |
211 | 0 | tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN, &len); |
212 | 0 | offset += len; |
213 | 0 | } else { |
214 | 0 | proto_tree_add_item(tree, hf_uavcan_time_syncronizedtimestamp, |
215 | 0 | tvb, offset, 7, ENC_LITTLE_ENDIAN); |
216 | 0 | offset += 7; |
217 | 0 | proto_tree_add_item(tree, hf_register_access_mutable, |
218 | 0 | tvb, offset, 1, ENC_NA); |
219 | 0 | proto_tree_add_item(tree, hf_register_access_persistent, |
220 | 0 | tvb, offset, 1, ENC_NA); |
221 | |
|
222 | 0 | offset += 1; |
223 | 0 | } |
224 | |
|
225 | 0 | proto_tree_add_item_ret_uint(tree, hf_register_value_tag, |
226 | 0 | tvb, offset, 1, ENC_NA, &tag); |
227 | 0 | offset += 1; |
228 | |
|
229 | 0 | if (tag == 1) { /* String */ |
230 | 0 | proto_tree_add_item(tree, hf_register_value_size, |
231 | 0 | tvb, offset, 1, ENC_NA); |
232 | | /* FT_UINT_STRING counted string, with count being the first byte */ |
233 | 0 | proto_tree_add_item(tree, hf_register_name, |
234 | 0 | tvb, offset, 1, ENC_ASCII|ENC_BIG_ENDIAN); |
235 | 0 | } else if (tag == 2 || tag == 3) { |
236 | 0 | return; // Raw data do nothing |
237 | 0 | } else { |
238 | 0 | uint8_t array_len = tvb_get_uint8(tvb, offset); |
239 | |
|
240 | 0 | if (array_len == 0 || tag == 0) { |
241 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_Empty, |
242 | 0 | tvb, 0, 0, ENC_NA); |
243 | 0 | } else { |
244 | 0 | proto_tree_add_item(tree, hf_register_value_size, |
245 | 0 | tvb, offset, 1, ENC_NA); |
246 | 0 | offset += 1; |
247 | |
|
248 | 0 | for (uint8_t i = 0; i < array_len; i++) { |
249 | 0 | switch (tag) { |
250 | 0 | case 4: /*Integer64*/ |
251 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_array_Integer64, |
252 | 0 | tvb, offset, 8, ENC_LITTLE_ENDIAN); |
253 | 0 | offset += 8; |
254 | 0 | break; |
255 | | |
256 | 0 | case 5: /*Integer32*/ |
257 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_array_Integer32, |
258 | 0 | tvb, offset, 4, ENC_LITTLE_ENDIAN); |
259 | 0 | offset += 4; |
260 | 0 | break; |
261 | | |
262 | 0 | case 6: /*Integer16*/ |
263 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_array_Integer16, |
264 | 0 | tvb, offset, 2, ENC_LITTLE_ENDIAN); |
265 | 0 | offset += 2; |
266 | 0 | break; |
267 | | |
268 | 0 | case 7: /*Integer8*/ |
269 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_array_Integer8, |
270 | 0 | tvb, offset, 1, ENC_LITTLE_ENDIAN); |
271 | 0 | offset += 1; |
272 | 0 | break; |
273 | | |
274 | 0 | case 8: /*Natural64*/ |
275 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_array_Natural64, |
276 | 0 | tvb, offset, 8, ENC_LITTLE_ENDIAN); |
277 | 0 | offset += 8; |
278 | 0 | break; |
279 | | |
280 | 0 | case 9: /*Natural32*/ |
281 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_array_Natural32, |
282 | 0 | tvb, offset, 4, ENC_LITTLE_ENDIAN); |
283 | 0 | offset += 4; |
284 | 0 | break; |
285 | | |
286 | 0 | case 10: /*Natural16*/ |
287 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_array_Natural16, |
288 | 0 | tvb, offset, 2, ENC_LITTLE_ENDIAN); |
289 | 0 | offset += 2; |
290 | 0 | break; |
291 | | |
292 | 0 | case 11: /*Natural8*/ |
293 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_array_Natural8, |
294 | 0 | tvb, offset, 1, ENC_LITTLE_ENDIAN); |
295 | 0 | offset += 1; |
296 | 0 | break; |
297 | | |
298 | 0 | case 12: /*Real64*/ |
299 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_array_Real64, |
300 | 0 | tvb, offset, 8, ENC_LITTLE_ENDIAN); |
301 | 0 | offset += 8; |
302 | 0 | break; |
303 | | |
304 | 0 | case 13: /*Real32*/ |
305 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_array_Real32, |
306 | 0 | tvb, offset, 4, ENC_LITTLE_ENDIAN); |
307 | 0 | offset += 4; |
308 | 0 | break; |
309 | | |
310 | 0 | case 14: /*Real16*/ |
311 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_array_Real16, |
312 | 0 | tvb, offset, 2, ENC_LITTLE_ENDIAN); |
313 | 0 | offset += 2; |
314 | 0 | break; |
315 | | |
316 | 0 | default: |
317 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_Empty, |
318 | 0 | tvb, 0, 0, ENC_NA); |
319 | 0 | } |
320 | 0 | } |
321 | 0 | } |
322 | 0 | } |
323 | 0 | } |
324 | | |
325 | | static int |
326 | | dissect_dsdl_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) |
327 | 0 | { |
328 | 0 | uint32_t id = GPOINTER_TO_INT(data); |
329 | |
|
330 | 0 | proto_item_append_text(tree, " DSDL (%s)", |
331 | 0 | rval_to_str_const(id, uavcan_subject_id_vals, "Reserved")); |
332 | |
|
333 | 0 | if (id == 7509) { |
334 | | /* Dissect Heartbeat1.0 frame */ |
335 | 0 | proto_tree_add_item(tree, hf_heartbeat_uptime, tvb, 0, 4, ENC_LITTLE_ENDIAN); |
336 | 0 | proto_tree_add_item(tree, hf_heartbeat_health, tvb, 4, 1, ENC_NA); |
337 | 0 | proto_tree_add_item(tree, hf_heartbeat_mode, tvb, 5, 1, ENC_NA); |
338 | 0 | proto_tree_add_item(tree, hf_heartbeat_status_code, tvb, 6, 1, ENC_NA); |
339 | 0 | return tvb_captured_length(tvb); |
340 | 0 | } else if (id == 8166) { |
341 | | /* Dissect NodeIDAllocationData1.0 allocation request */ |
342 | 0 | proto_tree_add_item(tree, hf_pnp_unique_id_hash, tvb, 0, 6, ENC_NA); |
343 | 0 | proto_tree_add_item(tree, hf_pnp_alloc, tvb, 6, 1, ENC_NA); |
344 | 0 | if (tvb_captured_length(tvb) > 8) { |
345 | 0 | proto_tree_add_item(tree, hf_node_id, tvb, 7, 2, ENC_LITTLE_ENDIAN); |
346 | 0 | } |
347 | 0 | return tvb_captured_length(tvb); |
348 | 0 | } else if (id == 8165) { |
349 | | /* Dissect NodeIDAllocationData2.0 allocation request/response */ |
350 | 0 | proto_tree_add_item(tree, hf_node_id, tvb, 0, 2, ENC_LITTLE_ENDIAN); |
351 | 0 | proto_tree_add_item(tree, hf_pnp_unique_id, tvb, 2, 16, ENC_NA); |
352 | 0 | proto_tree_add_uint(tree, hf_pnp_alloc, tvb, 0, 0, |
353 | 0 | (cmp_address(&anonymous_address, (const address *) &pinfo->src) != 0)); |
354 | 0 | return tvb_captured_length(tvb); |
355 | 0 | } else if (id == 8184) { |
356 | | /* Dissect Synchronization.1.0 frame */ |
357 | 0 | proto_tree_add_item(tree, hf_uavcan_time_syncronizedtimestamp, tvb, 0, 7, |
358 | 0 | ENC_LITTLE_ENDIAN); |
359 | 0 | proto_tree_add_item(tree, hf_uavcan_diagnostic_severity, tvb, 7, 1, ENC_NA); |
360 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_String, tvb, 8, 1, |
361 | 0 | ENC_ASCII|ENC_BIG_ENDIAN); |
362 | 0 | return tvb_captured_length(tvb); |
363 | 0 | } |
364 | | |
365 | 0 | return 0; |
366 | 0 | } |
367 | | |
368 | | static int |
369 | | dissect_dsdl_service_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) |
370 | 0 | { |
371 | 0 | uint32_t id = GPOINTER_TO_INT(data); |
372 | |
|
373 | 0 | (void) pinfo; |
374 | |
|
375 | 0 | proto_item_append_text(tree, " DSDL (%s)", |
376 | 0 | rval_to_str_const(id, uavcan_service_id_vals, "Reserved")); |
377 | |
|
378 | 0 | if (id == 384) { /* Dissect Access.1.0 frame */ |
379 | 0 | dissect_access_service_data(tvb, 0, tree, true); |
380 | 0 | return tvb_captured_length(tvb); |
381 | 0 | } else if (id == 385) { /* Dissect List.1.0 frame */ |
382 | 0 | dissect_list_service_data(tvb, 0, tree, true); |
383 | 0 | return tvb_captured_length(tvb); |
384 | 0 | } else if (id == 405) { /* Dissect GetInfo.0.X frame */ |
385 | 0 | proto_tree_add_item(tree, hf_uavcan_getinfo_path, |
386 | 0 | tvb, 0, 1, ENC_ASCII|ENC_BIG_ENDIAN); |
387 | 0 | return tvb_captured_length(tvb); |
388 | 0 | } else if (id == 406) { /* Dissect List.0.X frame */ |
389 | 0 | proto_tree_add_item(tree, hf_uavcan_entry_index, |
390 | 0 | tvb, 0, 4, ENC_LITTLE_ENDIAN); |
391 | 0 | proto_tree_add_item(tree, hf_uavcan_directory_path, |
392 | 0 | tvb, 8, 1, ENC_ASCII|ENC_BIG_ENDIAN); |
393 | 0 | return tvb_captured_length(tvb); |
394 | 0 | } else if (id == 407) { /* Dissect Modify.1.X frame */ |
395 | 0 | proto_tree_add_item(tree, hf_uavcan_modify_preserve_source, |
396 | 0 | tvb, 0, 1, ENC_NA); |
397 | 0 | proto_tree_add_item(tree, hf_uavcan_modify_overwrite_destination, |
398 | 0 | tvb, 0, 1, ENC_NA); |
399 | 0 | int len; |
400 | 0 | proto_tree_add_item_ret_length(tree, hf_uavcan_modify_source_path, |
401 | 0 | tvb, 4, 1, ENC_ASCII|ENC_BIG_ENDIAN, &len); |
402 | 0 | proto_tree_add_item(tree, hf_uavcan_modify_destination_path, |
403 | 0 | tvb, 4 + len, 1, ENC_ASCII|ENC_BIG_ENDIAN); |
404 | 0 | return tvb_captured_length(tvb); |
405 | 0 | } else if (id == 408) { /* Dissect Read.1.X frame */ |
406 | 0 | proto_tree_add_item(tree, hf_uavcan_read_offset, |
407 | 0 | tvb, 0, 5, ENC_LITTLE_ENDIAN); |
408 | 0 | proto_tree_add_item(tree, hf_uavcan_read_path, |
409 | 0 | tvb, 5, 1, ENC_ASCII|ENC_BIG_ENDIAN); |
410 | 0 | return tvb_captured_length(tvb); |
411 | 0 | } else if (id == 409) { /* Dissect Write.1.X frame */ |
412 | 0 | proto_tree_add_item(tree, hf_uavcan_write_offset, |
413 | 0 | tvb, 0, 5, ENC_LITTLE_ENDIAN); |
414 | 0 | int len; |
415 | 0 | proto_tree_add_item_ret_length(tree, hf_uavcan_write_path, |
416 | 0 | tvb, 5, 1, ENC_ASCII|ENC_BIG_ENDIAN, &len); |
417 | 0 | uint16_t data_len = tvb_get_uint16(tvb, 5 + len, ENC_LITTLE_ENDIAN); |
418 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_Unstructured, |
419 | 0 | tvb, 7 + len, data_len, ENC_NA); |
420 | 0 | return tvb_captured_length(tvb); |
421 | 0 | } |
422 | | |
423 | 0 | return 0; |
424 | 0 | } |
425 | | |
426 | | static int |
427 | | dissect_dsdl_service_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) |
428 | 0 | { |
429 | 0 | uint32_t id = GPOINTER_TO_INT(data); |
430 | |
|
431 | 0 | (void) pinfo; |
432 | |
|
433 | 0 | proto_item_append_text(tree, " DSDL (%s)", |
434 | 0 | rval_to_str_const(id, uavcan_service_id_vals, "Reserved")); |
435 | |
|
436 | 0 | if (id == 384) { /* Dissect Access.1.0 frame */ |
437 | 0 | dissect_access_service_data(tvb, 0, tree, false); |
438 | 0 | return tvb_captured_length(tvb); |
439 | 0 | } else if (id == 385) { /* Dissect List.1.0 frame */ |
440 | 0 | dissect_list_service_data(tvb, 0, tree, false); |
441 | 0 | return tvb_captured_length(tvb); |
442 | 0 | } else if (id == 405) { /* Dissect GetInfo.0.X frame */ |
443 | 0 | proto_tree_add_item(tree, hf_uavcan_getinfo_error, |
444 | 0 | tvb, 0, 2, ENC_LITTLE_ENDIAN); |
445 | 0 | proto_tree_add_item(tree, hf_uavcan_getinfo_size, |
446 | 0 | tvb, 2, 5, ENC_LITTLE_ENDIAN); |
447 | 0 | proto_tree_add_item(tree, hf_uavcan_getinfo_timestamp, |
448 | 0 | tvb, 7, 5, ENC_LITTLE_ENDIAN); |
449 | 0 | proto_tree_add_item(tree, hf_uavcan_getinfo_is_file_not_directory, |
450 | 0 | tvb, 13, 1, ENC_LITTLE_ENDIAN); |
451 | 0 | proto_tree_add_item(tree, hf_uavcan_getinfo_is_link, |
452 | 0 | tvb, 13, 1, ENC_LITTLE_ENDIAN); |
453 | 0 | proto_tree_add_item(tree, hf_uavcan_getinfo_is_readable, |
454 | 0 | tvb, 13, 1, ENC_LITTLE_ENDIAN); |
455 | 0 | proto_tree_add_item(tree, hf_uavcan_getinfo_is_writeable, |
456 | 0 | tvb, 13, 1, ENC_LITTLE_ENDIAN); |
457 | 0 | return tvb_captured_length(tvb); |
458 | 0 | } else if (id == 406) { /* Dissect List.0.X frame */ |
459 | | /* FT_UINT_STRING counted string, with count being the first byte */ |
460 | 0 | proto_tree_add_item(tree, hf_uavcan_entry_base_name, |
461 | 0 | tvb, 4, 1, ENC_ASCII|ENC_BIG_ENDIAN); |
462 | 0 | return tvb_captured_length(tvb); |
463 | 0 | } else if (id == 407) { /* Dissect Modify.1.X frame */ |
464 | 0 | proto_tree_add_item(tree, hf_uavcan_modify_error, |
465 | 0 | tvb, 0, 2, ENC_LITTLE_ENDIAN); |
466 | 0 | return tvb_captured_length(tvb); |
467 | 0 | } else if (id == 408) { /* Dissect Read.1.X frame */ |
468 | 0 | proto_tree_add_item(tree, hf_uavcan_read_error, |
469 | 0 | tvb, 0, 2, ENC_LITTLE_ENDIAN); |
470 | 0 | uint16_t data_len = tvb_get_uint16(tvb, 2, ENC_LITTLE_ENDIAN); |
471 | 0 | proto_tree_add_item(tree, hf_uavcan_primitive_Unstructured, |
472 | 0 | tvb, 4, data_len, ENC_NA); |
473 | 0 | return tvb_captured_length(tvb); |
474 | 0 | } else if (id == 409) { /* Dissect Write.1.X frame */ |
475 | 0 | proto_tree_add_item(tree, hf_uavcan_write_error, |
476 | 0 | tvb, 0, 2, ENC_LITTLE_ENDIAN); |
477 | 0 | return tvb_captured_length(tvb); |
478 | 0 | } |
479 | | |
480 | 0 | return 0; |
481 | 0 | } |
482 | | |
483 | | void |
484 | | proto_register_dsdl(void) |
485 | 14 | { |
486 | 14 | static hf_register_info hf[] = { |
487 | 14 | {&hf_node_id, |
488 | 14 | {"Node ID", "uavcan_dsdl.node.id", |
489 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
490 | 14 | {&hf_pnp_unique_id, |
491 | 14 | {"Unique ID", "uavcan_dsdl.pnp.unique_id", |
492 | 14 | FT_BYTES, BASE_NONE | BASE_ALLOW_ZERO, NULL, 0x0, NULL, HFILL}}, |
493 | 14 | {&hf_pnp_unique_id_hash, |
494 | 14 | {"Unique ID hash", "uavcan_dsdl.pnp.unique_id_hash", |
495 | 14 | FT_BYTES, BASE_NONE | BASE_ALLOW_ZERO, NULL, 0x0, NULL, HFILL}}, |
496 | 14 | {&hf_pnp_alloc, |
497 | 14 | {"allocation type", "uavcan_dsdl.pnp.allocation", |
498 | 14 | FT_UINT8, BASE_DEC, VALS(uavcan_nodeid_alloc_vals), 0x0, NULL, HFILL}}, |
499 | | |
500 | | // Heartbeat 1.0 |
501 | 14 | {&hf_heartbeat_uptime, |
502 | 14 | {"Uptime", "uavcan_dsdl.Heartbeat.uptime", |
503 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
504 | 14 | {&hf_heartbeat_health, |
505 | 14 | {"Health", "uavcan_dsdl.Heartbeat.health", |
506 | 14 | FT_UINT8, BASE_DEC, VALS(uavcan_heartbeat_health_vals), 0x0, NULL, HFILL}}, |
507 | 14 | {&hf_heartbeat_mode, |
508 | 14 | {"Mode", "uavcan_dsdl.Heartbeat.mode", |
509 | 14 | FT_UINT8, BASE_DEC, VALS(uavcan_heartbeat_mode_vals), 0x0, NULL, HFILL}}, |
510 | 14 | {&hf_heartbeat_status_code, |
511 | 14 | {"Vendor specific status code", |
512 | 14 | "uavcan_dsdl.Heartbeat.vendor_specific_status_code", |
513 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
514 | 14 | {&hf_uavcan_time_syncronizedtimestamp, |
515 | 14 | {"Timestamp (usec)", "uavcan_dsdl.time.SynchronizedTimestamp", |
516 | 14 | FT_UINT56, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
517 | 14 | {&hf_uavcan_diagnostic_severity, |
518 | 14 | {"Severity", "uavcan_dsdl.diagnostic.severity", |
519 | 14 | FT_UINT8, BASE_DEC, VALS(uavcan_diagnostic_severity_vals), 0x0, NULL, HFILL}}, |
520 | | |
521 | | // List1.0 Request |
522 | 14 | {&hf_list_index, |
523 | 14 | {"Index", "uavcan_dsdl.register.List.index", |
524 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
525 | 14 | {&hf_register_name, |
526 | 14 | {"Name", "uavcan_dsdl.register.Name", |
527 | 14 | FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
528 | | |
529 | | // Access1.0 Value1.0 |
530 | 14 | {&hf_register_access_mutable, |
531 | 14 | {"Mutable", "uavcan_dsdl.register.Access.mutable", |
532 | 14 | FT_UINT8, BASE_DEC, NULL, 0x1, NULL, HFILL}}, |
533 | 14 | {&hf_register_access_persistent, |
534 | 14 | {"Persistent", "uavcan_dsdl.register.Access.persistent", |
535 | 14 | FT_UINT8, BASE_DEC, NULL, 0x2, NULL, HFILL}}, |
536 | 14 | {&hf_register_value_tag, |
537 | 14 | {"Tag", "uavcan_dsdl.register.Value.tag", |
538 | 14 | FT_UINT8, BASE_DEC, VALS(uavcan_value_tag_vals), 0x0, NULL, HFILL}}, |
539 | 14 | {&hf_register_value_size, |
540 | 14 | {"Array size", "uavcan_dsdl.primitive.array.size", |
541 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
542 | 14 | {&hf_uavcan_primitive_Empty, |
543 | 14 | {"Empty", "uavcan_dsdl.primitive.Empty", |
544 | 14 | FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
545 | 14 | {&hf_uavcan_primitive_String, |
546 | 14 | {"String", "uavcan_dsdl.primitive.String", |
547 | 14 | FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
548 | 14 | {&hf_uavcan_primitive_Unstructured, |
549 | 14 | {"Unstructured", "uavcan_dsdl.primitive.array.Unstructured", |
550 | 14 | FT_BYTES, BASE_NONE | BASE_ALLOW_ZERO, NULL, 0x0, NULL, HFILL}}, |
551 | 14 | {&hf_uavcan_primitive_array_Integer64, |
552 | 14 | {"Integer64", "uavcan_dsdl.primitive.array.Integer64", |
553 | 14 | FT_INT64, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
554 | 14 | {&hf_uavcan_primitive_array_Integer32, |
555 | 14 | {"Integer32", "uavcan_dsdl.primitive.array.Integer32", |
556 | 14 | FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
557 | 14 | {&hf_uavcan_primitive_array_Integer16, |
558 | 14 | {"Integer16", "uavcan_dsdl.primitive.array.Integer16", |
559 | 14 | FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
560 | 14 | {&hf_uavcan_primitive_array_Integer8, |
561 | 14 | {"Integer8", "uavcan_dsdl.primitive.array.Integer8", |
562 | 14 | FT_INT8, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
563 | 14 | {&hf_uavcan_primitive_array_Natural64, |
564 | 14 | {"Natural64", "uavcan_dsdl.primitive.array.Natural64", |
565 | 14 | FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
566 | 14 | {&hf_uavcan_primitive_array_Natural32, |
567 | 14 | {"Natural32", "uavcan_dsdl.primitive.array.Natural32", |
568 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
569 | 14 | {&hf_uavcan_primitive_array_Natural16, |
570 | 14 | {"Natural16", "uavcan_dsdl.primitive.array.Natural16", |
571 | 14 | FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
572 | 14 | {&hf_uavcan_primitive_array_Natural8, |
573 | 14 | {"Natural8", "uavcan_dsdl.primitive.array.Natural8", |
574 | 14 | FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
575 | 14 | {&hf_uavcan_primitive_array_Real64, |
576 | 14 | {"Real64", "uavcan_dsdl.primitive.array.Real64", |
577 | 14 | FT_DOUBLE, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
578 | 14 | {&hf_uavcan_primitive_array_Real32, |
579 | 14 | {"Real32", "uavcan_dsdl.primitive.array.Real32", |
580 | 14 | FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
581 | 14 | {&hf_uavcan_primitive_array_Real16, |
582 | 14 | {"Real16", "uavcan_dsdl.primitive.array.Real16", |
583 | 14 | FT_IEEE_11073_SFLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL} /* TODO not sure check */ |
584 | 14 | }, |
585 | 14 | {&hf_uavcan_getinfo_path, |
586 | 14 | {"Path", "uavcan_dsdl.file.GetInfo.path", |
587 | 14 | FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
588 | 14 | {&hf_uavcan_getinfo_error, |
589 | 14 | {"Error", "uavcan_dsdl.file.GetInfo.error", |
590 | 14 | FT_UINT16, BASE_DEC, VALS(uavcan_file_error_vals), 0x0, NULL, HFILL}}, |
591 | 14 | {&hf_uavcan_getinfo_size, |
592 | 14 | {"Size", "uavcan_dsdl.file.GetInfo.size", |
593 | 14 | FT_UINT40, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
594 | 14 | {&hf_uavcan_getinfo_timestamp, |
595 | 14 | {"Timestamp", "uavcan_dsdl.file.GetInfo.timestamp", |
596 | 14 | FT_UINT40, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
597 | 14 | {&hf_uavcan_getinfo_is_file_not_directory, |
598 | 14 | {"Is file not directory", |
599 | 14 | "uavcan_dsdl.file.GetInfo.is_file_not_directory", |
600 | 14 | FT_UINT8, BASE_DEC, NULL, 0x1, NULL, HFILL}}, |
601 | 14 | {&hf_uavcan_getinfo_is_link, |
602 | 14 | {"Is link", "uavcan_dsdl.file.GetInfo.is_link", |
603 | 14 | FT_UINT8, BASE_DEC, NULL, 0x2, NULL, HFILL}}, |
604 | 14 | {&hf_uavcan_getinfo_is_readable, |
605 | 14 | {"Is readable", "uavcan_dsdl.file.GetInfo.is_readable", |
606 | 14 | FT_UINT8, BASE_DEC, NULL, 0x4, NULL, HFILL}}, |
607 | 14 | {&hf_uavcan_getinfo_is_writeable, |
608 | 14 | {"Is writeable", "uavcan_dsdl.file.GetInfo.is_writeable", |
609 | 14 | FT_UINT8, BASE_DEC, NULL, 0x8, NULL, HFILL}}, |
610 | 14 | {&hf_uavcan_read_path, |
611 | 14 | {"Path", "uavcan_dsdl.file.Read.path", |
612 | 14 | FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
613 | 14 | {&hf_uavcan_write_path, |
614 | 14 | {"Path", "uavcan_dsdl.file.Write.path", |
615 | 14 | FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
616 | 14 | {&hf_uavcan_directory_path, |
617 | 14 | {"Directory path", "uavcan_dsdl.file.list.directory_path", |
618 | 14 | FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
619 | 14 | {&hf_uavcan_entry_base_name, |
620 | 14 | {"Base name", "uavcan_dsdl.file.list.entry_base_name", |
621 | 14 | FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
622 | 14 | {&hf_uavcan_modify_source_path, |
623 | 14 | {"Source", "uavcan_dsdl.file.Modify.source", |
624 | 14 | FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
625 | 14 | {&hf_uavcan_modify_destination_path, |
626 | 14 | {"Destination", "uavcan_dsdl.file.Modify.Destination", |
627 | 14 | FT_UINT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL}}, |
628 | 14 | {&hf_uavcan_modify_preserve_source, |
629 | 14 | {"Preserve source", "uavcan_dsdl.Modify.preserve_source", |
630 | 14 | FT_UINT8, BASE_DEC, NULL, 0x1, NULL, HFILL}}, |
631 | 14 | {&hf_uavcan_modify_overwrite_destination, |
632 | 14 | {"Overwrite destination", "uavcan_dsdl.Modify.overwrite_destination", |
633 | 14 | FT_UINT8, BASE_DEC, NULL, 0x2, NULL, HFILL}}, |
634 | 14 | {&hf_uavcan_modify_error, |
635 | 14 | {"Error", "uavcan_dsdl.Modify.error", |
636 | 14 | FT_UINT16, BASE_DEC, VALS(uavcan_file_error_vals), 0x0, NULL, HFILL}}, |
637 | 14 | {&hf_uavcan_read_offset, |
638 | 14 | {"Offset", "uavcan_dsdl.Read.offset", |
639 | 14 | FT_UINT40, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
640 | 14 | {&hf_uavcan_read_error, |
641 | 14 | {"Error", "uavcan_dsdl.Read.error", |
642 | 14 | FT_UINT16, BASE_DEC, VALS(uavcan_file_error_vals), 0x0, NULL, HFILL}}, |
643 | 14 | {&hf_uavcan_write_offset, |
644 | 14 | {"Offset", "uavcan_dsdl.Write.offset", |
645 | 14 | FT_UINT40, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
646 | 14 | {&hf_uavcan_write_error, |
647 | 14 | {"Error", "uavcan_dsdl.Write.error", |
648 | 14 | FT_UINT16, BASE_DEC, VALS(uavcan_file_error_vals), 0x0, NULL, HFILL}}, |
649 | 14 | {&hf_uavcan_entry_index, |
650 | 14 | {"Entry index", "uavcan_dsdl.file.list.entry_index", |
651 | 14 | FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}}, |
652 | 14 | }; |
653 | | |
654 | 14 | static int *ett[] = { |
655 | 14 | &ett_dsdl, |
656 | 14 | }; |
657 | | |
658 | 14 | proto_dsdl = proto_register_protocol("UAVCAN DSDL", "DSDL", "uavcan_dsdl"); |
659 | | |
660 | 14 | proto_register_field_array(proto_dsdl, hf, array_length(hf)); |
661 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
662 | | |
663 | 14 | register_dissector("uavcan_dsdl.message", dissect_dsdl_message, proto_dsdl); |
664 | 14 | register_dissector("uavcan_dsdl.request", dissect_dsdl_service_request, proto_dsdl); |
665 | 14 | register_dissector("uavcan_dsdl.response", dissect_dsdl_service_response, proto_dsdl); |
666 | 14 | } |
667 | | |
668 | | void |
669 | | proto_reg_handoff_dsdl(void) |
670 | 14 | { |
671 | 14 | } |
672 | | |
673 | | /* |
674 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
675 | | * |
676 | | * Local variables: |
677 | | * c-basic-offset: 4 |
678 | | * tab-width: 8 |
679 | | * indent-tabs-mode: nil |
680 | | * End: |
681 | | * |
682 | | * vi: set shiftwidth=4 tabstop=8 expandtab: |
683 | | * :indentSize=4:tabSize=8:noTabs=true: |
684 | | */ |