epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-asam-cmp.c
blob530fe44720f3b49773d34a9ac3ce87fa29beedc9
1 /* packet-asam-cmp.c
2 * ASAM Capture Module Protocol dissector.
3 * Copyright 2021-2023 Alicia Mediano Schikarski, Technica Engineering GmbH
4 * Copyright 2021-2024 Dr. Lars Voelker, Technica Engineering GmbH
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
14 * This is a dissector for the Capture Module Protocol standardized by the ASAM.
15 * ASAM CMP is the standardized successor of TECMP.
18 #include "config.h"
20 #include <epan/packet.h>
21 #include <epan/uat.h>
22 #include <epan/expert.h>
23 #include <epan/tfs.h>
24 #include <epan/unit_strings.h>
26 #include "packet-socketcan.h"
27 #include "packet-flexray.h"
28 #include "packet-lin.h"
30 void proto_register_asam_cmp(void);
31 void proto_reg_handoff_asam_cmp(void);
33 static int proto_asam_cmp;
35 static dissector_handle_t eth_handle;
37 static bool heuristic_first;
38 static bool old_11bit_canid_encoding;
40 static dissector_table_t lin_subdissector_table;
42 /* Header fields */
43 static int hf_cmp_header;
44 static int hf_cmp_version;
45 static int hf_cmp_header_res;
46 static int hf_cmp_device_id;
47 static int hf_cmp_msg_type;
48 static int hf_cmp_stream_id;
49 static int hf_cmp_stream_seq_ctr;
51 /* Message Fields */
52 /* Message Header Fields */
53 static int hf_cmp_msg_header;
55 static int hf_cmp_common_flag_recal;
56 static int hf_cmp_common_flag_insync;
57 static int hf_cmp_common_flag_seg;
58 static int hf_cmp_common_flag_dir_on_if;
59 static int hf_cmp_common_flag_overflow;
60 static int hf_cmp_common_flag_err_in_payload;
61 static int hf_cmp_common_flag_reserved;
62 static int hf_cmp_common_flag_reserved_ctrl;
64 static int hf_cmp_msg_timestamp;
65 static int hf_cmp_msg_timestamp_ns;
66 static int hf_cmp_msg_reserved;
67 static int hf_cmp_msg_common_flags;
68 static int hf_cmp_msg_vendor_id;
69 static int hf_cmp_msg_payload_length;
70 static int hf_cmp_msg_payload;
72 /* Additional Data Message Header Fields */
73 static int hf_cmp_interface_id;
74 static int hf_cmp_payload_type;
76 /* Additional Control Message Header Fields */
77 static int hf_cmp_ctrl_msg_reserved;
78 static int hf_cmp_ctrl_msg_payload_type;
80 /* Additional Status Message Header Fields */
81 static int hf_cmp_status_msg_payload_type;
83 /* Additional Status Message Header Fields */
84 static int hf_cmp_vendor_msg_payload_type;
86 /* Data Message Payload Fields */
87 /* CAN */
88 #define CMP_CAN_FLAGS_ERRORS 0x03ff
89 #define CMP_CAN_ID_11BIT_MASK 0x1ffc0000
90 #define CMP_CAN_ID_11BIT_SHIFT 18
91 #define CMP_CAN_ID_11BIT_MASK_OLD 0x000007ff
92 #define CMP_CAN_ID_29BIT_MASK 0x1fffffff
93 #define CMP_CAN_ID_RES 0x20000000
94 #define CMP_CAN_ID_RTR 0x40000000
95 #define CMP_CAN_ID_IDE 0x80000000
97 #define CMP_CAN_CRC_CRC 0x00007fff
98 #define CMP_CAN_CRC_RES 0x7fff8000
99 #define CMP_CAN_CRC_CRC_SUPP 0x80000000
101 static int hf_cmp_can_flags;
103 static int hf_cmp_can_flag_crc_err;
104 static int hf_cmp_can_flag_ack_err;
105 static int hf_cmp_can_flag_passive_ack_err;
106 static int hf_cmp_can_flag_active_ack_err;
107 static int hf_cmp_can_flag_ack_del_err;
108 static int hf_cmp_can_flag_form_err;
109 static int hf_cmp_can_flag_stuff_err;
110 static int hf_cmp_can_flag_crc_del_err;
111 static int hf_cmp_can_flag_eof_err;
112 static int hf_cmp_can_flag_bit_err;
113 static int hf_cmp_can_flag_r0;
114 static int hf_cmp_can_flag_srr_dom;
115 static int hf_cmp_can_flag_reserved;
117 static int hf_cmp_can_reserved;
118 static int hf_cmp_can_id;
119 static int hf_cmp_can_id_11bit;
120 static int hf_cmp_can_id_11bit_old;
121 static int hf_cmp_can_id_29bit;
122 static int hf_cmp_can_id_res;
123 static int hf_cmp_can_id_rtr;
124 static int hf_cmp_can_id_ide;
125 static int hf_cmp_can_crc;
126 static int hf_cmp_can_crc_crc;
127 static int hf_cmp_can_crc_res;
128 static int hf_cmp_can_crc_crc_support;
129 static int hf_cmp_can_err_pos;
130 static int hf_cmp_can_dlc;
131 static int hf_cmp_can_data_len;
133 /* CAN FD */
134 #define CMP_CANFD_FLAGS_ERRORS 0x03ff
135 #define CMP_CANFD_ID_RES 0x20000000
136 #define CMP_CANFD_ID_RRS 0x40000000
137 #define CMP_CANFD_ID_IDE 0x80000000
139 #define CMP_CANFD_CRC_CRC17 0x0001ffff
140 #define CMP_CANFD_CRC_CRC21 0x001fffff
141 #define CMP_CANFD_CRC_SBC 0x00e00000
142 #define CMP_CANFD_CRC_SBC_PARITY 0x01000000
143 #define CMP_CANFD_CRC_RES 0x3e000000
144 #define CMP_CANFD_CRC_SBC_SUPP 0x40000000
145 #define CMP_CANFD_CRC_CRC_SUPP 0x80000000
147 static int hf_cmp_canfd_flags;
149 static int hf_cmp_canfd_flag_crc_err;
150 static int hf_cmp_canfd_flag_ack_err;
151 static int hf_cmp_canfd_flag_passive_ack_err;
152 static int hf_cmp_canfd_flag_active_ack_err;
153 static int hf_cmp_canfd_flag_ack_del_err;
154 static int hf_cmp_canfd_flag_form_err;
155 static int hf_cmp_canfd_flag_stuff_err;
156 static int hf_cmp_canfd_flag_crc_del_err;
157 static int hf_cmp_canfd_flag_eof_err;
158 static int hf_cmp_canfd_flag_bit_err;
159 static int hf_cmp_canfd_flag_res;
160 static int hf_cmp_canfd_flag_srr_dom;
161 static int hf_cmp_canfd_flag_brs;
162 static int hf_cmp_canfd_flag_esi;
163 static int hf_cmp_canfd_flag_reserved;
165 static int hf_cmp_canfd_reserved;
166 static int hf_cmp_canfd_id;
167 static int hf_cmp_canfd_id_11bit;
168 static int hf_cmp_canfd_id_11bit_old;
169 static int hf_cmp_canfd_id_29bit;
170 static int hf_cmp_canfd_id_res;
171 static int hf_cmp_canfd_id_rrs;
172 static int hf_cmp_canfd_id_ide;
173 static int hf_cmp_canfd_crc;
174 static int hf_cmp_canfd_crc_crc17;
175 static int hf_cmp_canfd_crc_crc21;
176 static int hf_cmp_canfd_crc_sbc;
177 static int hf_cmp_canfd_crc_sbc_parity;
178 static int hf_cmp_canfd_crc_res;
179 static int hf_cmp_canfd_crc_sbc_support;
180 static int hf_cmp_canfd_crc_crc_support;
181 static int hf_cmp_canfd_err_pos;
182 static int hf_cmp_canfd_dlc;
183 static int hf_cmp_canfd_data_len;
185 /* LIN */
186 #define CMP_CANFD_PID_PARITY_MASK 0xc0
187 #define CMP_CANFD_PID_ID_MASK 0x3f
189 static int hf_cmp_lin_flags;
190 static int hf_cmp_lin_flag_checksum_err;
191 static int hf_cmp_lin_flag_col_err;
192 static int hf_cmp_lin_flag_parity_err;
193 static int hf_cmp_lin_flag_no_slave_res_err;
194 static int hf_cmp_lin_flag_sync_err;
195 static int hf_cmp_lin_flag_framing_err;
196 static int hf_cmp_lin_flag_short_dom_err;
197 static int hf_cmp_lin_flag_long_dom_err;
198 static int hf_cmp_lin_flag_wup;
199 static int hf_cmp_lin_flag_reserved;
201 static int hf_cmp_lin_reserved;
202 static int hf_cmp_lin_pid;
203 static int hf_cmp_lin_pid_parity;
204 static int hf_cmp_lin_pid_id;
205 static int hf_cmp_lin_reserved_2;
206 static int hf_cmp_lin_checksum;
207 static int hf_cmp_lin_data_len;
209 /* FlexRay */
210 #define CMP_FLEXRAY_FLAGS_NF 0x0004
212 static int hf_cmp_flexray_flags;
214 static int hf_cmp_flexray_flag_crc_frame_err;
215 static int hf_cmp_flexray_flag_crc_header_err;
216 static int hf_cmp_flexray_flag_nf;
217 static int hf_cmp_flexray_flag_sf;
218 static int hf_cmp_flexray_flag_sync;
219 static int hf_cmp_flexray_flag_wus;
220 static int hf_cmp_flexray_flag_ppi;
221 static int hf_cmp_flexray_flag_cas;
222 static int hf_cmp_flexray_flag_reserved;
224 static int hf_cmp_flexray_reserved;
225 static int hf_cmp_flexray_header_crc;
226 static int hf_cmp_flexray_frame_id;
227 static int hf_cmp_flexray_cycle;
228 static int hf_cmp_flexray_frame_crc;
229 static int hf_cmp_flexray_reserved_2;
230 static int hf_cmp_flexray_data_len;
232 /* UART/RS-232 */
233 #define CMP_UART_DATA_DATA_MASK 0x01FF
235 static int hf_cmp_uart_flags;
237 static int hf_cmp_uart_flag_cl;
238 static int hf_cmp_uart_flag_reserved;
240 static int hf_cmp_uart_reserved;
241 static int hf_cmp_uart_data_len;
242 static int hf_cmp_uart_data;
244 static int hf_cmp_uart_data_data;
245 static int hf_cmp_uart_data_reserved;
246 static int hf_cmp_uart_data_framing_err;
247 static int hf_cmp_uart_data_break_condition;
248 static int hf_cmp_uart_data_parity_err;
250 /* Analog */
251 static int hf_cmp_analog_flags;
253 static int hf_cmp_analog_flag_sample_dt;
254 static int hf_cmp_analog_flag_reserved;
256 static int hf_cmp_analog_reserved;
257 static int hf_cmp_analog_unit;
258 static int hf_cmp_analog_sample_interval;
259 static int hf_cmp_analog_sample_offset;
260 static int hf_cmp_analog_sample_scalar;
261 static int hf_cmp_analog_sample;
262 static int hf_cmp_analog_sample_raw;
264 /* Ethernet */
265 static int hf_cmp_eth_flags;
267 static int hf_cmp_eth_flag_fcs_err;
268 static int hf_cmp_eth_flag_short_err;
269 static int hf_cmp_eth_flag_tx_down;
270 static int hf_cmp_eth_flag_collision;
271 static int hf_cmp_eth_flag_long_err;
272 static int hf_cmp_eth_flag_phy_err;
273 static int hf_cmp_eth_flag_truncated;
274 static int hf_cmp_eth_flag_fcs_supported;
275 static int hf_cmp_eth_flag_reserved;
277 static int hf_cmp_eth_reserved;
278 static int hf_cmp_eth_payload_length;
280 /* Control Message Payload Fields */
281 /* Data Sink Ready */
282 static int hf_cmp_ctrl_msg_device_id;
284 /* User Event */
285 static int hf_cmp_ctrl_msg_event_id;
287 /* Vendor specific */
288 static int hf_cmp_ctrl_msg_vendor_id;
289 static int hf_cmp_ctrl_msg_vendor_payload_type;
291 /* Status Message Payload Fields */
292 /* Capture Module Status Message */
293 static int hf_cmp_status_msg_cm_uptime_ns;
294 static int hf_cmp_status_msg_cm_uptime_s;
295 static int hf_cmp_status_msg_gm_identity;
296 static int hf_cmp_status_msg_gm_clock_quality;
297 static int hf_cmp_status_msg_current_utc_offset;
298 static int hf_cmp_status_msg_time_source;
299 static int hf_cmp_status_msg_domain_num;
300 static int hf_cmp_status_msg_res;
301 static int hf_cmp_gptp_flags;
303 static int hf_cmp_gptp_flags_leap61;
304 static int hf_cmp_gptp_flags_leap59;
305 static int hf_cmp_gptp_flags_cur_utco_valid;
306 static int hf_cmp_gptp_flags_ptp_timescale;
307 static int hf_cmp_gptp_flags_time_traceable;
308 static int hf_cmp_gptp_flags_freq_traceable;
309 static int hf_cmp_gptp_flags_reserved;
311 static int hf_cmp_status_dev_desc_length;
312 static int hf_cmp_status_dev_desc;
313 static int hf_cmp_status_sn_length;
314 static int hf_cmp_status_sn;
315 static int hf_cmp_status_hw_ver_length;
316 static int hf_cmp_status_hw_ver;
317 static int hf_cmp_status_sw_ver_length;
318 static int hf_cmp_status_sw_ver;
319 static int hf_cmp_status_vendor_data_length;
320 static int hf_cmp_status_vendor_data;
322 /* Interface Status Message */
323 static int hf_cmp_iface_interface;
324 static int hf_cmp_iface_iface_id;
325 static int hf_cmp_iface_msg_total_rx;
326 static int hf_cmp_iface_msg_total_tx;
327 static int hf_cmp_iface_msg_dropped_rx;
328 static int hf_cmp_iface_msg_dropped_tx;
329 static int hf_cmp_iface_errs_total_rx;
330 static int hf_cmp_iface_errs_total_tx;
331 static int hf_cmp_iface_iface_type;
332 static int hf_cmp_iface_iface_status;
333 static int hf_cmp_iface_stream_id_cnt;
334 static int hf_cmp_iface_reserved;
336 static int hf_cmp_iface_feat;
337 static int hf_cmp_iface_feat_can_pas_ack;
338 static int hf_cmp_iface_feat_can_act_ack;
339 static int hf_cmp_iface_feat_can_ack_del_err;
340 static int hf_cmp_iface_feat_can_crc_del_err;
341 static int hf_cmp_iface_feat_can_eof_err;
342 static int hf_cmp_iface_feat_can_r0;
343 static int hf_cmp_iface_feat_can_srr_dom;
345 static int hf_cmp_iface_feat_canfd_pas_ack;
346 static int hf_cmp_iface_feat_canfd_act_ack;
347 static int hf_cmp_iface_feat_canfd_ack_del_err;
348 static int hf_cmp_iface_feat_canfd_crc_del_err;
349 static int hf_cmp_iface_feat_canfd_eof_err;
350 static int hf_cmp_iface_feat_canfd_rsvd;
351 static int hf_cmp_iface_feat_canfd_srr_dom;
352 static int hf_cmp_iface_feat_canfd_brs_dom;
353 static int hf_cmp_iface_feat_canfd_esi_dom;
355 static int hf_cmp_iface_feat_lin_sync_err;
356 static int hf_cmp_iface_feat_lin_framing_err;
357 static int hf_cmp_iface_feat_lin_short_dom_err;
358 static int hf_cmp_iface_feat_lin_long_dom_err;
359 static int hf_cmp_iface_feat_lin_wup;
361 static int hf_cmp_iface_feat_eth_too_long;
362 static int hf_cmp_iface_feat_eth_phy_err;
363 static int hf_cmp_iface_feat_eth_trunc;
365 static int hf_cmp_iface_stream_ids;
366 static int hf_cmp_iface_stream_id;
367 static int hf_cmp_iface_vendor_data_len;
368 static int hf_cmp_iface_vendor_data;
370 /* Configuration Status Message */
371 static int hf_cmp_status_msg_config;
373 /* Data Lost Event Status Message */
374 static int hf_cmp_dataloss_data_sink_port;
375 static int hf_cmp_dataloss_device_id;
376 static int hf_cmp_dataloss_reserved;
377 static int hf_cmp_dataloss_stream_id;
378 static int hf_cmp_dataloss_last_ssq_value;
379 static int hf_cmp_dataloss_current_ssq_value;
381 /* Time Sync Lost Event Status Message */
382 static int hf_cmp_timeloss_port_nr;
383 static int hf_cmp_timeloss_device_id;
384 static int hf_cmp_timeloss_error_flags;
386 static int hf_cmp_timeloss_error_flags_ts;
387 static int hf_cmp_timeloss_error_flags_insync;
388 static int hf_cmp_timeloss_error_flags_delta;
389 static int hf_cmp_timeloss_error_flags_reserved;
391 /* Vendor Specific */
392 static int hf_cmp_status_msg_vendor_specific;
394 /* Protocol trees */
395 static int ett_asam_cmp;
396 static int ett_asam_cmp_header;
397 static int ett_asam_cmp_timestamp;
398 static int ett_asam_cmp_common_flags;
399 static int ett_asam_cmp_payload;
400 static int ett_asam_cmp_payload_flags;
401 static int ett_asam_cmp_lin_pid;
402 static int ett_asam_cmp_can_id;
403 static int ett_asam_cmp_can_crc;
404 static int ett_asam_cmp_uart_data;
405 static int ett_asam_cmp_analog_sample;
406 static int ett_asam_cmp_status_cm_flags;
407 static int ett_asam_cmp_status_cm_uptime;
408 static int ett_asam_cmp_status_timeloss_flags;
409 static int ett_asam_cmp_status_interface;
410 static int ett_asam_cmp_status_feature_support;
411 static int ett_asam_cmp_status_stream_ids;
413 /* General */
414 #define CMP_HEADER_LEN 8
415 #define CMP_MSG_HEADER_LEN 16
417 /* CMP Message Type Names */
418 #define CMP_MSG_TYPE_DATA_MSG 0x01
419 #define CMP_MSG_TYPE_CTRL_MSG 0x02
420 #define CMP_MSG_TYPE_STATUS_MSG 0x03
421 #define CMP_MSG_TYPE_VENDOR 0xFF
423 /* CMP Segmentation Flag Values */
424 #define CMP_SEG_UNSEGMENTED 0x00
425 #define CMP_SEG_FIRST 0x01
426 #define CMP_SEG_INTERMEDIARY 0x02
427 #define CMP_SEG_LAST 0x03
429 /* CMP Data Message Payload Type Names */
430 #define CMP_DATA_MSG_INVALID 0x00
431 #define CMP_DATA_MSG_CAN 0x01
432 #define CMP_DATA_MSG_CANFD 0x02
433 #define CMP_DATA_MSG_LIN 0x03
434 #define CMP_DATA_MSG_FLEXRAY 0x04
435 #define CMP_DATA_MSG_DIGITAL 0x05
436 #define CMP_DATA_MSG_UART_RS_232 0x06
437 #define CMP_DATA_MSG_ANALOG 0x07
438 #define CMP_DATA_MSG_ETHERNET 0x08
439 #define CMP_DATA_MSG_SPI 0x09
440 #define CMP_DATA_MSG_I2C 0x0A
441 #define CMP_DATA_MSG_GIGEVISION 0x0B
442 #define CMP_DATA_MSG_MIPI_CSI2 0x0C
443 #define CMP_DATA_MSG_USER_DEFINED 0xFF
445 /* CMP Digital Trigger Pattern Values */
446 #define CMP_T_PATTERN_FALLING 0x00
447 #define CMP_T_PATTERN_RISING 0x01
449 /* CMP Digital Data Message DL Values */
450 #define CMP_UART_CL_5 0x00
451 #define CMP_UART_CL_6 0x01
452 #define CMP_UART_CL_7 0x02
453 #define CMP_UART_CL_8 0x03
454 #define CMP_UART_CL_9 0x04
456 /* CMP Analog Data Message DT Values */
457 #define CMP_ANALOG_DATA_MSG_DL_16 0x00
458 #define CMP_ANALOG_DATA_MSG_DL_32 0x01
459 #define CMP_ANALOG_DATA_MSG_DL_RES1 0x02
460 #define CMP_ANALOG_DATA_MSG_DL_RES2 0x03
462 /* CMP Control Message Payload Type Names */
463 #define CMP_CTRL_MSG_INVALID 0x00
464 #define CMP_CTRL_MSG_DSR_CTRL_MSG 0x01
465 #define CMP_CTRL_MSG_USER_EVENT_CTRL_MSG 0xFE
466 #define CMP_CTRL_MSG_VENDOR 0xFF
468 /* CMP Status Message Payload Type Names */
469 #define CMP_STATUS_MSG_INVALID 0x00
470 #define CMP_STATUS_MSG_CM_STAT_MSG 0x01
471 #define CMP_STATUS_MSG_IF_STAT_MSG 0x02
472 #define CMP_STATUS_MSG_CONF_STAT_MSG 0x03
473 #define CMP_STATUS_MSG_DLE_STAT_MSG 0x04
474 #define CMP_STATUS_MSG_TSLE_STAT_MSG 0x05
475 #define CMP_STATUS_MSG_VENDOR_STAT_MSG 0xFF
477 /* Interface Status Message Names */
478 #define CMP_STATUS_IFACE_DOWN_EN 0x00
479 #define CMP_STATUS_IFACE_UP_EN 0x01
480 #define CMP_STATUS_IFACE_DOWN_DIS 0x02
482 static const value_string msg_type_names[] = {
483 {CMP_MSG_TYPE_DATA_MSG, "Data Message"},
484 {CMP_MSG_TYPE_CTRL_MSG, "Control Message"},
485 {CMP_MSG_TYPE_STATUS_MSG, "Status Message"},
486 {CMP_MSG_TYPE_VENDOR, "Vendor Specific Data"},
487 {0, NULL}
490 static const value_string seg_flag_names[] = {
491 {CMP_SEG_INTERMEDIARY, "Intermediary segment"},
492 {CMP_SEG_FIRST, "First segment"},
493 {CMP_SEG_LAST, "Last segment"},
494 {CMP_SEG_UNSEGMENTED, "Unsegmented"},
495 {0, NULL}
498 static const true_false_string interface_direction = {
499 "Sending",
500 "Receive"
503 static const value_string data_msg_type_names[] = {
504 {CMP_DATA_MSG_INVALID, "Invalid"},
505 {CMP_DATA_MSG_CAN, "CAN"},
506 {CMP_DATA_MSG_CANFD, "CAN-FD"},
507 {CMP_DATA_MSG_LIN, "LIN"},
508 {CMP_DATA_MSG_FLEXRAY, "FlexRay"},
509 {CMP_DATA_MSG_DIGITAL, "Digital"},
510 {CMP_DATA_MSG_UART_RS_232, "UART/RS-232"},
511 {CMP_DATA_MSG_ANALOG, "Analog"},
512 {CMP_DATA_MSG_ETHERNET, "Ethernet"},
513 {CMP_DATA_MSG_SPI, "SPI"},
514 {CMP_DATA_MSG_I2C, "I2C"},
515 {CMP_DATA_MSG_GIGEVISION, "Gigevision"},
516 {CMP_DATA_MSG_MIPI_CSI2, "MIPI CSI-2"},
517 {CMP_DATA_MSG_USER_DEFINED, "User defined"},
518 {0, NULL}
521 static const true_false_string can_dom_rec = {
522 "Dominant",
523 "Recessive"
526 static const true_false_string can_rec_dom = {
527 "Recessive",
528 "Dominant"
531 static const true_false_string can_id_ide = {
532 "29bit ID",
533 "11bit ID"
536 static const true_false_string can_id_rtr = {
537 "Remote Frame",
538 "Data Frame"
541 static const true_false_string canfd_act_pas = {
542 "Error active",
543 "Error passive"
547 static const value_string uart_cl_names[] = {
548 {CMP_UART_CL_5, "5 Bits"},
549 {CMP_UART_CL_6, "6 Bits"},
550 {CMP_UART_CL_7, "7 Bits"},
551 {CMP_UART_CL_8, "8 Bits"},
552 {CMP_UART_CL_9, "9 Bits"},
553 {0, NULL}
556 static const value_string analog_sample_dt[] = {
557 {CMP_ANALOG_DATA_MSG_DL_16, "A_INT16"},
558 {CMP_ANALOG_DATA_MSG_DL_32, "A_INT32"},
559 {CMP_ANALOG_DATA_MSG_DL_RES1, "Reserved"},
560 {CMP_ANALOG_DATA_MSG_DL_RES2, "Reserved"},
561 {0, NULL}
564 static const value_string ctrl_msg_type_names[] = {
565 {CMP_CTRL_MSG_INVALID, "Invalid"},
566 {CMP_CTRL_MSG_DSR_CTRL_MSG, "Data Sink ready to receive Control Message"},
567 {CMP_CTRL_MSG_USER_EVENT_CTRL_MSG, "User Event Message"},
568 {CMP_CTRL_MSG_VENDOR, "Vendor Specific Control Message"},
569 {0, NULL}
572 static const value_string status_msg_type_names[] = {
573 {CMP_STATUS_MSG_INVALID, "Invalid"},
574 {CMP_STATUS_MSG_CM_STAT_MSG, "Capture Module Status"},
575 {CMP_STATUS_MSG_IF_STAT_MSG, "Interface Status"},
576 {CMP_STATUS_MSG_CONF_STAT_MSG, "Configuration Status"},
577 {CMP_STATUS_MSG_DLE_STAT_MSG, "Data Lost Status"},
578 {CMP_STATUS_MSG_TSLE_STAT_MSG, "Time Sync Lost Status"},
579 {CMP_STATUS_MSG_VENDOR_STAT_MSG, "Vendor specific Status"},
580 {0, NULL}
583 static const value_string interface_status_names[] = {
584 {CMP_STATUS_IFACE_DOWN_EN, "Down and enabled"},
585 {CMP_STATUS_IFACE_UP_EN, "Up and enabled"},
586 {CMP_STATUS_IFACE_DOWN_DIS, "Down and disabled"},
587 {0, NULL}
590 /* As defined by the ASAM Vendor ID registry for POD and CMP */
591 #define CMP_VENDOR_ID_AVL_LIST 0x0006
592 #define CMP_VENDOR_DSPACE 0x000b
593 #define CMP_VENDOR_ETAS 0x000c
594 #define CMP_VENDOR_BOSCH 0x0027
595 #define CMP_VENDOR_VECTOR 0x002d
596 #define CMP_VENDOR_CONTINENTAL 0x003c
597 #define CMP_VENDOR_MK 0x003e
598 #define CMP_VENDOR_ID_ACCURATE 0x004a
599 #define CMP_VENDOR_RA 0x006c
600 #define CMP_VENDOR_X2E 0x00ca
601 #define CMP_VENDOR_INTREPIDCS 0x00f0
602 #define CMP_VENDOR_ID_BPLUS 0x010f
603 #define CMP_VENDOR_VIGEM 0x012a
604 #define CMP_VENDOR_TECHNICA 0x019c
605 #define CMP_VENDOR_ID_AED_ENG 0x0241
607 /* As defined by the ASAM Vendor ID registry for POD and CMP */
608 static const value_string vendor_ids[] = {
609 {CMP_VENDOR_ID_ACCURATE, "Accurate Technologies Inc."},
610 {CMP_VENDOR_ID_AED_ENG, "AED Engineering GmbH"},
611 {CMP_VENDOR_ID_AVL_LIST, "AVL List GmbH"},
612 {CMP_VENDOR_ID_BPLUS, "b-plus GmbH"},
613 {CMP_VENDOR_CONTINENTAL, "Continental AG"},
614 {CMP_VENDOR_DSPACE, "dSPACE GmbH"},
615 {CMP_VENDOR_ETAS, "ETAS GmbH"},
616 {CMP_VENDOR_INTREPIDCS, "Intrepid Control Systems, Inc."},
617 {CMP_VENDOR_MK, "M&K Meß- und Kommunikationstechnik GmbH"},
618 {CMP_VENDOR_RA, "RA Consulting GmbH"},
619 {CMP_VENDOR_BOSCH, "Robert Bosch GmbH"},
620 {CMP_VENDOR_TECHNICA, "Technica Engineering GmbH"},
621 {CMP_VENDOR_VECTOR, "Vector Informatik GmbH"},
622 {CMP_VENDOR_VIGEM, "ViGEM GmbH"},
623 {CMP_VENDOR_X2E, "X2E GmbH"},
624 {0, NULL}
627 static const value_string analog_units[] = {
628 {0x01, "s"},
629 {0x02, "m"},
630 {0x03, "kg"},
631 {0x04, "A"},
632 {0x05, "K"},
633 {0x06, "mol"},
634 {0x07, "cd"},
635 {0x08, "Hz"},
636 {0x09, "rad"},
637 {0x0a, "sr"},
638 {0x0b, "N"},
639 {0x0c, "Pa"},
640 {0x0d, "J"},
641 {0x0e, "W"},
642 {0x0f, "C"},
643 {0x10, "V"},
644 {0x11, "F"},
645 {0x12, "Ω"},
646 {0x13, "S"},
647 {0x14, "Wb"},
648 {0x15, "T"},
649 {0x16, "H"},
650 {0x17, "°C"},
651 {0x18, "lm"},
652 {0x19, "lx"},
653 {0x1A, "Bq"},
654 {0x1B, "Gy"},
655 {0x1C, "Sv"},
656 {0x1D, "kat"},
657 {0x1E, "m/s"},
658 {0x1F, "m/s2"},
659 {0x20, "m/s3"},
660 {0x21, "m/s4"},
661 {0x22, "rad/s"},
662 {0x23, "rad/s2"},
663 {0x24, "Hz/s"},
664 {0x25, "m3/s"},
665 {0x26, "m2"},
666 {0x27, "m3"},
667 {0x28, "N s"},
668 {0x29, "N m s"},
669 {0x2A, "N m"},
670 {0x2B, "kg/m2"},
671 {0x2C, "kg/m3"},
672 {0x2D, "m3/kg"},
673 {0x2E, "J s"},
674 {0x2F, "J/kg"},
675 {0x30, "J/m3"},
676 {0x31, "N/m"},
677 {0x32, "W/m2"},
678 {0x33, "m2/s"},
679 {0x34, "Pa s"},
680 {0x35, "kg/s"},
681 {0x36, "W/(sr m2)"},
682 {0x37, "Gy/s"},
683 {0x38, "m/m3"},
684 {0x39, "W/m3"},
685 {0x3A, "J/(m2 s)"},
686 {0x3B, "kg m2"},
687 {0x3C, "W/sr"},
688 {0x3D, "mol/m3"},
689 {0x3E, "m3/mol"},
690 {0x3F, "J/(mol K)"},
691 {0x40, "J/mol"},
692 {0x41, "mol/kg"},
693 {0x42, "kg/mol"},
694 {0x45, "C/m3"},
695 {0x46, "A/m2"},
696 {0x47, "S/m"},
697 {0x48, "F/m"},
698 {0x49, "H/m"},
699 {0x4A, "V/m"},
700 {0x4B, "A/m"},
701 {0x4C, "C/Kg"},
702 {0x4D, "J/T"},
703 {0x4E, "lm s"},
704 {0x4F, "lx s"},
705 {0x50, "cd/m2"},
706 {0x51, "lm/W"},
707 {0x52, "J/K"},
708 {0x53, "J/(K kg)"},
709 {0x54, "W/(m K)"},
710 {0, NULL}
713 /********* UATs *********/
715 typedef struct _generic_one_id_string {
716 unsigned id;
717 char *name;
718 } generic_one_id_string_t;
720 /* Interface UAT */
721 typedef struct _interface_config {
722 unsigned id;
723 unsigned bus_id;
724 char *name;
725 } interface_config_t;
727 /* Devices */
728 #define DATAFILE_ASAM_CMP_DEVICES_IDS "ASAM_CMP_devices"
730 static GHashTable *data_asam_cmp_devices;
731 static generic_one_id_string_t *asam_cmp_devices;
732 static unsigned asam_cmp_devices_num;
734 UAT_HEX_CB_DEF(asam_cmp_devices, id, generic_one_id_string_t)
735 UAT_CSTRING_CB_DEF(asam_cmp_devices, name, generic_one_id_string_t)
737 /* Interfaces */
738 #define DATAFILE_ASAM_CMP_IFACE_IDS "ASAM_CMP_interfaces"
740 static GHashTable *data_asam_cmp_interfaces;
741 static interface_config_t *asam_cmp_interfaces;
742 static unsigned asam_cmp_interface_num;
744 UAT_HEX_CB_DEF(asam_cmp_interfaces, id, interface_config_t)
745 UAT_CSTRING_CB_DEF(asam_cmp_interfaces, name, interface_config_t)
746 UAT_HEX_CB_DEF(asam_cmp_interfaces, bus_id, interface_config_t)
748 /*** expert info items ***/
749 static expert_field ei_asam_cmp_length_mismatch;
750 static expert_field ei_asam_cmp_unsupported_crc_not_zero;
752 /* generic UAT */
753 static void
754 tecmp_free_key(void *key) {
755 wmem_free(wmem_epan_scope(), key);
758 static void
759 simple_free(void *data) {
760 /* we need to free because of the g_strdup in post_update*/
761 g_free(data);
764 /* ID -> Name */
765 static void *
766 copy_generic_one_id_string_cb(void *n, const void *o, size_t size _U_) {
767 generic_one_id_string_t *new_rec = (generic_one_id_string_t *)n;
768 const generic_one_id_string_t *old_rec = (const generic_one_id_string_t *)o;
770 new_rec->name = g_strdup(old_rec->name);
771 new_rec->id = old_rec->id;
772 return new_rec;
775 static bool
776 update_generic_one_identifier_16bit(void *r, char **err) {
777 generic_one_id_string_t *rec = (generic_one_id_string_t *)r;
779 if (rec->id > 0xffff) {
780 *err = ws_strdup_printf("We currently only support 16 bit identifiers (ID: %i Name: %s)", rec->id, rec->name);
781 return false;
784 if (rec->name == NULL || rec->name[0] == 0) {
785 *err = g_strdup("Name cannot be empty");
786 return false;
789 return true;
792 static void
793 free_generic_one_id_string_cb(void *r) {
794 generic_one_id_string_t *rec = (generic_one_id_string_t *)r;
795 /* freeing result of g_strdup */
796 g_free(rec->name);
797 rec->name = NULL;
800 static void
801 post_update_one_id_string_template_cb(generic_one_id_string_t *data, unsigned data_num, GHashTable *ht) {
802 unsigned i;
803 int *key = NULL;
805 for (i = 0; i < data_num; i++) {
806 key = wmem_new(wmem_epan_scope(), int);
807 *key = data[i].id;
809 g_hash_table_insert(ht, key, g_strdup(data[i].name));
813 static char *
814 ht_lookup_name(GHashTable *ht, unsigned int identifier) {
815 char *tmp = NULL;
816 unsigned int *id = NULL;
818 if (ht == NULL) {
819 return NULL;
822 id = wmem_new(wmem_epan_scope(), unsigned int);
823 *id = (unsigned int)identifier;
824 tmp = (char *)g_hash_table_lookup(ht, id);
825 wmem_free(wmem_epan_scope(), id);
827 return tmp;
830 /* ID -> ID, Name */
831 static void *
832 copy_interface_config_cb(void *n, const void *o, size_t size _U_) {
833 interface_config_t *new_rec = (interface_config_t *)n;
834 const interface_config_t *old_rec = (const interface_config_t *)o;
836 new_rec->id = old_rec->id;
837 new_rec->name = g_strdup(old_rec->name);
838 new_rec->bus_id = old_rec->bus_id;
839 return new_rec;
842 static bool
843 update_interface_config(void *r, char **err) {
844 interface_config_t *rec = (interface_config_t *)r;
846 if (rec->id > 0xffffffff) {
847 *err = ws_strdup_printf("We currently only support 32 bit identifiers (ID: %i Name: %s)", rec->id, rec->name);
848 return false;
851 if (rec->name == NULL || rec->name[0] == 0) {
852 *err = g_strdup("Name cannot be empty");
853 return false;
856 if (rec->bus_id > 0xffff) {
857 *err = ws_strdup_printf("We currently only support 16 bit bus identifiers (ID: %i Name: %s Bus-ID: %i)", rec->id, rec->name, rec->bus_id);
858 return false;
861 return true;
864 static void
865 free_interface_config_cb(void *r) {
866 interface_config_t *rec = (interface_config_t *)r;
867 /* freeing result of g_strdup */
868 g_free(rec->name);
869 rec->name = NULL;
872 static interface_config_t *
873 ht_lookup_channel_config(unsigned int identifier) {
874 interface_config_t *tmp = NULL;
875 unsigned int *id = NULL;
877 if (data_asam_cmp_interfaces == NULL) {
878 return NULL;
881 id = wmem_new(wmem_epan_scope(), unsigned int);
882 *id = (unsigned int)identifier;
883 tmp = (interface_config_t *)g_hash_table_lookup(data_asam_cmp_interfaces, id);
884 wmem_free(wmem_epan_scope(), id);
886 return tmp;
889 static char *
890 ht_interface_config_to_string(unsigned int identifier) {
891 interface_config_t *tmp = ht_lookup_channel_config(identifier);
892 if (tmp == NULL) {
893 return NULL;
896 return tmp->name;
899 static uint16_t
900 ht_interface_config_to_bus_id(unsigned int identifier) {
901 interface_config_t *tmp = ht_lookup_channel_config(identifier);
902 if (tmp == NULL) {
903 /* 0 means basically any or none */
904 return 0;
907 return tmp->bus_id;
910 static void
911 post_update_asam_cmp_devices_cb(void) {
912 /* destroy old hash table, if it exists */
913 if (data_asam_cmp_devices) {
914 g_hash_table_destroy(data_asam_cmp_devices);
915 data_asam_cmp_devices = NULL;
918 /* create new hash table */
919 data_asam_cmp_devices = g_hash_table_new_full(g_int_hash, g_int_equal, &tecmp_free_key, &simple_free);
920 post_update_one_id_string_template_cb(asam_cmp_devices, asam_cmp_devices_num, data_asam_cmp_devices);
923 static void
924 post_update_interface_config_cb(void) {
925 unsigned i;
926 int *key = NULL;
928 /* destroy old hash table, if it exists */
929 if (data_asam_cmp_interfaces) {
930 g_hash_table_destroy(data_asam_cmp_interfaces);
931 data_asam_cmp_interfaces = NULL;
934 /* create new hash table */
935 data_asam_cmp_interfaces = g_hash_table_new_full(g_int_hash, g_int_equal, &tecmp_free_key, NULL);
937 if (data_asam_cmp_interfaces == NULL || asam_cmp_interfaces == NULL || asam_cmp_interface_num == 0) {
938 return;
941 for (i = 0; i < asam_cmp_interface_num; i++) {
942 key = wmem_new(wmem_epan_scope(), int);
943 *key = asam_cmp_interfaces[i].id;
944 g_hash_table_insert(data_asam_cmp_interfaces, key, &asam_cmp_interfaces[i]);
948 static void
949 add_device_id_text(proto_item *ti, uint16_t device_id) {
950 const char *descr = ht_lookup_name(data_asam_cmp_devices, device_id);
952 if (descr != NULL) {
953 proto_item_append_text(ti, " (%s)", descr);
957 static void
958 add_interface_id_text(proto_item *ti, uint32_t interface_id) {
959 const char *descr = ht_interface_config_to_string(interface_id);
961 if (descr != NULL) {
962 proto_item_append_text(ti, " (%s)", descr);
966 static int
967 dissect_asam_cmp_data_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root_tree, proto_tree *tree, unsigned offset_orig) {
968 proto_item *ti = NULL;
969 proto_item *ti_msg_header = NULL;
970 proto_item *ti_msg_payload = NULL;
971 proto_tree *asam_cmp_data_msg_header_tree = NULL;
972 proto_tree *asam_cmp_data_msg_payload_tree = NULL;
973 proto_tree *subtree = NULL;
974 unsigned offset = offset_orig;
976 unsigned msg_payload_type = 0;
977 unsigned msg_payload_length = 0;
978 unsigned msg_payload_type_length = 0;
979 unsigned interface_id = 0;
981 static int * const asam_cmp_common_flags[] = {
982 &hf_cmp_common_flag_reserved,
983 &hf_cmp_common_flag_err_in_payload,
984 &hf_cmp_common_flag_overflow,
985 &hf_cmp_common_flag_dir_on_if,
986 &hf_cmp_common_flag_seg,
987 &hf_cmp_common_flag_insync,
988 &hf_cmp_common_flag_recal,
989 NULL
992 static int * const asam_cmp_can_flags[] = {
993 &hf_cmp_can_flag_reserved,
994 &hf_cmp_can_flag_srr_dom,
995 &hf_cmp_can_flag_r0,
996 &hf_cmp_can_flag_bit_err,
997 &hf_cmp_can_flag_eof_err,
998 &hf_cmp_can_flag_crc_del_err,
999 &hf_cmp_can_flag_stuff_err,
1000 &hf_cmp_can_flag_form_err,
1001 &hf_cmp_can_flag_ack_del_err,
1002 &hf_cmp_can_flag_active_ack_err,
1003 &hf_cmp_can_flag_passive_ack_err,
1004 &hf_cmp_can_flag_ack_err,
1005 &hf_cmp_can_flag_crc_err,
1006 NULL
1009 static int * const asam_cmp_canfd_flags[] = {
1010 &hf_cmp_canfd_flag_reserved,
1011 &hf_cmp_canfd_flag_esi,
1012 &hf_cmp_canfd_flag_brs,
1013 &hf_cmp_canfd_flag_srr_dom,
1014 &hf_cmp_canfd_flag_res,
1015 &hf_cmp_canfd_flag_bit_err,
1016 &hf_cmp_canfd_flag_eof_err,
1017 &hf_cmp_canfd_flag_crc_del_err,
1018 &hf_cmp_canfd_flag_stuff_err,
1019 &hf_cmp_canfd_flag_form_err,
1020 &hf_cmp_canfd_flag_ack_del_err,
1021 &hf_cmp_canfd_flag_active_ack_err,
1022 &hf_cmp_canfd_flag_passive_ack_err,
1023 &hf_cmp_canfd_flag_ack_err,
1024 &hf_cmp_canfd_flag_crc_err,
1025 NULL
1028 static int * const asam_cmp_lin_pid[] = {
1029 &hf_cmp_lin_pid_parity,
1030 &hf_cmp_lin_pid_id,
1031 NULL
1034 static int * const asam_cmp_lin_flags[] = {
1035 &hf_cmp_lin_flag_reserved,
1036 &hf_cmp_lin_flag_wup,
1037 &hf_cmp_lin_flag_long_dom_err,
1038 &hf_cmp_lin_flag_short_dom_err,
1039 &hf_cmp_lin_flag_framing_err,
1040 &hf_cmp_lin_flag_sync_err,
1041 &hf_cmp_lin_flag_no_slave_res_err,
1042 &hf_cmp_lin_flag_parity_err,
1043 &hf_cmp_lin_flag_col_err,
1044 &hf_cmp_lin_flag_checksum_err,
1045 NULL
1048 static int * const asam_cmp_flexray_flags[] = {
1049 &hf_cmp_flexray_flag_reserved,
1050 &hf_cmp_flexray_flag_cas,
1051 &hf_cmp_flexray_flag_ppi,
1052 &hf_cmp_flexray_flag_wus,
1053 &hf_cmp_flexray_flag_sync,
1054 &hf_cmp_flexray_flag_sf,
1055 &hf_cmp_flexray_flag_nf,
1056 &hf_cmp_flexray_flag_crc_header_err,
1057 &hf_cmp_flexray_flag_crc_frame_err,
1058 NULL
1061 static int * const asam_cmp_uart_flags[] = {
1062 &hf_cmp_uart_flag_reserved,
1063 &hf_cmp_uart_flag_cl,
1064 NULL
1067 static int * const asam_cmp_uart_data[] = {
1068 &hf_cmp_uart_data_parity_err,
1069 &hf_cmp_uart_data_break_condition,
1070 &hf_cmp_uart_data_framing_err,
1071 &hf_cmp_uart_data_reserved,
1072 &hf_cmp_uart_data_data,
1073 NULL
1076 static int * const asam_cmp_analog_flags[] = {
1077 &hf_cmp_analog_flag_reserved,
1078 &hf_cmp_analog_flag_sample_dt,
1079 NULL
1082 static int * const asam_cmp_ethernet_flags[] = {
1083 &hf_cmp_eth_flag_reserved,
1084 &hf_cmp_eth_flag_fcs_supported,
1085 &hf_cmp_eth_flag_truncated,
1086 &hf_cmp_eth_flag_phy_err,
1087 &hf_cmp_eth_flag_long_err,
1088 &hf_cmp_eth_flag_collision,
1089 &hf_cmp_eth_flag_tx_down,
1090 &hf_cmp_eth_flag_short_err,
1091 &hf_cmp_eth_flag_fcs_err,
1092 NULL
1095 ti_msg_header = proto_tree_add_item(tree, hf_cmp_msg_header, tvb, offset, 8, ENC_BIG_ENDIAN);
1096 asam_cmp_data_msg_header_tree = proto_item_add_subtree(ti_msg_header, ett_asam_cmp_header);
1097 proto_item_append_text(ti_msg_header, " %s", "- Data Message");
1099 uint64_t ns = tvb_get_uint64(tvb, offset, ENC_BIG_ENDIAN);
1100 nstime_t timestamp = { .secs = (time_t)(ns / 1000000000), .nsecs = (int)(ns % 1000000000) };
1102 ti = proto_tree_add_time(asam_cmp_data_msg_header_tree, hf_cmp_msg_timestamp, tvb, offset, 8, &timestamp);
1103 subtree = proto_item_add_subtree(ti, ett_asam_cmp_timestamp);
1104 proto_tree_add_item(subtree, hf_cmp_msg_timestamp_ns, tvb, offset, 8, ENC_BIG_ENDIAN);
1105 offset += 8;
1107 ti = proto_tree_add_item_ret_uint(asam_cmp_data_msg_header_tree, hf_cmp_interface_id, tvb, offset, 4, ENC_BIG_ENDIAN, &interface_id);
1108 add_interface_id_text(ti, interface_id);
1109 offset += 4;
1111 proto_tree_add_bitmask(asam_cmp_data_msg_header_tree, tvb, offset, hf_cmp_msg_common_flags, ett_asam_cmp_common_flags, asam_cmp_common_flags, ENC_BIG_ENDIAN);
1112 offset += 1;
1114 proto_tree_add_item_ret_uint(asam_cmp_data_msg_header_tree, hf_cmp_payload_type, tvb, offset, 1, ENC_NA, &msg_payload_type);
1115 offset += 1;
1117 proto_tree_add_item_ret_uint(asam_cmp_data_msg_header_tree, hf_cmp_msg_payload_length, tvb, offset, 2, ENC_BIG_ENDIAN, &msg_payload_length);
1118 offset += 2;
1120 proto_item_set_end(ti_msg_header, tvb, offset);
1122 ti_msg_payload = proto_tree_add_item(tree, hf_cmp_msg_payload, tvb, offset, msg_payload_length, ENC_BIG_ENDIAN);
1123 asam_cmp_data_msg_payload_tree = proto_item_add_subtree(ti_msg_payload, ett_asam_cmp_header);
1124 proto_item_append_text(ti_msg_payload, " %s", "- Data Message");
1126 switch (msg_payload_type) {
1127 case CMP_DATA_MSG_INVALID: {
1128 col_append_str(pinfo->cinfo, COL_INFO, " (Invalid)");
1129 proto_item_append_text(ti_msg_payload, " %s", "(Invalid)");
1131 if (msg_payload_length > 0) {
1132 tvbuff_t *sub_tvb = tvb_new_subset_length(tvb, offset, msg_payload_length);
1133 call_data_dissector(sub_tvb, pinfo, tree);
1134 offset += (int)msg_payload_length;
1137 proto_item_set_end(ti_msg_payload, tvb, offset);
1139 break;
1142 case CMP_DATA_MSG_CAN: {
1143 static int *const asam_cmp_can_id_field_11bit[] = {
1144 &hf_cmp_can_id_ide,
1145 &hf_cmp_can_id_rtr,
1146 &hf_cmp_can_id_res,
1147 &hf_cmp_can_id_11bit,
1148 NULL
1151 static int *const asam_cmp_can_id_field_11bit_old[] = {
1152 &hf_cmp_can_id_ide,
1153 &hf_cmp_can_id_rtr,
1154 &hf_cmp_can_id_res,
1155 &hf_cmp_can_id_11bit_old,
1156 NULL
1159 static int *const asam_cmp_can_id_field_29bit[] = {
1160 &hf_cmp_can_id_ide,
1161 &hf_cmp_can_id_rtr,
1162 &hf_cmp_can_id_res,
1163 &hf_cmp_can_id_29bit,
1164 NULL
1167 static int *const asam_cmp_can_crc_field[] = {
1168 &hf_cmp_can_crc_crc_support,
1169 &hf_cmp_can_crc_res,
1170 &hf_cmp_can_crc_crc,
1171 NULL
1174 col_append_str(pinfo->cinfo, COL_INFO, " (CAN)");
1175 proto_item_append_text(ti_msg_payload, " %s", "(CAN)");
1177 uint16_t can_flags = tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN);
1178 proto_tree_add_bitmask(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_can_flags, ett_asam_cmp_payload_flags, asam_cmp_can_flags, ENC_BIG_ENDIAN);
1179 offset += 2;
1181 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_can_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
1182 offset += 2;
1184 uint32_t can_id_field = tvb_get_uint32(tvb, offset, ENC_BIG_ENDIAN);
1185 bool can_id_29bit = (can_id_field & CMP_CAN_ID_IDE) == CMP_CAN_ID_IDE;
1186 uint32_t can_id = 0;
1187 if (can_id_29bit) {
1188 proto_tree_add_bitmask_with_flags(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_can_id, ett_asam_cmp_can_id, asam_cmp_can_id_field_29bit, ENC_BIG_ENDIAN, BMT_NO_FALSE);
1189 can_id = can_id_field & (CMP_CAN_ID_29BIT_MASK | CMP_CAN_ID_RTR | CMP_CAN_ID_IDE);
1190 } else {
1191 if (old_11bit_canid_encoding) {
1192 proto_tree_add_bitmask_with_flags(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_can_id, ett_asam_cmp_can_id, asam_cmp_can_id_field_11bit_old, ENC_BIG_ENDIAN, BMT_NO_FALSE);
1193 can_id = can_id_field & (CMP_CAN_ID_RTR | CMP_CAN_ID_IDE | CMP_CAN_ID_11BIT_MASK_OLD);
1194 } else {
1195 proto_tree_add_bitmask_with_flags(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_can_id, ett_asam_cmp_can_id, asam_cmp_can_id_field_11bit, ENC_BIG_ENDIAN, BMT_NO_FALSE);
1196 can_id = (can_id_field & (CMP_CAN_ID_RTR | CMP_CAN_ID_IDE)) + ((can_id_field & CMP_CAN_ID_11BIT_MASK) >> CMP_CAN_ID_11BIT_SHIFT);
1199 offset += 4;
1201 uint64_t tmp64;
1202 proto_tree_add_bitmask_with_flags_ret_uint64(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_can_crc, ett_asam_cmp_can_crc, asam_cmp_can_crc_field, ENC_BIG_ENDIAN, BMT_NO_FALSE, &tmp64);
1203 if ((tmp64 & CMP_CAN_CRC_CRC_SUPP) == 0 && (tmp64 & CMP_CAN_CRC_CRC) != 0) {
1204 proto_tree_add_expert(asam_cmp_data_msg_payload_tree, pinfo, &ei_asam_cmp_unsupported_crc_not_zero, tvb, offset, 4);
1206 offset += 4;
1208 uint32_t err_pos = 0;
1209 proto_tree_add_item_ret_uint(asam_cmp_data_msg_payload_tree, hf_cmp_can_err_pos, tvb, offset, 2, ENC_BIG_ENDIAN, &err_pos);
1210 offset += 2;
1212 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_can_dlc, tvb, offset, 1, ENC_NA);
1213 offset += 1;
1215 proto_tree_add_item_ret_uint(asam_cmp_data_msg_payload_tree, hf_cmp_can_data_len, tvb, offset, 1, ENC_NA, &msg_payload_type_length);
1216 offset += 1;
1218 if (msg_payload_type_length > 0) {
1219 tvbuff_t *sub_tvb = tvb_new_subset_length(tvb, offset, msg_payload_type_length);
1221 if ((can_flags & CMP_CAN_FLAGS_ERRORS) != 0) {
1222 can_id = can_id | CAN_ERR_FLAG;
1225 struct can_info can_info = { .id = can_id, .len = msg_payload_type_length, .fd = CAN_TYPE_CAN_CLASSIC, .bus_id = ht_interface_config_to_bus_id(interface_id) };
1226 if (!socketcan_call_subdissectors(sub_tvb, pinfo, tree, &can_info, heuristic_first)) {
1227 call_data_dissector(sub_tvb, pinfo, tree);
1230 offset += (int)msg_payload_type_length;
1233 proto_item_set_end(ti_msg_payload, tvb, offset);
1234 break;
1237 case CMP_DATA_MSG_CANFD: {
1238 static int * const asam_cmp_canfd_id_field_11bit[] = {
1239 &hf_cmp_canfd_id_ide,
1240 &hf_cmp_canfd_id_rrs,
1241 &hf_cmp_canfd_id_res,
1242 &hf_cmp_canfd_id_11bit,
1243 NULL
1246 static int * const asam_cmp_canfd_id_field_11bit_old[] = {
1247 &hf_cmp_canfd_id_ide,
1248 &hf_cmp_canfd_id_rrs,
1249 &hf_cmp_canfd_id_res,
1250 &hf_cmp_canfd_id_11bit_old,
1251 NULL
1254 static int * const asam_cmp_canfd_id_field_29bit[] = {
1255 &hf_cmp_canfd_id_res,
1256 &hf_cmp_canfd_id_rrs,
1257 &hf_cmp_canfd_id_ide,
1258 &hf_cmp_canfd_id_29bit,
1259 NULL
1262 static int * const asam_cmp_canfd_crc_field_17bit[] = {
1263 &hf_cmp_canfd_crc_crc_support,
1264 &hf_cmp_canfd_crc_sbc_support,
1265 &hf_cmp_canfd_crc_res,
1266 &hf_cmp_canfd_crc_sbc_parity,
1267 &hf_cmp_canfd_crc_sbc,
1268 &hf_cmp_canfd_crc_crc17,
1269 NULL
1272 static int * const asam_cmp_canfd_crc_field_21bit[] = {
1273 &hf_cmp_canfd_crc_crc_support,
1274 &hf_cmp_canfd_crc_sbc_support,
1275 &hf_cmp_canfd_crc_res,
1276 &hf_cmp_canfd_crc_sbc_parity,
1277 &hf_cmp_canfd_crc_sbc,
1278 &hf_cmp_canfd_crc_crc21,
1279 NULL
1282 col_append_str(pinfo->cinfo, COL_INFO, " (CAN FD)");
1283 proto_item_append_text(ti_msg_payload, " %s", "(CAN FD)");
1285 uint16_t canfd_flags = tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN);
1286 proto_tree_add_bitmask(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_canfd_flags, ett_asam_cmp_payload_flags, asam_cmp_canfd_flags, ENC_BIG_ENDIAN);
1287 offset += 2;
1289 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_canfd_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
1290 offset += 2;
1292 uint32_t can_id_field = tvb_get_uint32(tvb, offset, ENC_BIG_ENDIAN);
1293 bool can_id_29bit = (can_id_field & CMP_CANFD_ID_IDE) == CMP_CANFD_ID_IDE;
1294 uint32_t can_id = 0;
1295 if (can_id_29bit) {
1296 proto_tree_add_bitmask_with_flags(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_canfd_id, ett_asam_cmp_can_id, asam_cmp_canfd_id_field_29bit, ENC_BIG_ENDIAN, BMT_NO_FALSE);
1297 can_id = can_id_field & (CMP_CAN_ID_29BIT_MASK | CMP_CANFD_ID_IDE);
1298 } else {
1299 if (old_11bit_canid_encoding) {
1300 proto_tree_add_bitmask_with_flags(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_canfd_id, ett_asam_cmp_can_id, asam_cmp_canfd_id_field_11bit_old, ENC_BIG_ENDIAN, BMT_NO_FALSE);
1301 can_id = can_id_field & (CMP_CANFD_ID_IDE | CMP_CAN_ID_11BIT_MASK_OLD);
1302 } else {
1303 proto_tree_add_bitmask_with_flags(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_canfd_id, ett_asam_cmp_can_id, asam_cmp_canfd_id_field_11bit, ENC_BIG_ENDIAN, BMT_NO_FALSE);
1304 can_id = (can_id_field & CMP_CANFD_ID_IDE) + ((can_id_field & CMP_CAN_ID_11BIT_MASK) >> CMP_CAN_ID_11BIT_SHIFT);
1307 offset += 4;
1309 /* We peek ahead to find out the DLC. 0..10: 17bit CRC, 11..15: 21bit CRC. */
1310 if (tvb_get_uint8(tvb, offset + 6) <= 10) {
1311 proto_tree_add_bitmask_with_flags(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_canfd_crc, ett_asam_cmp_can_crc, asam_cmp_canfd_crc_field_17bit, ENC_BIG_ENDIAN, BMT_NO_FALSE);
1312 } else {
1313 proto_tree_add_bitmask_with_flags(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_canfd_crc, ett_asam_cmp_can_crc, asam_cmp_canfd_crc_field_21bit, ENC_BIG_ENDIAN, BMT_NO_FALSE);
1315 offset += 4;
1317 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_canfd_err_pos, tvb, offset, 2, ENC_BIG_ENDIAN);
1318 offset += 2;
1320 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_canfd_dlc, tvb, offset, 1, ENC_NA);
1321 offset += 1;
1323 proto_tree_add_item_ret_uint(asam_cmp_data_msg_payload_tree, hf_cmp_canfd_data_len, tvb, offset, 1, ENC_NA, &msg_payload_type_length);
1324 offset += 1;
1326 if (msg_payload_type_length > 0) {
1327 tvbuff_t *sub_tvb = tvb_new_subset_length(tvb, offset, msg_payload_type_length);
1329 if ((canfd_flags & CMP_CANFD_FLAGS_ERRORS) != 0) {
1330 can_id = can_id | CAN_ERR_FLAG;
1333 struct can_info can_info = { .id = can_id, .len = msg_payload_type_length, .fd = CAN_TYPE_CAN_FD, .bus_id = ht_interface_config_to_bus_id(interface_id) };
1334 if (!socketcan_call_subdissectors(sub_tvb, pinfo, tree, &can_info, heuristic_first)) {
1335 call_data_dissector(sub_tvb, pinfo, tree);
1338 offset += (int)msg_payload_type_length;
1341 proto_item_set_end(ti_msg_payload, tvb, offset);
1342 break;
1345 case CMP_DATA_MSG_LIN: {
1346 lin_info_t lin_info = {0, 0, 0};
1348 col_append_str(pinfo->cinfo, COL_INFO, " (LIN)");
1349 proto_item_append_text(ti_msg_payload, " %s", "(LIN)");
1351 proto_tree_add_bitmask(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_lin_flags, ett_asam_cmp_payload_flags, asam_cmp_lin_flags, ENC_BIG_ENDIAN);
1352 offset += 2;
1354 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_lin_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
1355 offset += 2;
1357 lin_info.id = tvb_get_uint8(tvb, offset) & CMP_CANFD_PID_ID_MASK;
1358 proto_tree_add_bitmask(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_lin_pid, ett_asam_cmp_lin_pid, asam_cmp_lin_pid, ENC_BIG_ENDIAN);
1359 offset += 1;
1361 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_lin_reserved_2, tvb, offset, 1, ENC_NA);
1362 offset += 1;
1364 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_lin_checksum, tvb, offset, 1, ENC_NA);
1365 offset += 1;
1367 proto_tree_add_item_ret_uint(asam_cmp_data_msg_payload_tree, hf_cmp_lin_data_len, tvb, offset, 1, ENC_NA, &msg_payload_type_length);
1368 offset += 1;
1370 if (msg_payload_type_length > 0) {
1371 tvbuff_t *sub_tvb = tvb_new_subset_length(tvb, offset, msg_payload_type_length);
1373 lin_info.bus_id = ht_interface_config_to_bus_id(interface_id);
1374 lin_info.len = msg_payload_type_length;
1376 if (!dissector_try_uint_new(lin_subdissector_table, lin_info.id | (lin_info.bus_id << 16), sub_tvb, pinfo, tree, false, &lin_info)) {
1377 if (!dissector_try_uint_new(lin_subdissector_table, lin_info.id, sub_tvb, pinfo, tree, false, &lin_info)) {
1378 call_data_dissector(sub_tvb, pinfo, tree);
1382 offset += (int)msg_payload_type_length;
1385 proto_item_set_end(ti_msg_payload, tvb, offset);
1386 break;
1389 case CMP_DATA_MSG_FLEXRAY: {
1390 flexray_info_t fr_info = {0, 0, 0, 0};
1391 uint32_t tmp;
1393 col_append_str(pinfo->cinfo, COL_INFO, " (FlexRay)");
1394 proto_item_append_text(ti_msg_payload, " %s", "(FlexRay)");
1396 uint16_t flags = tvb_get_uint16(tvb, offset, ENC_BIG_ENDIAN);
1397 proto_tree_add_bitmask(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_flexray_flags, ett_asam_cmp_payload_flags, asam_cmp_flexray_flags, ENC_BIG_ENDIAN);
1398 offset += 2;
1400 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_flexray_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
1401 offset += 2;
1403 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_flexray_header_crc, tvb, offset, 2, ENC_BIG_ENDIAN);
1404 offset += 2;
1406 proto_tree_add_item_ret_uint(asam_cmp_data_msg_payload_tree, hf_cmp_flexray_frame_id, tvb, offset, 2, ENC_BIG_ENDIAN, &tmp);
1407 fr_info.id = (uint16_t)tmp;
1408 offset += 2;
1410 proto_tree_add_item_ret_uint(asam_cmp_data_msg_payload_tree, hf_cmp_flexray_cycle, tvb, offset, 1, ENC_NA, &tmp);
1411 fr_info.cc= (uint8_t)tmp;
1412 offset += 1;
1414 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_flexray_frame_crc, tvb, offset, 3, ENC_BIG_ENDIAN);
1415 offset += 3;
1417 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_flexray_reserved_2, tvb, offset, 1, ENC_NA);
1418 offset += 1;
1420 proto_tree_add_item_ret_uint(asam_cmp_data_msg_payload_tree, hf_cmp_flexray_data_len, tvb, offset, 1, ENC_NA, &msg_payload_type_length);
1421 offset += 1;
1423 if (msg_payload_type_length > 0 && (flags & CMP_FLEXRAY_FLAGS_NF) == 0) {
1424 fr_info.bus_id = ht_interface_config_to_bus_id(interface_id);
1425 fr_info.ch = 0; /* Assuming A! Could this be B? */
1427 tvbuff_t *sub_tvb = tvb_new_subset_length(tvb, offset, msg_payload_type_length);
1428 if (!flexray_call_subdissectors(sub_tvb, pinfo, tree, &fr_info, heuristic_first)) {
1429 call_data_dissector(sub_tvb, pinfo, tree);
1432 offset += (int)msg_payload_type_length;
1434 proto_item_set_end(ti_msg_payload, tvb, offset);
1435 break;
1438 case CMP_DATA_MSG_UART_RS_232: {
1439 col_append_str(pinfo->cinfo, COL_INFO, " (UART/RS-232)");
1440 proto_item_append_text(ti_msg_payload, " %s", "(UART/RS-232)");
1442 uint64_t char_len;
1443 proto_tree_add_bitmask_ret_uint64(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_uart_flags, ett_asam_cmp_payload_flags, asam_cmp_uart_flags, ENC_BIG_ENDIAN, &char_len);
1444 char_len = char_len & 0x07;
1445 offset += 2;
1447 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_uart_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
1448 offset += 2;
1450 proto_tree_add_item_ret_uint(asam_cmp_data_msg_payload_tree, hf_cmp_uart_data_len, tvb, offset, 2, ENC_BIG_ENDIAN, &msg_payload_type_length);
1451 offset += 2;
1453 if (msg_payload_type_length > 0) {
1454 for (unsigned i = 0; i < msg_payload_type_length; i++) {
1455 uint8_t *buf = NULL;
1456 ti = proto_tree_add_bitmask(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_uart_data, ett_asam_cmp_uart_data, asam_cmp_uart_data, ENC_BIG_ENDIAN);
1457 if (char_len == CMP_UART_CL_7 || char_len == CMP_UART_CL_8) {
1458 buf = tvb_get_string_enc(pinfo->pool, tvb, offset + 1, 1, ENC_ASCII | ENC_NA);
1460 /* sanitizing buffer */
1461 if (buf[0] > 0x00 && buf[0] < 0x20) {
1462 buf[0] = 0x20;
1463 } else {
1464 proto_item_append_text(ti, ": %s", buf);
1467 offset += 2;
1471 proto_item_set_end(ti_msg_payload, tvb, offset);
1472 break;
1475 case CMP_DATA_MSG_ANALOG: {
1476 col_append_str(pinfo->cinfo, COL_INFO, " (Analog)");
1477 proto_item_append_text(ti_msg_payload, " %s", "(Analog)");
1479 uint64_t flags;
1480 proto_tree_add_bitmask_ret_uint64(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_analog_flags, ett_asam_cmp_payload_flags, asam_cmp_analog_flags, ENC_BIG_ENDIAN, &flags);
1481 offset += 2;
1483 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_analog_reserved, tvb, offset, 1, ENC_NA);
1484 offset += 1;
1486 unsigned analog_unit;
1487 proto_tree_add_item_ret_uint(asam_cmp_data_msg_payload_tree, hf_cmp_analog_unit, tvb, offset, 1, ENC_NA, &analog_unit);
1488 const char *unit_symbol;
1489 unit_symbol = try_val_to_str(analog_unit, analog_units);
1490 offset += 1;
1492 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_analog_sample_interval, tvb, offset, 4, ENC_BIG_ENDIAN);
1493 offset += 4;
1495 float sample_offset;
1496 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_analog_sample_offset, tvb, offset, 4, ENC_BIG_ENDIAN);
1497 sample_offset = tvb_get_ieee_float(tvb, offset, ENC_BIG_ENDIAN);
1498 offset += 4;
1500 float sample_scalar;
1501 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_analog_sample_scalar, tvb, offset, 4, ENC_BIG_ENDIAN);
1502 sample_scalar = tvb_get_ieee_float(tvb, offset, ENC_BIG_ENDIAN);
1503 offset += 4;
1505 int data_left = msg_payload_length - 16;
1506 if (data_left > 0) {
1507 switch (flags & 0x03) {
1508 case 0: /* INT16 */
1509 while (data_left >= 2) {
1510 double sample_value = ((double)tvb_get_int16(tvb, offset, ENC_BIG_ENDIAN) * sample_scalar + sample_offset);
1511 ti = proto_tree_add_double(asam_cmp_data_msg_payload_tree, hf_cmp_analog_sample, tvb, offset, 2, sample_value);
1512 if (unit_symbol == NULL) {
1513 proto_item_append_text(ti, " (%.9f)", sample_value);
1514 } else {
1515 proto_item_append_text(ti, "%s (%.9f%s)", unit_symbol, sample_value, unit_symbol);
1517 PROTO_ITEM_SET_GENERATED(ti);
1519 proto_tree *sample_tree = proto_item_add_subtree(ti, ett_asam_cmp_analog_sample);
1520 ti = proto_tree_add_item(sample_tree, hf_cmp_analog_sample_raw, tvb, offset, 2, ENC_BIG_ENDIAN);
1521 PROTO_ITEM_SET_HIDDEN(ti);
1523 data_left -= 2;
1524 offset += 2;
1526 break;
1527 case 1: /* INT32 */
1528 while (data_left >= 4) {
1529 double sample_value = ((double)tvb_get_int32(tvb, offset, ENC_BIG_ENDIAN) * sample_scalar + sample_offset);
1530 ti = proto_tree_add_double(asam_cmp_data_msg_payload_tree, hf_cmp_analog_sample, tvb, offset, 4, sample_value);
1531 if (unit_symbol == NULL) {
1532 proto_item_append_text(ti, " (%.9f)", sample_value);
1533 } else {
1534 proto_item_append_text(ti, "%s (%.9f%s)", unit_symbol, sample_value, unit_symbol);
1536 PROTO_ITEM_SET_GENERATED(ti);
1538 proto_tree *sample_tree = proto_item_add_subtree(ti, ett_asam_cmp_analog_sample);
1539 ti = proto_tree_add_item(sample_tree, hf_cmp_analog_sample_raw, tvb, offset, 4, ENC_BIG_ENDIAN);
1540 PROTO_ITEM_SET_HIDDEN(ti);
1542 data_left -= 4;
1543 offset += 4;
1545 break;
1549 proto_item_set_end(ti_msg_payload, tvb, offset);
1550 break;
1553 case CMP_DATA_MSG_ETHERNET:
1554 col_append_str(pinfo->cinfo, COL_INFO, " (Ethernet)");
1555 proto_item_append_text(ti_msg_payload, " %s", "(Ethernet)");
1557 proto_tree_add_bitmask(asam_cmp_data_msg_payload_tree, tvb, offset, hf_cmp_eth_flags, ett_asam_cmp_payload_flags, asam_cmp_ethernet_flags, ENC_BIG_ENDIAN);
1558 offset += 2;
1560 proto_tree_add_item(asam_cmp_data_msg_payload_tree, hf_cmp_eth_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
1561 offset += 2;
1563 proto_tree_add_item_ret_uint(asam_cmp_data_msg_payload_tree, hf_cmp_eth_payload_length, tvb, offset, 2, ENC_BIG_ENDIAN, &msg_payload_type_length);
1564 offset += 2;
1566 if (msg_payload_type_length > 0) {
1567 tvbuff_t *sub_tvb = tvb_new_subset_length(tvb, offset, (int)msg_payload_type_length);
1568 call_dissector(eth_handle, sub_tvb, pinfo, root_tree);
1570 offset += (int)msg_payload_type_length;
1572 proto_item_set_end(ti_msg_payload, tvb, offset);
1573 break;
1575 case CMP_DATA_MSG_USER_DEFINED:
1576 col_append_str(pinfo->cinfo, COL_INFO, " (User defined)");
1578 if (msg_payload_length > 0) {
1579 tvbuff_t *sub_tvb = tvb_new_subset_length(tvb, offset, msg_payload_length);
1580 call_data_dissector(sub_tvb, pinfo, tree);
1581 offset += (int)msg_payload_length;
1584 proto_item_set_end(ti_msg_payload, tvb, offset);
1585 break;
1587 default:
1588 if (msg_payload_length > 0) {
1589 offset += (int)msg_payload_length;
1592 proto_item_set_end(ti_msg_payload, tvb, offset);
1593 break;
1596 if ((CMP_MSG_HEADER_LEN + msg_payload_length) < (offset - offset_orig)) {
1597 proto_tree_add_expert(tree, pinfo, &ei_asam_cmp_length_mismatch, tvb, offset_orig + CMP_MSG_HEADER_LEN, msg_payload_length);
1598 proto_item_set_end(ti_msg_payload, tvb, offset);
1601 return CMP_MSG_HEADER_LEN + msg_payload_length;
1604 static int
1605 dissect_asam_cmp_ctrl_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root_tree _U_, proto_tree *tree, unsigned offset_orig) {
1607 proto_item *ti = NULL;
1608 proto_item *ti_msg_header = NULL;
1609 proto_item *ti_msg_payload = NULL;
1610 proto_tree *asam_cmp_ctrl_msg_header_tree = NULL;
1611 proto_tree *asam_cmp_ctrl_msg_payload_tree = NULL;
1612 proto_tree *subtree = NULL;
1613 unsigned asam_cmp_ctrl_msg_payload_type = 0;
1614 unsigned asam_cmp_ctrl_msg_payload_length = 0;
1615 unsigned offset = offset_orig;
1617 static int * const asam_cmp_common_flags[] = {
1618 &hf_cmp_common_flag_reserved_ctrl,
1619 &hf_cmp_common_flag_seg,
1620 &hf_cmp_common_flag_insync,
1621 &hf_cmp_common_flag_recal,
1622 NULL
1625 ti_msg_header = proto_tree_add_item(tree, hf_cmp_msg_header, tvb, offset, 8, ENC_BIG_ENDIAN);
1626 asam_cmp_ctrl_msg_header_tree = proto_item_add_subtree(ti_msg_header, ett_asam_cmp_header);
1627 proto_item_append_text(ti_msg_header, " %s", "- Control Message");
1629 uint64_t ns = tvb_get_uint64(tvb, offset, ENC_BIG_ENDIAN);
1630 nstime_t timestamp = { .secs = (time_t)(ns / 1000000000), .nsecs = (int)(ns % 1000000000) };
1632 ti = proto_tree_add_time(asam_cmp_ctrl_msg_header_tree, hf_cmp_msg_timestamp, tvb, offset, 8, &timestamp);
1634 subtree = proto_item_add_subtree(ti, ett_asam_cmp_timestamp);
1635 proto_tree_add_item(subtree, hf_cmp_msg_timestamp_ns, tvb, offset, 8, ENC_BIG_ENDIAN);
1636 offset += 8;
1638 proto_tree_add_item(asam_cmp_ctrl_msg_header_tree, hf_cmp_ctrl_msg_reserved, tvb, offset, 4, ENC_BIG_ENDIAN);
1639 offset += 4;
1641 proto_tree_add_bitmask(asam_cmp_ctrl_msg_header_tree, tvb, offset, hf_cmp_msg_common_flags, ett_asam_cmp_common_flags, asam_cmp_common_flags, ENC_BIG_ENDIAN);
1642 offset += 1;
1644 proto_tree_add_item_ret_uint(asam_cmp_ctrl_msg_header_tree, hf_cmp_ctrl_msg_payload_type, tvb, offset, 1, ENC_NA, &asam_cmp_ctrl_msg_payload_type);
1645 offset += 1;
1647 proto_tree_add_item_ret_uint(asam_cmp_ctrl_msg_header_tree, hf_cmp_msg_payload_length, tvb, offset, 2, ENC_BIG_ENDIAN, &asam_cmp_ctrl_msg_payload_length);
1648 offset += 2;
1650 proto_item_set_end(ti_msg_header, tvb, offset);
1652 ti_msg_payload = proto_tree_add_item(tree, hf_cmp_msg_payload, tvb, offset, asam_cmp_ctrl_msg_payload_length, ENC_BIG_ENDIAN);
1653 asam_cmp_ctrl_msg_payload_tree = proto_item_add_subtree(ti_msg_payload, ett_asam_cmp_header);
1654 proto_item_append_text(ti_msg_payload, " %s", "- Control Message");
1656 switch (asam_cmp_ctrl_msg_payload_type) {
1657 case CMP_CTRL_MSG_INVALID:
1658 col_append_str(pinfo->cinfo, COL_INFO, " (Invalid/Padding)");
1659 proto_item_append_text(ti_msg_payload, " %s", "(Invalid/Padding)");
1660 proto_item_set_end(ti_msg_payload, tvb, offset + asam_cmp_ctrl_msg_payload_length);
1662 return tvb_reported_length_remaining(tvb, offset_orig);
1664 case CMP_CTRL_MSG_DSR_CTRL_MSG:
1665 col_append_str(pinfo->cinfo, COL_INFO, " (Data Sink Ready)");
1666 proto_item_append_text(ti_msg_payload, " %s", "(Data Sink Ready)");
1668 proto_tree_add_item(asam_cmp_ctrl_msg_payload_tree, hf_cmp_ctrl_msg_device_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1669 offset += 2;
1671 break;
1673 case CMP_CTRL_MSG_USER_EVENT_CTRL_MSG:
1674 col_append_str(pinfo->cinfo, COL_INFO, " (User Event)");
1675 proto_item_append_text(ti_msg_payload, " %s", "(User Event)");
1677 proto_tree_add_item(asam_cmp_ctrl_msg_payload_tree, hf_cmp_ctrl_msg_event_id, tvb, offset, 4, ENC_BIG_ENDIAN);
1678 offset += 4;
1680 break;
1682 case CMP_CTRL_MSG_VENDOR:
1683 col_append_str(pinfo->cinfo, COL_INFO, " (Vendor specific)");
1684 proto_item_append_text(ti_msg_payload, " %s", "(Vendor specific)");
1686 proto_tree_add_item(asam_cmp_ctrl_msg_payload_tree, hf_cmp_ctrl_msg_vendor_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1687 offset += 2;
1688 asam_cmp_ctrl_msg_payload_length -= 2;
1690 proto_tree_add_item(asam_cmp_ctrl_msg_payload_tree, hf_cmp_ctrl_msg_vendor_payload_type, tvb, offset, 2, ENC_BIG_ENDIAN);
1691 offset += 2;
1692 asam_cmp_ctrl_msg_payload_length -= 2;
1694 if ((asam_cmp_ctrl_msg_payload_length) > 0) {
1695 tvbuff_t *sub_tvb = tvb_new_subset_length(tvb, offset, asam_cmp_ctrl_msg_payload_length);
1696 call_data_dissector(sub_tvb, pinfo, tree);
1697 offset += (int)asam_cmp_ctrl_msg_payload_length;
1700 /* we changed the payload length, so lets skip the length check by leaving */
1701 return (offset + asam_cmp_ctrl_msg_payload_length) - offset_orig;
1703 default:
1704 if (asam_cmp_ctrl_msg_payload_length > 0) {
1705 offset += (int)asam_cmp_ctrl_msg_payload_length;
1708 proto_item_set_end(ti_msg_payload, tvb, offset);
1709 break;
1712 if ((CMP_MSG_HEADER_LEN + asam_cmp_ctrl_msg_payload_length) < (offset - offset_orig)) {
1713 proto_tree_add_expert(tree, pinfo, &ei_asam_cmp_length_mismatch, tvb, offset_orig + CMP_MSG_HEADER_LEN, asam_cmp_ctrl_msg_payload_length);
1714 proto_item_set_end(ti_msg_payload, tvb, offset);
1717 return CMP_MSG_HEADER_LEN + asam_cmp_ctrl_msg_payload_length;
1720 static int
1721 dissect_asam_cmp_status_interface_support_mask(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, unsigned offset_orig, uint8_t interface_type) {
1722 unsigned offset = offset_orig;
1723 uint64_t temp = 0;
1725 static int *const can_feature_support[] = {
1726 &hf_cmp_iface_feat_can_srr_dom,
1727 &hf_cmp_iface_feat_can_r0,
1728 &hf_cmp_iface_feat_can_eof_err,
1729 &hf_cmp_iface_feat_can_crc_del_err,
1730 &hf_cmp_iface_feat_can_ack_del_err,
1731 &hf_cmp_iface_feat_can_act_ack,
1732 &hf_cmp_iface_feat_can_pas_ack,
1733 NULL
1736 static int *const canfd_feature_support[] = {
1737 &hf_cmp_iface_feat_canfd_esi_dom,
1738 &hf_cmp_iface_feat_canfd_brs_dom,
1739 &hf_cmp_iface_feat_canfd_srr_dom,
1740 &hf_cmp_iface_feat_canfd_rsvd,
1741 &hf_cmp_iface_feat_canfd_eof_err,
1742 &hf_cmp_iface_feat_canfd_crc_del_err,
1743 &hf_cmp_iface_feat_canfd_ack_del_err,
1744 &hf_cmp_iface_feat_canfd_act_ack,
1745 &hf_cmp_iface_feat_canfd_pas_ack,
1746 NULL
1749 static int *const lin_feature_support[] = {
1750 &hf_cmp_iface_feat_lin_wup,
1751 &hf_cmp_iface_feat_lin_long_dom_err,
1752 &hf_cmp_iface_feat_lin_short_dom_err,
1753 &hf_cmp_iface_feat_lin_framing_err,
1754 &hf_cmp_iface_feat_lin_sync_err,
1755 NULL
1758 static int *const eth_feature_support[] = {
1759 &hf_cmp_iface_feat_eth_trunc,
1760 &hf_cmp_iface_feat_eth_phy_err,
1761 &hf_cmp_iface_feat_eth_too_long,
1762 NULL
1765 switch (interface_type) {
1766 case CMP_DATA_MSG_CAN:
1767 proto_tree_add_bitmask_ret_uint64(tree, tvb, offset, hf_cmp_iface_feat, ett_asam_cmp_status_feature_support, can_feature_support, ENC_BIG_ENDIAN, &temp);
1768 break;
1770 case CMP_DATA_MSG_CANFD:
1771 proto_tree_add_bitmask_ret_uint64(tree, tvb, offset, hf_cmp_iface_feat, ett_asam_cmp_status_feature_support, canfd_feature_support, ENC_BIG_ENDIAN, &temp);
1772 break;
1774 case CMP_DATA_MSG_LIN:
1775 proto_tree_add_bitmask_ret_uint64(tree, tvb, offset, hf_cmp_iface_feat, ett_asam_cmp_status_feature_support, lin_feature_support, ENC_BIG_ENDIAN, &temp);
1776 break;
1778 case CMP_DATA_MSG_ETHERNET:
1779 proto_tree_add_bitmask_ret_uint64(tree, tvb, offset, hf_cmp_iface_feat, ett_asam_cmp_status_feature_support, eth_feature_support, ENC_BIG_ENDIAN, &temp);
1780 break;
1782 default:
1783 proto_tree_add_item(tree, hf_cmp_iface_feat, tvb, offset, 4, ENC_BIG_ENDIAN);
1786 offset += 4;
1788 return offset - offset_orig;
1791 static int
1792 dissect_asam_cmp_status_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *root_tree _U_, proto_tree *tree, unsigned offset_orig) {
1793 proto_item *ti = NULL;
1794 proto_item *ti_msg_header = NULL;
1795 proto_item *ti_msg_payload = NULL;
1796 proto_item *ti_interface = NULL;
1797 proto_item *ti_stream_ids = NULL;
1798 proto_tree *asam_cmp_status_msg_header_tree = NULL;
1799 proto_tree *asam_cmp_status_msg_payload_tree = NULL;
1800 proto_tree *subtree = NULL;
1801 proto_tree *stream_ids_subtree = NULL;
1802 unsigned offset = offset_orig;
1804 unsigned asam_cmp_status_msg_payload_type = 0;
1805 unsigned asam_cmp_status_msg_payload_length = 0;
1806 unsigned asam_cmp_status_msg_cm_dev_desc_length = 0;
1807 unsigned asam_cmp_status_msg_cm_sn_length = 0;
1808 unsigned asam_cmp_status_msg_cm_hw_ver_length = 0;
1809 unsigned asam_cmp_status_msg_cm_sw_ver_length = 0;
1810 unsigned asam_cmp_status_msg_vendor_data_length = 0;
1811 unsigned asam_cmp_status_msg_iface_stream_id_count = 0;
1812 uint64_t uptime = 0;
1813 const char *descr = NULL;
1815 static int * const asam_cmp_common_flags[] = {
1816 &hf_cmp_common_flag_reserved_ctrl,
1817 &hf_cmp_common_flag_seg,
1818 &hf_cmp_common_flag_insync,
1819 &hf_cmp_common_flag_recal,
1820 NULL
1823 static int * const asam_cmp_status_cm_flags[] = {
1824 &hf_cmp_gptp_flags_reserved,
1825 &hf_cmp_gptp_flags_freq_traceable,
1826 &hf_cmp_gptp_flags_time_traceable,
1827 &hf_cmp_gptp_flags_ptp_timescale,
1828 &hf_cmp_gptp_flags_cur_utco_valid,
1829 &hf_cmp_gptp_flags_leap59,
1830 &hf_cmp_gptp_flags_leap61,
1831 NULL
1834 static int * const asam_cmp_status_timeloss_error_flags[] = {
1835 &hf_cmp_timeloss_error_flags_reserved,
1836 &hf_cmp_timeloss_error_flags_delta,
1837 &hf_cmp_timeloss_error_flags_insync,
1838 &hf_cmp_timeloss_error_flags_ts,
1839 NULL
1842 ti_msg_header = proto_tree_add_item(tree, hf_cmp_msg_header, tvb, offset, 16, ENC_BIG_ENDIAN);
1843 asam_cmp_status_msg_header_tree = proto_item_add_subtree(ti_msg_header, ett_asam_cmp_header);
1844 proto_item_append_text(ti_msg_header, " %s", "- Status Message");
1846 uint64_t ns = tvb_get_uint64(tvb, offset, ENC_BIG_ENDIAN);
1847 nstime_t timestamp = { .secs = (time_t)(ns / 1000000000), .nsecs = (int)(ns % 1000000000) };
1849 ti = proto_tree_add_time(asam_cmp_status_msg_header_tree, hf_cmp_msg_timestamp, tvb, offset, 8, &timestamp);
1850 subtree = proto_item_add_subtree(ti, ett_asam_cmp_timestamp);
1851 proto_tree_add_item(subtree, hf_cmp_msg_timestamp_ns, tvb, offset, 8, ENC_BIG_ENDIAN);
1852 offset += 8;
1854 proto_tree_add_item(asam_cmp_status_msg_header_tree, hf_cmp_msg_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
1855 offset += 2;
1857 proto_tree_add_item(asam_cmp_status_msg_header_tree, hf_cmp_msg_vendor_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1858 offset += 2;
1860 proto_tree_add_bitmask(asam_cmp_status_msg_header_tree, tvb, offset, hf_cmp_msg_common_flags, ett_asam_cmp_common_flags, asam_cmp_common_flags, ENC_BIG_ENDIAN);
1861 offset += 1;
1863 proto_tree_add_item_ret_uint(asam_cmp_status_msg_header_tree, hf_cmp_status_msg_payload_type, tvb, offset, 1, ENC_NA, &asam_cmp_status_msg_payload_type);
1864 offset += 1;
1866 proto_tree_add_item_ret_uint(asam_cmp_status_msg_header_tree, hf_cmp_msg_payload_length, tvb, offset, 2, ENC_BIG_ENDIAN, &asam_cmp_status_msg_payload_length);
1867 offset += 2;
1869 proto_item_set_end(ti_msg_header, tvb, offset);
1871 ti_msg_payload = proto_tree_add_item(tree, hf_cmp_msg_payload, tvb, offset, asam_cmp_status_msg_payload_length, ENC_BIG_ENDIAN);
1872 asam_cmp_status_msg_payload_tree = proto_item_add_subtree(ti_msg_payload, ett_asam_cmp_header);
1873 proto_item_append_text(ti_msg_payload, " %s", "- Status Message");
1875 switch (asam_cmp_status_msg_payload_type) {
1876 case CMP_STATUS_MSG_INVALID:
1877 col_append_str(pinfo->cinfo, COL_INFO, " (Invalid/Padding)");
1878 proto_item_append_text(ti_msg_payload, " %s", "(Invalid/Padding)");
1879 proto_item_set_end(ti_msg_payload, tvb, offset + asam_cmp_status_msg_payload_length);
1881 return tvb_reported_length_remaining(tvb, offset_orig);
1883 case CMP_STATUS_MSG_CM_STAT_MSG:
1884 col_append_str(pinfo->cinfo, COL_INFO, " (CM)");
1885 proto_item_append_text(ti_msg_payload, " %s", "(CM)");
1887 ti = proto_tree_add_item_ret_uint64(asam_cmp_status_msg_payload_tree, hf_cmp_status_msg_cm_uptime_ns, tvb, offset, 8, ENC_BIG_ENDIAN, &uptime);
1889 subtree = proto_item_add_subtree(ti, ett_asam_cmp_status_cm_uptime);
1890 proto_tree_add_uint64(subtree, hf_cmp_status_msg_cm_uptime_s, tvb, offset, 8, uptime / 1000000000);
1891 offset += 8;
1893 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_msg_gm_identity, tvb, offset, 8, ENC_BIG_ENDIAN);
1894 offset += 8;
1896 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_msg_gm_clock_quality, tvb, offset, 4, ENC_BIG_ENDIAN);
1897 offset += 4;
1899 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_msg_current_utc_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
1900 offset += 2;
1902 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_msg_time_source, tvb, offset, 1, ENC_NA);
1903 offset += 1;
1905 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_msg_domain_num, tvb, offset, 1, ENC_NA);
1906 offset += 1;
1908 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_msg_res, tvb, offset, 1, ENC_NA);
1909 offset += 1;
1911 proto_tree_add_bitmask(asam_cmp_status_msg_payload_tree, tvb, offset, hf_cmp_gptp_flags, ett_asam_cmp_status_cm_flags, asam_cmp_status_cm_flags, ENC_BIG_ENDIAN);
1912 offset += 1;
1914 proto_tree_add_item_ret_uint(asam_cmp_status_msg_payload_tree, hf_cmp_status_dev_desc_length, tvb, offset, 2, ENC_BIG_ENDIAN, &asam_cmp_status_msg_cm_dev_desc_length);
1915 offset += 2;
1917 if ((asam_cmp_status_msg_cm_dev_desc_length) > 0) {
1918 asam_cmp_status_msg_cm_dev_desc_length += (asam_cmp_status_msg_cm_dev_desc_length % 2); /* padding to 16bit */
1919 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_dev_desc, tvb, offset, asam_cmp_status_msg_cm_dev_desc_length, ENC_UTF_8 | ENC_NA);
1920 offset += (int)asam_cmp_status_msg_cm_dev_desc_length;
1923 proto_tree_add_item_ret_uint(asam_cmp_status_msg_payload_tree, hf_cmp_status_sn_length, tvb, offset, 2, ENC_BIG_ENDIAN, &asam_cmp_status_msg_cm_sn_length);
1924 offset += 2;
1926 if ((asam_cmp_status_msg_cm_sn_length) > 0) {
1927 asam_cmp_status_msg_cm_sn_length += (asam_cmp_status_msg_cm_sn_length % 2); /* padding to 16bit */
1928 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_sn, tvb, offset, asam_cmp_status_msg_cm_sn_length, ENC_UTF_8 | ENC_NA);
1929 offset += (int)asam_cmp_status_msg_cm_sn_length;
1932 proto_tree_add_item_ret_uint(asam_cmp_status_msg_payload_tree, hf_cmp_status_hw_ver_length, tvb, offset, 2, ENC_BIG_ENDIAN, &asam_cmp_status_msg_cm_hw_ver_length);
1933 offset += 2;
1935 if ((asam_cmp_status_msg_cm_hw_ver_length) > 0) {
1936 asam_cmp_status_msg_cm_hw_ver_length += (asam_cmp_status_msg_cm_hw_ver_length % 2); /* padding to 16bit */
1937 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_hw_ver, tvb, offset, asam_cmp_status_msg_cm_hw_ver_length, ENC_UTF_8 | ENC_NA);
1938 offset += (int)asam_cmp_status_msg_cm_hw_ver_length;
1941 proto_tree_add_item_ret_uint(asam_cmp_status_msg_payload_tree, hf_cmp_status_sw_ver_length, tvb, offset, 2, ENC_BIG_ENDIAN, &asam_cmp_status_msg_cm_sw_ver_length);
1942 offset += 2;
1944 if ((asam_cmp_status_msg_cm_sw_ver_length) > 0) {
1945 asam_cmp_status_msg_cm_sw_ver_length += (asam_cmp_status_msg_cm_sw_ver_length % 2); /* padding to 16bit */
1946 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_sw_ver, tvb, offset, asam_cmp_status_msg_cm_sw_ver_length, ENC_UTF_8 | ENC_NA);
1947 offset += (int)asam_cmp_status_msg_cm_sw_ver_length;
1950 proto_tree_add_item_ret_uint(asam_cmp_status_msg_payload_tree, hf_cmp_status_vendor_data_length, tvb, offset, 2, ENC_BIG_ENDIAN, &asam_cmp_status_msg_vendor_data_length);
1951 offset += 2;
1953 if ((asam_cmp_status_msg_vendor_data_length) > 0) {
1954 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_vendor_data, tvb, offset, asam_cmp_status_msg_vendor_data_length, ENC_NA);
1955 offset += (int)asam_cmp_status_msg_vendor_data_length;
1957 break;
1959 case CMP_STATUS_MSG_IF_STAT_MSG:
1960 col_append_str(pinfo->cinfo, COL_INFO, " (Interface)");
1961 proto_item_append_text(ti_msg_payload, " %s", "(Interface)");
1963 /* each entry is 40 bytes, header is 16 bytes */
1964 while (tvb_reported_length_remaining(tvb, offset) >= 40 && offset - offset_orig + 40 <= 16 + asam_cmp_status_msg_payload_length) {
1965 uint32_t ifaceid;
1966 uint32_t ifacetype;
1968 ti_interface = proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_iface_interface, tvb, offset, 34, ENC_NA);
1969 subtree = proto_item_add_subtree(ti_interface, ett_asam_cmp_status_interface);
1971 ti = proto_tree_add_item_ret_uint(subtree, hf_cmp_iface_iface_id, tvb, offset, 4, ENC_BIG_ENDIAN, &ifaceid);
1972 descr = ht_interface_config_to_string(ifaceid);
1973 if (descr != NULL) {
1974 proto_item_append_text(ti, " (%s)", descr);
1976 offset += 4;
1978 proto_tree_add_item(subtree, hf_cmp_iface_msg_total_rx, tvb, offset, 4, ENC_BIG_ENDIAN);
1979 offset += 4;
1981 proto_tree_add_item(subtree, hf_cmp_iface_msg_total_tx, tvb, offset, 4, ENC_BIG_ENDIAN);
1982 offset += 4;
1984 proto_tree_add_item(subtree, hf_cmp_iface_msg_dropped_rx, tvb, offset, 4, ENC_BIG_ENDIAN);
1985 offset += 4;
1987 proto_tree_add_item(subtree, hf_cmp_iface_msg_dropped_tx, tvb, offset, 4, ENC_BIG_ENDIAN);
1988 offset += 4;
1990 proto_tree_add_item(subtree, hf_cmp_iface_errs_total_rx, tvb, offset, 4, ENC_BIG_ENDIAN);
1991 offset += 4;
1993 proto_tree_add_item(subtree, hf_cmp_iface_errs_total_tx, tvb, offset, 4, ENC_BIG_ENDIAN);
1994 offset += 4;
1996 proto_tree_add_item_ret_uint(subtree, hf_cmp_iface_iface_type, tvb, offset, 1, ENC_NA, &ifacetype);
1997 offset += 1;
1999 if (descr != NULL) {
2000 proto_item_append_text(ti_interface, " %s, Type: %s", descr, val_to_str(ifacetype, data_msg_type_names, "Unknown (0x%x)"));
2001 } else {
2002 proto_item_append_text(ti_interface, " 0x%x, Type: %s", ifaceid, val_to_str(ifacetype, data_msg_type_names, "Unknown (0x%x)"));
2005 proto_tree_add_item(subtree, hf_cmp_iface_iface_status, tvb, offset, 1, ENC_NA);
2006 offset += 1;
2008 proto_tree_add_item(subtree, hf_cmp_iface_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
2009 offset += 2;
2011 offset += dissect_asam_cmp_status_interface_support_mask(tvb, pinfo, subtree, offset, (uint8_t)ifacetype);
2013 proto_tree_add_item_ret_uint(subtree, hf_cmp_iface_stream_id_cnt, tvb, offset, 2, ENC_BIG_ENDIAN, &asam_cmp_status_msg_iface_stream_id_count);
2014 offset += 2;
2016 if ((asam_cmp_status_msg_iface_stream_id_count) > 0) {
2017 ti_stream_ids = proto_tree_add_item(subtree, hf_cmp_iface_stream_ids, tvb, offset, asam_cmp_status_msg_iface_stream_id_count, ENC_NA);
2018 stream_ids_subtree = proto_item_add_subtree(ti_stream_ids, ett_asam_cmp_status_stream_ids);
2020 for (unsigned i = 0; i < asam_cmp_status_msg_iface_stream_id_count; i++) {
2021 proto_tree_add_item(stream_ids_subtree, hf_cmp_iface_stream_id, tvb, offset, 1, ENC_NA);
2022 offset += 1;
2024 offset += (asam_cmp_status_msg_iface_stream_id_count % 2); /* padding to 16bit */
2027 proto_tree_add_item_ret_uint(subtree, hf_cmp_iface_vendor_data_len, tvb, offset, 2, ENC_BIG_ENDIAN, &asam_cmp_status_msg_vendor_data_length);
2028 offset += 2;
2030 if ((asam_cmp_status_msg_vendor_data_length) > 0) {
2031 proto_tree_add_item(subtree, hf_cmp_iface_vendor_data, tvb, offset, asam_cmp_status_msg_vendor_data_length, ENC_NA);
2032 offset += (int)asam_cmp_status_msg_vendor_data_length;
2035 proto_item_set_end(ti_interface, tvb, offset);
2037 break;
2039 case CMP_STATUS_MSG_CONF_STAT_MSG:
2040 col_append_str(pinfo->cinfo, COL_INFO, " (Configuration)");
2041 proto_item_append_text(ti_msg_payload, " %s", "(Configuration)");
2043 if ((asam_cmp_status_msg_payload_length) > 0) {
2044 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_msg_config, tvb, offset, asam_cmp_status_msg_payload_length, ENC_NA);
2045 offset += (int)asam_cmp_status_msg_payload_length;
2047 break;
2049 case CMP_STATUS_MSG_DLE_STAT_MSG:
2050 col_append_str(pinfo->cinfo, COL_INFO, " (Data Lost Event)");
2051 proto_item_append_text(ti_msg_payload, " %s", "(Data Lost Event)");
2053 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_dataloss_data_sink_port, tvb, offset, 2, ENC_BIG_ENDIAN);
2054 offset += 2;
2056 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_dataloss_device_id, tvb, offset, 2, ENC_BIG_ENDIAN);
2057 offset += 2;
2059 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_dataloss_reserved, tvb, offset, 1, ENC_NA);
2060 offset += 1;
2062 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_dataloss_stream_id, tvb, offset, 1, ENC_NA);
2063 offset += 1;
2065 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_dataloss_last_ssq_value, tvb, offset, 2, ENC_BIG_ENDIAN);
2066 offset += 2;
2068 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_dataloss_current_ssq_value, tvb, offset, 2, ENC_BIG_ENDIAN);
2069 offset += 2;
2070 break;
2072 case CMP_STATUS_MSG_TSLE_STAT_MSG:
2073 col_append_str(pinfo->cinfo, COL_INFO, " (Time Sync Lost Event)");
2074 proto_item_append_text(ti_msg_payload, " %s", "(Time Sync Lost Event)");
2076 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_timeloss_port_nr, tvb, offset, 2, ENC_BIG_ENDIAN);
2077 offset += 2;
2079 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_timeloss_device_id, tvb, offset, 2, ENC_BIG_ENDIAN);
2080 offset += 2;
2082 proto_tree_add_bitmask(asam_cmp_status_msg_payload_tree, tvb, offset, hf_cmp_timeloss_error_flags, ett_asam_cmp_status_timeloss_flags, asam_cmp_status_timeloss_error_flags, ENC_BIG_ENDIAN);
2083 offset += 1;
2084 break;
2086 case CMP_STATUS_MSG_VENDOR_STAT_MSG:
2087 col_append_str(pinfo->cinfo, COL_INFO, " (Vendor specific)");
2088 proto_item_append_text(ti_msg_payload, " %s", "(Vendor specific)");
2090 if ((asam_cmp_status_msg_payload_length) > 0) {
2091 proto_tree_add_item(asam_cmp_status_msg_payload_tree, hf_cmp_status_msg_vendor_specific, tvb, offset, asam_cmp_status_msg_payload_length, ENC_NA);
2092 offset += (int)asam_cmp_status_msg_payload_length;
2094 break;
2096 default:
2097 if (asam_cmp_status_msg_payload_length > 0) {
2098 offset += (int)asam_cmp_status_msg_payload_length;
2101 proto_item_set_end(ti_msg_payload, tvb, offset);
2102 break;
2105 if ((CMP_MSG_HEADER_LEN + asam_cmp_status_msg_payload_length) < (offset - offset_orig)) {
2106 proto_tree_add_expert(tree, pinfo, &ei_asam_cmp_length_mismatch, tvb, offset_orig + CMP_MSG_HEADER_LEN, asam_cmp_status_msg_payload_length);
2107 proto_item_set_end(ti_msg_payload, tvb, offset);
2110 return CMP_MSG_HEADER_LEN + asam_cmp_status_msg_payload_length;
2113 static int
2114 dissect_asam_cmp_vendor_msg(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *root_tree _U_, proto_tree *tree, unsigned offset_orig) {
2115 proto_item *ti = NULL;
2116 proto_item *ti_msg_header = NULL;
2117 proto_item *ti_msg_payload = NULL;
2118 proto_tree *asam_cmp_vendor_msg_header_tree = NULL;
2119 proto_tree *subtree = NULL;
2120 unsigned asam_cmp_vendor_msg_payload_type = 0;
2121 unsigned asam_cmp_vendor_msg_payload_length = 0;
2122 unsigned offset = offset_orig;
2124 static int * const asam_cmp_common_flags[] = {
2125 &hf_cmp_common_flag_recal,
2126 &hf_cmp_common_flag_insync,
2127 &hf_cmp_common_flag_seg,
2128 &hf_cmp_common_flag_reserved_ctrl,
2129 NULL
2132 ti_msg_header = proto_tree_add_item(tree, hf_cmp_msg_header, tvb, offset, 8, ENC_BIG_ENDIAN);
2133 asam_cmp_vendor_msg_header_tree = proto_item_add_subtree(ti_msg_header, ett_asam_cmp_header);
2134 proto_item_append_text(ti_msg_header, " %s", "- Vendor-Defined Message");
2136 uint64_t ns = tvb_get_uint64(tvb, offset, ENC_BIG_ENDIAN);
2137 nstime_t timestamp = { .secs = (time_t)(ns / 1000000000), .nsecs = (int)(ns % 1000000000) };
2139 ti = proto_tree_add_time(asam_cmp_vendor_msg_header_tree, hf_cmp_msg_timestamp, tvb, offset, 8, &timestamp);
2141 subtree = proto_item_add_subtree(ti, ett_asam_cmp_timestamp);
2142 proto_tree_add_item(subtree, hf_cmp_msg_timestamp_ns, tvb, offset, 8, ENC_BIG_ENDIAN);
2143 offset += 8;
2145 proto_tree_add_item(asam_cmp_vendor_msg_header_tree, hf_cmp_msg_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
2146 offset += 2;
2148 proto_tree_add_item(asam_cmp_vendor_msg_header_tree, hf_cmp_msg_vendor_id, tvb, offset, 2, ENC_BIG_ENDIAN);
2149 offset += 2;
2151 proto_tree_add_bitmask(asam_cmp_vendor_msg_header_tree, tvb, offset, hf_cmp_msg_common_flags, ett_asam_cmp_common_flags, asam_cmp_common_flags, ENC_BIG_ENDIAN);
2152 offset += 1;
2154 proto_tree_add_item_ret_uint(asam_cmp_vendor_msg_header_tree, hf_cmp_vendor_msg_payload_type, tvb, offset, 1, ENC_NA, &asam_cmp_vendor_msg_payload_type);
2155 offset += 1;
2157 proto_tree_add_item_ret_uint(asam_cmp_vendor_msg_header_tree, hf_cmp_msg_payload_length, tvb, offset, 2, ENC_BIG_ENDIAN, &asam_cmp_vendor_msg_payload_length);
2158 offset += 2;
2160 proto_item_set_end(ti_msg_header, tvb, offset);
2162 ti_msg_payload = proto_tree_add_item(tree, hf_cmp_msg_payload, tvb, offset, asam_cmp_vendor_msg_payload_length, ENC_BIG_ENDIAN);
2163 proto_item_append_text(ti_msg_payload, " %s", "- Vendor-Defined Message");
2165 if ((asam_cmp_vendor_msg_payload_length) > 0) {
2166 offset += (int)asam_cmp_vendor_msg_payload_length;
2167 proto_item_set_end(ti_msg_payload, tvb, offset);
2170 return CMP_MSG_HEADER_LEN + asam_cmp_vendor_msg_payload_length;
2173 static int
2174 dissect_asam_cmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) {
2175 proto_item *ti_root = NULL;
2176 proto_item *ti_header = NULL;
2177 proto_item *ti = NULL;
2178 proto_tree *asam_cmp_tree = NULL;
2179 proto_tree *asam_cmp_header_tree = NULL;
2180 unsigned msg_type = 0;
2181 unsigned device_id = 0;
2182 unsigned offset = 0;
2184 col_clear(pinfo->cinfo, COL_INFO);
2185 col_set_str(pinfo->cinfo, COL_INFO, "ASAM-CMP");
2186 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ASAM-CMP");
2188 ti_root = proto_tree_add_item(tree, proto_asam_cmp, tvb, 0, -1, ENC_NA);
2189 asam_cmp_tree = proto_item_add_subtree(ti_root, ett_asam_cmp);
2191 ti_header = proto_tree_add_item(asam_cmp_tree, hf_cmp_header, tvb, offset, CMP_HEADER_LEN, ENC_BIG_ENDIAN);
2192 asam_cmp_header_tree = proto_item_add_subtree(ti_header, ett_asam_cmp_header);
2194 proto_tree_add_item(asam_cmp_header_tree, hf_cmp_version, tvb, offset, 1, ENC_NA);
2195 offset += 1;
2197 proto_tree_add_item(asam_cmp_header_tree, hf_cmp_header_res, tvb, offset, 1, ENC_NA);
2198 offset += 1;
2200 ti = proto_tree_add_item_ret_uint(asam_cmp_header_tree, hf_cmp_device_id, tvb, offset, 2, ENC_BIG_ENDIAN, &device_id);
2201 add_device_id_text(ti, device_id);
2202 offset += 2;
2204 proto_tree_add_item_ret_uint(asam_cmp_header_tree, hf_cmp_msg_type, tvb, offset, 1, ENC_NA, &msg_type);
2205 offset += 1;
2207 proto_tree_add_item(asam_cmp_header_tree, hf_cmp_stream_id, tvb, offset, 1, ENC_NA);
2208 offset += 1;
2210 proto_tree_add_item(asam_cmp_header_tree, hf_cmp_stream_seq_ctr, tvb, offset, 2, ENC_BIG_ENDIAN);
2211 offset += 2;
2213 proto_item_append_text(ti_root, ", Device: 0x%04x, Type: %s", device_id, val_to_str(msg_type, msg_type_names, "Unknown (0x%x)"));
2215 while (tvb_reported_length_remaining(tvb, offset) >= 16) {
2216 switch (msg_type) {
2217 case CMP_MSG_TYPE_CTRL_MSG:
2218 col_append_str(pinfo->cinfo, COL_INFO, ", Control Msg");
2219 offset += dissect_asam_cmp_ctrl_msg(tvb, pinfo, tree, asam_cmp_tree, offset);
2220 break;
2221 case CMP_MSG_TYPE_STATUS_MSG:
2222 col_append_str(pinfo->cinfo, COL_INFO, ", Status Msg");
2223 offset += dissect_asam_cmp_status_msg(tvb, pinfo, tree, asam_cmp_tree, offset);
2224 break;
2225 case CMP_MSG_TYPE_VENDOR:
2226 col_append_str(pinfo->cinfo, COL_INFO, ", Vendor Msg");
2227 offset += dissect_asam_cmp_vendor_msg(tvb, pinfo, tree, asam_cmp_tree, offset);
2228 break;
2229 case CMP_MSG_TYPE_DATA_MSG:
2230 col_append_str(pinfo->cinfo, COL_INFO, ", Data Msg");
2231 offset += dissect_asam_cmp_data_msg(tvb, pinfo, tree, asam_cmp_tree, offset);
2232 break;
2233 default:
2234 proto_item_set_end(ti_root, tvb, offset);
2235 proto_item_set_end(ti_header, tvb, offset);
2236 return offset;
2240 proto_item_set_end(ti_root, tvb, offset);
2241 proto_item_set_end(ti_header, tvb, offset);
2242 return offset;
2245 void
2246 proto_register_asam_cmp(void) {
2247 module_t *asam_cmp_module = NULL;
2248 expert_module_t *expert_module_asam_cmp;
2249 uat_t *asam_cmp_deviceid_uat = NULL;
2250 uat_t *asam_cmp_interfaceid_uat = NULL;
2252 static hf_register_info hf[] = {
2253 /* Header */
2254 { &hf_cmp_header, { "ASAM CMP Header", "asam-cmp.hdr", FT_PROTOCOL, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2256 { &hf_cmp_version, { "Version", "asam-cmp.hdr.version", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2257 { &hf_cmp_header_res, { "Reserved", "asam-cmp.hdr.res", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2258 { &hf_cmp_device_id, { "Device ID", "asam-cmp.hdr.device_id", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2259 { &hf_cmp_msg_type, { "Message Type", "asam-cmp.hdr.msg_type", FT_UINT8, BASE_HEX, VALS(msg_type_names), 0x0, NULL, HFILL }},
2260 { &hf_cmp_stream_id, { "Stream ID", "asam-cmp.hdr.stream_id", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2261 { &hf_cmp_stream_seq_ctr, { "Stream Sequence Counter", "asam-cmp.hdr.stream_seq_cnt", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2263 /* Message Header*/
2264 { &hf_cmp_msg_header, { "ASAM CMP Msg Header", "asam-cmp.msg_hdr", FT_PROTOCOL, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2266 { &hf_cmp_common_flag_recal, { "Timestamp recalculated", "asam-cmp.msg_hdr.recalculated", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
2267 { &hf_cmp_common_flag_insync, { "Synchronized", "asam-cmp.msg_hdr.sync", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL } },
2268 { &hf_cmp_common_flag_seg, { "Segmentation", "asam-cmp.msg_hdr.seg", FT_UINT8, BASE_HEX, VALS(seg_flag_names), 0x0C, NULL, HFILL } },
2269 { &hf_cmp_common_flag_dir_on_if, { "Direction", "asam-cmp.msg_hdr.dir_on_if", FT_BOOLEAN, 8, TFS(&interface_direction), 0x10, NULL, HFILL } },
2270 { &hf_cmp_common_flag_overflow, { "Overflow", "asam-cmp.msg_hdr.overflow", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL } },
2271 { &hf_cmp_common_flag_err_in_payload, { "Error in payload", "asam-cmp.msg_hdr.error_in_payload", FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL } },
2272 { &hf_cmp_common_flag_reserved, { "Reserved", "asam-cmp.msg_hdr.res", FT_UINT8, BASE_HEX, NULL, 0x80, NULL, HFILL } },
2273 { &hf_cmp_common_flag_reserved_ctrl, { "Reserved", "asam-cmp.msg_hdr.res2", FT_UINT8, BASE_HEX, NULL, 0xF0, NULL, HFILL } },
2275 { &hf_cmp_msg_timestamp, { "Timestamp", "asam-cmp.msg_hdr.timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL }},
2276 { &hf_cmp_msg_timestamp_ns, { "Timestamp (ns)", "asam-cmp.msg_hdr.timestamp_ns", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2277 { &hf_cmp_msg_reserved, { "Reserved", "asam-cmp.msg_hdr.reserved", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2278 { &hf_cmp_msg_common_flags, { "Common Flags", "asam-cmp.msg_hdr.common_flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2279 { &hf_cmp_msg_vendor_id, { "Vendor ID", "asam-cmp.msg_hdr.vendor_id", FT_UINT16, BASE_HEX, VALS(vendor_ids), 0x0, NULL, HFILL }},
2280 { &hf_cmp_msg_payload_length, { "Payload Length", "asam-cmp.msg_hdr.payload_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2281 { &hf_cmp_msg_payload, { "Payload", "asam-cmp.msg_payload", FT_PROTOCOL, BASE_NONE, NULL, 0x0, NULL, HFILL }},
2283 /* Data Message Header */
2284 { &hf_cmp_interface_id, { "Interface ID", "asam-cmp.msg_hdr.interface_id", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2285 { &hf_cmp_payload_type, { "Payload Type", "asam-cmp.msg_hdr.payload_type", FT_UINT8, BASE_HEX, VALS(data_msg_type_names), 0x0, NULL, HFILL }},
2287 /* Additional Control Message Header */
2288 { &hf_cmp_ctrl_msg_reserved, { "Reserved", "asam-cmp.msg_hdr.reserved", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2289 { &hf_cmp_ctrl_msg_payload_type, { "Payload Type", "asam-cmp.msg_hdr.payload_type", FT_UINT8, BASE_HEX, VALS(ctrl_msg_type_names), 0x0, NULL, HFILL }},
2291 /* Additional Status Message Header */
2292 { &hf_cmp_status_msg_payload_type, { "Payload Type", "asam-cmp.msg_hdr.payload_type", FT_UINT8, BASE_HEX, VALS(status_msg_type_names), 0x0, NULL, HFILL }},
2294 /* Additional Vendor Message Header */
2295 { &hf_cmp_vendor_msg_payload_type, { "Payload Type", "asam-cmp.msg_hdr.payload_type", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2297 /* Data Message Payloads */
2298 /* CAN Data */
2299 { &hf_cmp_can_flags, { "Flags", "asam-cmp.msg.can.flags", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2300 { &hf_cmp_can_reserved, { "Reserved", "asam-cmp.msg.can.res", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2302 { &hf_cmp_can_id, { "ID", "asam-cmp.msg.can.id_field", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2303 { &hf_cmp_can_id_11bit, { "ID (11bit)", "asam-cmp.msg.can.id_11bit", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CAN_ID_11BIT_MASK, NULL, HFILL }},
2304 { &hf_cmp_can_id_11bit_old, { "ID (11bit)", "asam-cmp.msg.can.id_11bit", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CAN_ID_11BIT_MASK_OLD, NULL, HFILL }},
2305 { &hf_cmp_can_id_29bit, { "ID (29bit)", "asam-cmp.msg.can.id_29bit", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CAN_ID_29BIT_MASK, NULL, HFILL }},
2306 { &hf_cmp_can_id_res, { "Reserved", "asam-cmp.msg.can.res", FT_BOOLEAN, 32, NULL, CMP_CAN_ID_RES, NULL, HFILL }},
2307 { &hf_cmp_can_id_rtr, { "RTR", "asam-cmp.msg.can.rtr", FT_BOOLEAN, 32, TFS(&can_id_rtr), CMP_CAN_ID_RTR, NULL, HFILL }},
2308 { &hf_cmp_can_id_ide, { "IDE", "asam-cmp.msg.can.ide", FT_BOOLEAN, 32, TFS(&can_id_ide), CMP_CAN_ID_IDE, NULL, HFILL }},
2310 { &hf_cmp_can_crc, { "CRC", "asam-cmp.msg.can.crc_field", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2311 { &hf_cmp_can_crc_crc, { "CRC", "asam-cmp.msg.can.crc", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CAN_CRC_CRC, NULL, HFILL }},
2312 { &hf_cmp_can_crc_res, { "Reserved", "asam-cmp.msg.can.crc_res", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CAN_CRC_RES, NULL, HFILL }},
2313 { &hf_cmp_can_crc_crc_support, { "CRC Supported", "asam-cmp.msg.can.crc_support", FT_BOOLEAN, 32, NULL, CMP_CAN_CRC_CRC_SUPP, NULL, HFILL }},
2315 { &hf_cmp_can_err_pos, { "Error Position", "asam-cmp.msg.can.err_pos", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2316 { &hf_cmp_can_dlc, { "DLC", "asam-cmp.msg.can.dlc", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2317 { &hf_cmp_can_data_len, { "Data length", "asam-cmp.msg.can.data_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2319 { &hf_cmp_can_flag_crc_err, { "CRC Error", "asam-cmp.msg.can.flags.crc_err", FT_BOOLEAN, 16, NULL, 0x0001, NULL, HFILL }},
2320 { &hf_cmp_can_flag_ack_err, { "ACK Error", "asam-cmp.msg.can.flags.ack_err", FT_BOOLEAN, 16, NULL, 0x0002, NULL, HFILL } },
2321 { &hf_cmp_can_flag_passive_ack_err, { "Passive ACK Error", "asam-cmp.msg.can.flags.passive_ack_err", FT_BOOLEAN, 16, NULL, 0x0004, NULL, HFILL } },
2322 { &hf_cmp_can_flag_active_ack_err, { "Active ACK Error", "asam-cmp.msg.can.flags.active_ack_err", FT_BOOLEAN, 16, NULL, 0x0008, NULL, HFILL } },
2323 { &hf_cmp_can_flag_ack_del_err, { "ACK DEL Error", "asam-cmp.msg.can.flags.ack_del_err", FT_BOOLEAN, 16, NULL, 0x0010, NULL, HFILL } },
2324 { &hf_cmp_can_flag_form_err, { "Form Error", "asam-cmp.msg.can.flags.form_err", FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL } },
2325 { &hf_cmp_can_flag_stuff_err, { "Stuff Error", "asam-cmp.msg.can.flags.stuff_err", FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL } },
2326 { &hf_cmp_can_flag_crc_del_err, { "CRC DEL Error", "asam-cmp.msg.can.flags.crc_del_err", FT_BOOLEAN, 16, NULL, 0x0080, NULL, HFILL } },
2327 { &hf_cmp_can_flag_eof_err, { "EOF Error", "asam-cmp.msg.can.flags.eof_err", FT_BOOLEAN, 16, NULL, 0x0100, NULL, HFILL } },
2328 { &hf_cmp_can_flag_bit_err, { "Bit Error", "asam-cmp.msg.can.flags.bit_err", FT_BOOLEAN, 16, NULL, 0x0200, NULL, HFILL } },
2329 { &hf_cmp_can_flag_r0, { "R0", "asam-cmp.msg.can.flags.r0", FT_BOOLEAN, 16, TFS(&can_rec_dom), 0x0400, NULL, HFILL } },
2330 { &hf_cmp_can_flag_srr_dom, { "Substitute Remote Request (SRR)", "asam-cmp.msg.can.flags.srr", FT_BOOLEAN, 16, TFS(&can_dom_rec), 0x0800, NULL, HFILL } },
2331 { &hf_cmp_can_flag_reserved, { "Reserved", "asam-cmp.msg.can.flags.reserved", FT_UINT16, BASE_HEX, NULL, 0xF000, NULL, HFILL } },
2333 /* CAN-FD Data */
2334 { &hf_cmp_canfd_flags, { "Flags", "asam-cmp.msg.canfd.flags", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2335 { &hf_cmp_canfd_reserved, { "Reserved", "asam-cmp.msg.canfd.res", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2337 { &hf_cmp_canfd_id, { "ID", "asam-cmp.msg.canfd.id_field", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2338 { &hf_cmp_canfd_id_11bit, { "ID (11bit)", "asam-cmp.msg.canfd.id_11bit", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CAN_ID_11BIT_MASK, NULL, HFILL }},
2339 { &hf_cmp_canfd_id_11bit_old, { "ID (11bit)", "asam-cmp.msg.canfd.id_11bit", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CAN_ID_11BIT_MASK_OLD, NULL, HFILL }},
2340 { &hf_cmp_canfd_id_29bit, { "ID (29bit)", "asam-cmp.msg.canfd.id_29bit", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CAN_ID_29BIT_MASK, NULL, HFILL }},
2341 { &hf_cmp_canfd_id_res, { "Reserved", "asam-cmp.msg.canfd.res", FT_BOOLEAN, 32, NULL, CMP_CANFD_ID_RES, NULL, HFILL }},
2342 { &hf_cmp_canfd_id_rrs, { "RRS", "asam-cmp.msg.canfd.rrs", FT_BOOLEAN, 32, NULL, CMP_CANFD_ID_RRS, NULL, HFILL }},
2343 { &hf_cmp_canfd_id_ide, { "IDE", "asam-cmp.msg.canfd.ide", FT_BOOLEAN, 32, NULL, CMP_CANFD_ID_IDE, NULL, HFILL }},
2345 { &hf_cmp_canfd_crc, { "CRC SBC", "asam-cmp.msg.canfd.crc_field", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2346 { &hf_cmp_canfd_crc_crc17, { "CRC (17bit)", "asam-cmp.msg.canfd.crc17", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CANFD_CRC_CRC17, NULL, HFILL }},
2347 { &hf_cmp_canfd_crc_crc21, { "CRC (21bit)", "asam-cmp.msg.canfd.crc21", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CANFD_CRC_CRC21, NULL, HFILL }},
2348 { &hf_cmp_canfd_crc_sbc, { "SBC", "asam-cmp.msg.canfd.sbc", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CANFD_CRC_SBC, NULL, HFILL }},
2349 { &hf_cmp_canfd_crc_sbc_parity, { "SBC Parity", "asam-cmp.msg.canfd.sbc_parity", FT_BOOLEAN, 32, NULL, CMP_CANFD_CRC_SBC_PARITY, NULL, HFILL }},
2350 { &hf_cmp_canfd_crc_res, { "Reserved", "asam-cmp.msg.canfd.crc_res", FT_UINT32, BASE_HEX_DEC, NULL, CMP_CANFD_CRC_RES, NULL, HFILL }},
2351 { &hf_cmp_canfd_crc_sbc_support, { "SBC Supported", "asam-cmp.msg.canfd.sbc_support", FT_BOOLEAN, 32, NULL, CMP_CANFD_CRC_SBC_SUPP, NULL, HFILL }},
2352 { &hf_cmp_canfd_crc_crc_support, { "CRC Supported", "asam-cmp.msg.canfd.crc_support", FT_BOOLEAN, 32, NULL, CMP_CANFD_CRC_CRC_SUPP, NULL, HFILL }},
2354 { &hf_cmp_canfd_err_pos, { "Error Position", "asam-cmp.msg.canfd.err_pos", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2355 { &hf_cmp_canfd_dlc, { "DLC", "asam-cmp.msg.canfd.dlc", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2356 { &hf_cmp_canfd_data_len, { "Data length", "asam-cmp.msg.canfd.data_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2358 { &hf_cmp_canfd_flag_crc_err, { "CRC Error", "asam-cmp.msg.canfd.flags.crc_err", FT_BOOLEAN, 16, NULL, 0x0001, NULL, HFILL }},
2359 { &hf_cmp_canfd_flag_ack_err, { "ACK Error", "asam-cmp.msg.canfd.flags.ack_err", FT_BOOLEAN, 16, NULL, 0x0002, NULL, HFILL } },
2360 { &hf_cmp_canfd_flag_passive_ack_err, { "Passive ACK Error", "asam-cmp.msg.canfd.flags.passive_ack_err", FT_BOOLEAN, 16, NULL, 0x0004, NULL, HFILL } },
2361 { &hf_cmp_canfd_flag_active_ack_err, { "Active ACK Error", "asam-cmp.msg.canfd.flags.active_ack_err", FT_BOOLEAN, 16, NULL, 0x0008, NULL, HFILL } },
2362 { &hf_cmp_canfd_flag_ack_del_err, { "ACK DEL Error", "asam-cmp.msg.canfd.flags.ack_del_err", FT_BOOLEAN, 16, NULL, 0x0010, NULL, HFILL } },
2363 { &hf_cmp_canfd_flag_form_err, { "Form Error", "asam-cmp.msg.canfd.flags.form_err", FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL } },
2364 { &hf_cmp_canfd_flag_stuff_err, { "Stuff Error", "asam-cmp.msg.canfd.flags.stuff_err", FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL } },
2365 { &hf_cmp_canfd_flag_crc_del_err, { "CRC DEL Error", "asam-cmp.msg.canfd.flags.crc_del_err", FT_BOOLEAN, 16, NULL, 0x0080, NULL, HFILL } },
2366 { &hf_cmp_canfd_flag_eof_err, { "EOF Error", "asam-cmp.msg.canfd.flags.eof_err", FT_BOOLEAN, 16, NULL, 0x0100, NULL, HFILL } },
2367 { &hf_cmp_canfd_flag_bit_err, { "Bit Error", "asam-cmp.msg.canfd.flags.bit_err", FT_BOOLEAN, 16, NULL, 0x0200, NULL, HFILL } },
2368 { &hf_cmp_canfd_flag_res, { "Reserved Bit", "asam-cmp.msg.canfd.flags.res", FT_BOOLEAN, 16, TFS(&can_rec_dom), 0x0400, NULL, HFILL } },
2369 { &hf_cmp_canfd_flag_srr_dom, { "Substitute Remote Request (SRR)", "asam-cmp.msg.canfd.flags.srr", FT_BOOLEAN, 16, TFS(&can_dom_rec), 0x0800, NULL, HFILL } },
2370 { &hf_cmp_canfd_flag_brs, { "BRS", "asam-cmp.msg.canfd.flags.brs", FT_BOOLEAN, 16, NULL, 0x1000, NULL, HFILL } },
2371 { &hf_cmp_canfd_flag_esi, { "ESI", "asam-cmp.msg.canfd.flags.esi", FT_BOOLEAN, 16, TFS(&canfd_act_pas), 0x2000, NULL, HFILL } },
2372 { &hf_cmp_canfd_flag_reserved, { "Reserved", "asam-cmp.msg.canfd.flags.reserved", FT_UINT16, BASE_HEX, NULL, 0xC000, NULL, HFILL } },
2374 /* LIN */
2375 { &hf_cmp_lin_flags, { "Flags", "asam-cmp.msg.lin.flags", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2376 { &hf_cmp_lin_reserved, { "Reserved", "asam-cmp.msg.lin.res", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2377 { &hf_cmp_lin_pid, { "PID", "asam-cmp.msg.lin.pid", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2378 { &hf_cmp_lin_pid_id, { "ID", "asam-cmp.msg.lin.pid.id", FT_UINT8, BASE_HEX, NULL, CMP_CANFD_PID_ID_MASK, NULL, HFILL } },
2379 { &hf_cmp_lin_pid_parity, { "Parity", "asam-cmp.msg.lin.pid.parity", FT_UINT8, BASE_HEX, NULL, CMP_CANFD_PID_PARITY_MASK, NULL, HFILL } },
2380 { &hf_cmp_lin_reserved_2, { "Reserved", "asam-cmp.msg.lin.res_2", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2381 { &hf_cmp_lin_checksum, { "Checksum", "asam-cmp.msg.lin.checksum", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2382 { &hf_cmp_lin_data_len, { "Data length", "asam-cmp.msg.lin.data_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2384 { &hf_cmp_lin_flag_checksum_err, { "Checksum Error", "asam-cmp.msg.lin.flags.checksum_err", FT_BOOLEAN, 16, NULL, 0x0001, NULL, HFILL } },
2385 { &hf_cmp_lin_flag_col_err, { "Collision Error", "asam-cmp.msg.lin.flags.col_err", FT_BOOLEAN, 16, NULL, 0x0002, NULL, HFILL } },
2386 { &hf_cmp_lin_flag_parity_err, { "Parity Error", "asam-cmp.msg.lin.flags.parity_err", FT_BOOLEAN, 16, NULL, 0x0004, NULL, HFILL } },
2387 { &hf_cmp_lin_flag_no_slave_res_err, { "No Slave Response Error", "asam-cmp.msg.lin.flags.no_slave_res_err", FT_BOOLEAN, 16, NULL, 0x0008, NULL, HFILL } },
2388 { &hf_cmp_lin_flag_sync_err, { "Sync Error", "asam-cmp.msg.lin.flags.sync_err", FT_BOOLEAN, 16, NULL, 0x0010, NULL, HFILL } },
2389 { &hf_cmp_lin_flag_framing_err, { "Framing Error", "asam-cmp.msg.lin.flags.framing_err", FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL } },
2390 { &hf_cmp_lin_flag_short_dom_err, { "Short Dominant Error", "asam-cmp.msg.lin.flags.short_dom_err", FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL } },
2391 { &hf_cmp_lin_flag_long_dom_err, { "Long Dominant Error", "asam-cmp.msg.lin.flags.long_dom_err", FT_BOOLEAN, 16, NULL, 0x0080, NULL, HFILL } },
2392 { &hf_cmp_lin_flag_wup, { "Wake Up Request Detection (WUP)", "asam-cmp.msg.lin.flags.wup", FT_BOOLEAN, 16, NULL, 0x0100, NULL, HFILL } },
2393 { &hf_cmp_lin_flag_reserved, { "Reserved", "asam-cmp.msg.lin.flags.reserved", FT_UINT16, BASE_HEX, NULL, 0xFE00, NULL, HFILL } },
2395 /* FlexRay */
2396 { &hf_cmp_flexray_flags, { "Flags", "asam-cmp.msg.flexray.flags.flags", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2397 { &hf_cmp_flexray_reserved, { "Reserved", "asam-cmp.msg.flexray.flags.res", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2398 { &hf_cmp_flexray_header_crc, { "Header CRC", "asam-cmp.msg.flexray.flags.header_crc", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2399 { &hf_cmp_flexray_frame_id, { "Frame ID", "asam-cmp.msg.flexray.flags.frame_id", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2400 { &hf_cmp_flexray_cycle, { "Cycle", "asam-cmp.msg.flexray.flags.cycle", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2401 { &hf_cmp_flexray_frame_crc, { "Frame CRC", "asam-cmp.msg.flexray.flags.frame_crc", FT_UINT24, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2402 { &hf_cmp_flexray_reserved_2, { "Reserved", "asam-cmp.msg.flexray.flags.res_2", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2403 { &hf_cmp_flexray_data_len, { "Data length", "asam-cmp.msg.flexray.flags.data_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2405 { &hf_cmp_flexray_flag_crc_frame_err, { "Frame CRC Error", "asam-cmp.msg.flexray.flags.crc_frame_err", FT_BOOLEAN, 16, NULL, 0x0001, NULL, HFILL }},
2406 { &hf_cmp_flexray_flag_crc_header_err, { "Header CRC Error", "asam-cmp.msg.flexray.flags.crc_header_err", FT_BOOLEAN, 16, NULL, 0x0002, NULL, HFILL }},
2407 { &hf_cmp_flexray_flag_nf, { "Null Frame", "asam-cmp.msg.flexray.flags.nf", FT_BOOLEAN, 16, NULL, CMP_FLEXRAY_FLAGS_NF, NULL, HFILL }},
2408 { &hf_cmp_flexray_flag_sf, { "Startup Frame", "asam-cmp.msg.flexray.flags.sf", FT_BOOLEAN, 16, NULL, 0x0008, NULL, HFILL } },
2409 { &hf_cmp_flexray_flag_sync, { "Sync Frame", "asam-cmp.msg.flexray.flags.sync", FT_BOOLEAN, 16, NULL, 0x0010, NULL, HFILL } },
2410 { &hf_cmp_flexray_flag_wus, { "Wake Up Symbol", "asam-cmp.msg.flexray.flags.wus", FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL } },
2411 { &hf_cmp_flexray_flag_ppi, { "Preamble Indicator", "asam-cmp.msg.flexray.flags.ppi", FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL } },
2412 { &hf_cmp_flexray_flag_cas, { "Collision avoidance Symbol (CAS)", "asam-cmp.msg.flexray.flags.cas", FT_BOOLEAN, 16, NULL, 0x0080, NULL, HFILL } },
2413 { &hf_cmp_flexray_flag_reserved, { "Reserved", "asam-cmp.msg.flexray.flags.reserved", FT_UINT16, BASE_HEX, NULL, 0xFF00, NULL, HFILL } },
2415 /* UART/RS-232 */
2416 { &hf_cmp_uart_flags, { "Flags", "asam-cmp.msg.uart.flags", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2417 { &hf_cmp_uart_reserved, { "Reserved", "asam-cmp.msg.uart.reserved", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2418 { &hf_cmp_uart_data_len, { "Data entry count", "asam-cmp.msg.uart.data_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2419 { &hf_cmp_uart_data, { "Data", "asam-cmp.msg.uart.data", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2421 { &hf_cmp_uart_data_data, { "Data", "asam-cmp.msg.uart.data.data", FT_UINT16, BASE_HEX, NULL, CMP_UART_DATA_DATA_MASK, NULL, HFILL }},
2422 { &hf_cmp_uart_data_reserved, { "Reserved", "asam-cmp.msg.uart.data.reserved", FT_UINT16, BASE_HEX, NULL, 0x1E00, NULL, HFILL }},
2423 { &hf_cmp_uart_data_framing_err, { "Framing Error", "asam-cmp.msg.uart.flags.framing_err", FT_BOOLEAN, 16, NULL, 0x2000, NULL, HFILL }},
2424 { &hf_cmp_uart_data_break_condition, { "Break Condition", "asam-cmp.msg.uart.flags.break_condition", FT_BOOLEAN, 16, NULL, 0x4000, NULL, HFILL }},
2425 { &hf_cmp_uart_data_parity_err, { "Parity Error", "asam-cmp.msg.uart.data.parity_err", FT_BOOLEAN, 16, NULL, 0x8000, NULL, HFILL }},
2427 { &hf_cmp_uart_flag_cl, { "CL", "asam-cmp.msg.uart.flags.cl", FT_UINT16, BASE_HEX, VALS(uart_cl_names), 0x0007, NULL, HFILL }},
2428 { &hf_cmp_uart_flag_reserved, { "Reserved", "asam-cmp.msg.uart.flags.reserved", FT_UINT16, BASE_HEX, NULL, 0xFFF8, NULL, HFILL }},
2430 /* Analog */
2431 { &hf_cmp_analog_flags, { "Flags", "asam-cmp.msg.analog.flags", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2432 { &hf_cmp_analog_reserved, { "Reserved", "asam-cmp.msg.analog.reserved", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2433 { &hf_cmp_analog_unit, { "Unit", "asam-cmp.msg.analog.unit", FT_UINT8, BASE_HEX, VALS(analog_units), 0x0, NULL, HFILL } },
2434 { &hf_cmp_analog_sample_interval, { "Sample Interval", "asam-cmp.msg.analog.sample_interval", FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, UNS(&units_seconds), 0x0, NULL, HFILL } },
2435 { &hf_cmp_analog_sample_offset, { "Sample Offset", "asam-cmp.msg.analog.sample_offset", FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2436 { &hf_cmp_analog_sample_scalar, { "Sample Scalar", "asam-cmp.msg.analog.sample_scalar", FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2437 { &hf_cmp_analog_sample, { "Sample", "asam-cmp.msg.analog.sample", FT_DOUBLE, BASE_EXP, NULL, 0x0, NULL, HFILL } },
2438 { &hf_cmp_analog_sample_raw, { "Sample Raw", "asam-cmp.msg.analog.sample_raw", FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2440 { &hf_cmp_analog_flag_sample_dt, { "Sample Datatype", "asam-cmp.msg.analog.flags.sample_dt", FT_UINT16, BASE_HEX, VALS(analog_sample_dt), 0x0003, NULL, HFILL }},
2441 { &hf_cmp_analog_flag_reserved, { "Reserved", "asam-cmp.msg.analog.flags.reserved", FT_UINT16, BASE_HEX, NULL, 0xfffc, NULL, HFILL }},
2443 /* Ethernet */
2444 { &hf_cmp_eth_flags, { "Flags", "asam-cmp.msg.eth.flags", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2445 { &hf_cmp_eth_reserved, { "Reserved", "asam-cmp.msg.eth.res", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2446 { &hf_cmp_eth_payload_length, { "Data length", "asam-cmp.msg.eth.data_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2448 { &hf_cmp_eth_flag_fcs_err, { "FCS Error", "asam-cmp.msg.eth.flags.crc_err", FT_BOOLEAN, 16, NULL, 0x0001, NULL, HFILL }},
2449 { &hf_cmp_eth_flag_short_err, { "Short Frame Error", "asam-cmp.msg.eth.flags.short_err", FT_BOOLEAN, 16, NULL, 0x0002, NULL, HFILL } },
2450 { &hf_cmp_eth_flag_tx_down, { "TX Port Down", "asam-cmp.msg.eth.flags.tx_down", FT_BOOLEAN, 16, NULL, 0x0004, NULL, HFILL } },
2451 { &hf_cmp_eth_flag_collision, { "Collision detected", "asam-cmp.msg.eth.flags.collision", FT_BOOLEAN, 16, NULL, 0x0008, NULL, HFILL } },
2452 { &hf_cmp_eth_flag_long_err, { "Long Frame Error", "asam-cmp.msg.eth.flags.long_err", FT_BOOLEAN, 16, NULL, 0x0010, NULL, HFILL } },
2453 { &hf_cmp_eth_flag_phy_err, { "PHY Error", "asam-cmp.msg.eth.flags.phy_err", FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL } },
2454 { &hf_cmp_eth_flag_truncated, { "Frame truncated", "asam-cmp.msg.eth.flags.truncated", FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL } },
2455 { &hf_cmp_eth_flag_fcs_supported, { "FCS supported", "asam-cmp.msg.eth.flags.fcs_supported", FT_BOOLEAN, 16, NULL, 0x0080, NULL, HFILL } },
2456 { &hf_cmp_eth_flag_reserved, { "Reserved", "asam-cmp.msg.eth.flags.reserved", FT_UINT16, BASE_HEX, NULL, 0xFF00, NULL, HFILL } },
2458 /* Control Message Payloads */
2459 /* Data Sink Ready */
2460 { &hf_cmp_ctrl_msg_device_id, { "Device ID", "asam-cmp.msg.dsr.device_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2462 /* User Event */
2463 { &hf_cmp_ctrl_msg_event_id, { "Event ID", "asam-cmp.msg.ue.event_id", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2465 /* Vendor specific */
2466 { &hf_cmp_ctrl_msg_vendor_id, { "Vendor ID", "asam-cmp.msg.vs.vendor_id", FT_UINT16, BASE_HEX, VALS(vendor_ids), 0x0, NULL, HFILL } },
2467 { &hf_cmp_ctrl_msg_vendor_payload_type, { "Payload Type", "asam-cmp.msg.vs.payload_type", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2469 /* Status Message Payloads */
2470 /* Capture Module Status Message */
2471 { &hf_cmp_status_msg_cm_uptime_ns, { "Uptime (ns)", "asam-cmp.msg.cm.uptime_ns", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2472 { &hf_cmp_status_msg_cm_uptime_s, { "Uptime (s)", "asam-cmp.msg.cm.uptime_s", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2473 { &hf_cmp_status_msg_gm_identity, { "gPTP grandmasterIdentity", "asam-cmp.msg.cm.gm_identity", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2474 { &hf_cmp_status_msg_gm_clock_quality, { "gPTP grandmasterClockQuality", "asam-cmp.msg.cm.gm_clock_quality", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2475 { &hf_cmp_status_msg_current_utc_offset, { "gPTP currentUtcOffset", "asam-cmp.msg.cm.current_utc_offset", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2476 { &hf_cmp_status_msg_time_source, { "gPTP timeSource", "asam-cmp.msg.cm.time_source", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2477 { &hf_cmp_status_msg_domain_num, { "gPTP domainNumber", "asam-cmp.msg.cm.domain_number", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2478 { &hf_cmp_status_msg_res, { "Reserved", "asam-cmp.msg.cm.res", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2479 { &hf_cmp_gptp_flags, { "gPTP Flags", "asam-cmp.msg.cm.gptp_flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2481 { &hf_cmp_gptp_flags_leap61, { "Leap61", "asam-cmp.msg.cm.gptp_flags.leap61", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL } },
2482 { &hf_cmp_gptp_flags_leap59, { "Leap59", "asam-cmp.msg.cm.gptp_flags.leap59", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL } },
2483 { &hf_cmp_gptp_flags_cur_utco_valid, { "Current UTC Offset Valid", "asam-cmp.msg.cm.gptp_flags.current_utco_valid", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL } },
2484 { &hf_cmp_gptp_flags_ptp_timescale, { "PTP Timescale", "asam-cmp.msg.cm.gptp_flags.ptp_timescale", FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL } },
2485 { &hf_cmp_gptp_flags_time_traceable, { "Time Traceable", "asam-cmp.msg.cm.gptp_flags.time_traceable", FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL } },
2486 { &hf_cmp_gptp_flags_freq_traceable, { "Frequency Traceable", "asam-cmp.msg.cm.gptp_flags.freq_traceable", FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL } },
2487 { &hf_cmp_gptp_flags_reserved, { "Reserved", "asam-cmp.msg.cm.gptp_flags.res", FT_UINT8, BASE_HEX, NULL, 0xC0, NULL, HFILL } },
2489 { &hf_cmp_status_dev_desc_length, { "Length of Device Description", "asam-cmp.msg.cm.dev_desc_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2490 { &hf_cmp_status_dev_desc, { "Device Description", "asam-cmp.msg.cm.dev_desc", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2491 { &hf_cmp_status_sn_length, { "Length of Serial Number", "asam-cmp.msg.cm.sn_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2492 { &hf_cmp_status_sn, { "Serial Number (SN)", "asam-cmp.msg.cm.sn", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2493 { &hf_cmp_status_hw_ver_length, { "Length of Hardware Version", "asam-cmp.msg.cm.hw_ver_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2494 { &hf_cmp_status_hw_ver, { "HW version", "asam-cmp.msg.cm.hw_ver", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2495 { &hf_cmp_status_sw_ver_length, { "Length of Software Version", "asam-cmp.msg.cm.sw_ver_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2496 { &hf_cmp_status_sw_ver, { "SW version", "asam-cmp.msg.cm.sw_ver", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2497 { &hf_cmp_status_vendor_data_length, { "Length of Vendor Data", "asam-cmp.msg.cm.vendor_data_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2498 { &hf_cmp_status_vendor_data, { "Vendor Data", "asam-cmp.msg.cm.vendor_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2500 /* Interface Status Message */
2501 { &hf_cmp_iface_interface, { "Interface", "asam-cmp.msg.iface", FT_PROTOCOL, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2502 { &hf_cmp_iface_iface_id, { "Interface ID", "asam-cmp.msg.iface.iface_id", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2503 { &hf_cmp_iface_msg_total_rx, { "Messages Total RX", "asam-cmp.msg.iface.msg_total_rx", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2504 { &hf_cmp_iface_msg_total_tx, { "Messages Total TX", "asam-cmp.msg.iface.msg_total_tx", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2505 { &hf_cmp_iface_msg_dropped_rx, { "Messages Dropped RX", "asam-cmp.msg.iface.msg_drop_rx", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2506 { &hf_cmp_iface_msg_dropped_tx, { "Messages Dropped TX", "asam-cmp.msg.iface.msg_drop_tx", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2507 { &hf_cmp_iface_errs_total_rx, { "Errors Total RX", "asam-cmp.msg.iface.errors_total_rx", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2508 { &hf_cmp_iface_errs_total_tx, { "Errors Total TX", "asam-cmp.msg.iface.errors_total_tx", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2509 { &hf_cmp_iface_iface_type, { "Interface Type", "asam-cmp.msg.iface.interface_type", FT_UINT8, BASE_HEX, VALS(data_msg_type_names), 0x0, NULL, HFILL } },
2510 { &hf_cmp_iface_iface_status, { "Interface Status", "asam-cmp.msg.iface.interface_status", FT_UINT8, BASE_HEX, VALS(interface_status_names), 0x0, NULL, HFILL } },
2511 { &hf_cmp_iface_stream_id_cnt, { "Stream ID count", "asam-cmp.msg.iface.stream_id_count", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2512 { &hf_cmp_iface_reserved, { "Reserved", "asam-cmp.msg.iface.res", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2514 { &hf_cmp_iface_feat, { "Feature Support Bitmask", "asam-cmp.msg.iface.feat_supp", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2515 { &hf_cmp_iface_feat_can_pas_ack, { "Passive Ack Supported", "asam-cmp.msg.iface.feat_supp.can.pas_ack", FT_BOOLEAN, 32, NULL, 0x00000004, NULL, HFILL } },
2516 { &hf_cmp_iface_feat_can_act_ack, { "Active Ack Supported", "asam-cmp.msg.iface.feat_supp.can.act_ack", FT_BOOLEAN, 32, NULL, 0x00000008, NULL, HFILL } },
2517 { &hf_cmp_iface_feat_can_ack_del_err, { "Ack Del Error Supported", "asam-cmp.msg.iface.feat_supp.can.ack_del_err", FT_BOOLEAN, 32, NULL, 0x00000010, NULL, HFILL } },
2518 { &hf_cmp_iface_feat_can_crc_del_err, { "CRC Del Error Supported", "asam-cmp.msg.iface.feat_supp.can.crc_del_err", FT_BOOLEAN, 32, NULL, 0x00000080, NULL, HFILL } },
2519 { &hf_cmp_iface_feat_can_eof_err, { "EOF Error Supported", "asam-cmp.msg.iface.feat_supp.can.eof_err", FT_BOOLEAN, 32, NULL, 0x00000100, NULL, HFILL } },
2520 { &hf_cmp_iface_feat_can_r0, { "R0 Supported", "asam-cmp.msg.iface.feat_supp.can.r0", FT_BOOLEAN, 32, NULL, 0x00000400, NULL, HFILL } },
2521 { &hf_cmp_iface_feat_can_srr_dom, { "SRR Dom Supported", "asam-cmp.msg.iface.feat_supp.can.srr_dom", FT_BOOLEAN, 32, NULL, 0x00000800, NULL, HFILL } },
2522 { &hf_cmp_iface_feat_canfd_pas_ack, { "Passive Ack Supported", "asam-cmp.msg.iface.feat_supp.canfd.pas_ack", FT_BOOLEAN, 32, NULL, 0x00000004, NULL, HFILL } },
2523 { &hf_cmp_iface_feat_canfd_act_ack, { "Active Ack Supported", "asam-cmp.msg.iface.feat_supp.canfd.act_ack", FT_BOOLEAN, 32, NULL, 0x00000008, NULL, HFILL } },
2524 { &hf_cmp_iface_feat_canfd_ack_del_err, { "Ack Del Error Supported", "asam-cmp.msg.iface.feat_supp.canfd.ack_del_err", FT_BOOLEAN, 32, NULL, 0x00000010, NULL, HFILL } },
2525 { &hf_cmp_iface_feat_canfd_crc_del_err, { "CRC Del Error Supported", "asam-cmp.msg.iface.feat_supp.canfd.crc_del_err", FT_BOOLEAN, 32, NULL, 0x00000080, NULL, HFILL } },
2526 { &hf_cmp_iface_feat_canfd_eof_err, { "EOF Error Supported", "asam-cmp.msg.iface.feat_supp.canfd.eof_err", FT_BOOLEAN, 32, NULL, 0x00000100, NULL, HFILL } },
2527 { &hf_cmp_iface_feat_canfd_rsvd, { "RRSV Supported", "asam-cmp.msg.iface.feat_supp.canfd.rsvd", FT_BOOLEAN, 32, NULL, 0x00000400, NULL, HFILL } },
2528 { &hf_cmp_iface_feat_canfd_srr_dom, { "SRR Dom Supported", "asam-cmp.msg.iface.feat_supp.canfd.srr_dom", FT_BOOLEAN, 32, NULL, 0x00000800, NULL, HFILL } },
2529 { &hf_cmp_iface_feat_canfd_brs_dom, { "BRS Dom Supported", "asam-cmp.msg.iface.feat_supp.canfd.brs_dom", FT_BOOLEAN, 32, NULL, 0x00001000, NULL, HFILL } },
2530 { &hf_cmp_iface_feat_canfd_esi_dom, { "ESI Dom Supported", "asam-cmp.msg.iface.feat_supp.canfd.esi_dom", FT_BOOLEAN, 32, NULL, 0x00002000, NULL, HFILL } },
2531 { &hf_cmp_iface_feat_lin_sync_err, { "Sync Error Supported", "asam-cmp.msg.iface.feat_supp.lin.sync_err", FT_BOOLEAN, 32, NULL, 0x00000010, NULL, HFILL } },
2532 { &hf_cmp_iface_feat_lin_framing_err, { "Framing Error Supported", "asam-cmp.msg.iface.feat_supp.lin.framing_err", FT_BOOLEAN, 32, NULL, 0x00000020, NULL, HFILL } },
2533 { &hf_cmp_iface_feat_lin_short_dom_err, { "Short Dom Error Supported", "asam-cmp.msg.iface.feat_supp.lin.short_dom_err", FT_BOOLEAN, 32, NULL, 0x00000040, NULL, HFILL } },
2534 { &hf_cmp_iface_feat_lin_long_dom_err, { "Long Dom Error Supported", "asam-cmp.msg.iface.feat_supp.lin.long_dom_err", FT_BOOLEAN, 32, NULL, 0x00000080, NULL, HFILL } },
2535 { &hf_cmp_iface_feat_lin_wup, { "WUP Supported", "asam-cmp.msg.iface.feat_supp.lin.wup", FT_BOOLEAN, 32, NULL, 0x00000100, NULL, HFILL } },
2536 { &hf_cmp_iface_feat_eth_too_long, { "Frame too long Supported", "asam-cmp.msg.iface.feat_supp.eth.frame_too_long", FT_BOOLEAN, 32, NULL, 0x00000010, NULL, HFILL } },
2537 { &hf_cmp_iface_feat_eth_phy_err, { "PHY Error Supported", "asam-cmp.msg.iface.feat_supp.eth.phy_err", FT_BOOLEAN, 32, NULL, 0x00000020, NULL, HFILL } },
2538 { &hf_cmp_iface_feat_eth_trunc, { "Truncated Frames Supported", "asam-cmp.msg.iface.feat_supp.eth.truncated_frames", FT_BOOLEAN, 32, NULL, 0x00000040, NULL, HFILL } },
2540 { &hf_cmp_iface_stream_ids, { "Stream IDs", "asam-cmp.msg.iface.stream_ids", FT_PROTOCOL, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2541 { &hf_cmp_iface_stream_id, { "Stream ID", "asam-cmp.msg.iface.stream_id", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2542 { &hf_cmp_iface_vendor_data_len, { "Vendor Data Length", "asam-cmp.msg.iface.vendor_data_len", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2543 { &hf_cmp_iface_vendor_data, { "Vendor Data", "asam-cmp.msg.iface.vendor_data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2545 /* Configuration Status Message */
2546 { &hf_cmp_status_msg_config, { "Data", "asam-cmp.msg.config.data", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2548 /* Data Lost Event Status Message */
2549 { &hf_cmp_dataloss_data_sink_port, { "Data Sink Port", "asam-cmp.msg.dataloss.data_sink_port", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2550 { &hf_cmp_dataloss_device_id, { "Device ID", "asam-cmp.msg.dataloss.device_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2551 { &hf_cmp_dataloss_reserved, { "Reserved", "asam-cmp.msg.dataloss.res", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2552 { &hf_cmp_dataloss_stream_id, { "Stream ID", "asam-cmp.msg.dataloss.stream_id", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2553 { &hf_cmp_dataloss_last_ssq_value, { "Last Stream Sequence Counter Value", "asam-cmp.msg.dataloss.last_ssqc", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2554 { &hf_cmp_dataloss_current_ssq_value, { "Current Stream Sequence Counter Value", "asam-cmp.msg.dataloss.current_ssqc", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2556 /* Time Sync Lost Event Status Message */
2557 { &hf_cmp_timeloss_port_nr, { "Port Number", "asam-cmp.msg.timesyncloss.port_nr", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2558 { &hf_cmp_timeloss_device_id, { "Device ID", "asam-cmp.msg.timesyncloss.device_id", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } },
2559 { &hf_cmp_timeloss_error_flags, { "Time Sync Loss Error Flags", "asam-cmp.msg.timesyncloss.err_flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
2561 { &hf_cmp_timeloss_error_flags_ts, { "Was Time Synced before", "asam-cmp.msg.timesyncloss.err_flags.ts", FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL } },
2562 { &hf_cmp_timeloss_error_flags_insync, { "Original CMP Message had at least one INSYNC=0", "asam-cmp.msg.timesyncloss.err_flags.insync", FT_BOOLEAN, 8, NULL, 0x02, NULL, HFILL } },
2563 { &hf_cmp_timeloss_error_flags_delta, { "Configured Time Delta was exceeded", "asam-cmp.msg.timesyncloss.err_flags.delta", FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL } },
2564 { &hf_cmp_timeloss_error_flags_reserved, { "Reserved", "asam-cmp.msg.timesyncloss.err_flags.res", FT_UINT8, BASE_HEX, NULL, 0xF8, NULL, HFILL } },
2566 /* Vendor Specific Status Message */
2567 { &hf_cmp_status_msg_vendor_specific, { "Vendor Specific", "asam-cmp.msg.vendor_specific", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } },
2570 static int *ett[] = {
2571 &ett_asam_cmp,
2572 &ett_asam_cmp_header,
2573 &ett_asam_cmp_timestamp,
2574 &ett_asam_cmp_common_flags,
2575 &ett_asam_cmp_payload,
2576 &ett_asam_cmp_payload_flags,
2577 &ett_asam_cmp_lin_pid,
2578 &ett_asam_cmp_can_id,
2579 &ett_asam_cmp_can_crc,
2580 &ett_asam_cmp_uart_data,
2581 &ett_asam_cmp_analog_sample,
2582 &ett_asam_cmp_status_cm_flags,
2583 &ett_asam_cmp_status_cm_uptime,
2584 &ett_asam_cmp_status_timeloss_flags,
2585 &ett_asam_cmp_status_interface,
2586 &ett_asam_cmp_status_feature_support,
2587 &ett_asam_cmp_status_stream_ids
2590 static ei_register_info ei[] = {
2591 { &ei_asam_cmp_length_mismatch, {"asam-cmp.expert.length_mismatch", PI_MALFORMED, PI_WARN, "Malformed message, length mismatch!", EXPFILL } },
2592 { &ei_asam_cmp_unsupported_crc_not_zero, {"asam-cmp.export.deactivated_crc_not_zero", PI_MALFORMED, PI_WARN, "Unsupported CRC is not zero!", EXPFILL } },
2595 /* UATs for user_data fields */
2596 static uat_field_t asam_cmp_device_id_uat_fields[] = {
2597 UAT_FLD_HEX(asam_cmp_devices, id, "Device ID", "Device ID (hex uint16 without leading 0x)"),
2598 UAT_FLD_CSTRING(asam_cmp_devices, name, "Device Name", "Device Name (string)"),
2599 UAT_END_FIELDS
2602 static uat_field_t asam_cmp_interface_id_uat_fields[] = {
2603 UAT_FLD_HEX(asam_cmp_interfaces, id, "Interface ID", "Interface ID (hex uint32 without leading 0x)"),
2604 UAT_FLD_CSTRING(asam_cmp_interfaces, name, "Interface Name", "Interface Name (string)"),
2605 UAT_FLD_HEX(asam_cmp_interfaces, bus_id, "Bus ID", "Bus ID of the Interface (hex uint16 without leading 0x)"),
2606 UAT_END_FIELDS
2609 proto_asam_cmp = proto_register_protocol("ASAM Capture Module Protocol", "ASAM CMP", "asam-cmp");
2610 proto_register_field_array(proto_asam_cmp, hf, array_length(hf));
2611 proto_register_subtree_array(ett, array_length(ett));
2612 asam_cmp_module = prefs_register_protocol(proto_asam_cmp, NULL);
2614 expert_module_asam_cmp = expert_register_protocol(proto_asam_cmp);
2615 expert_register_field_array(expert_module_asam_cmp, ei, array_length(ei));
2617 /* Configuration Items */
2618 asam_cmp_deviceid_uat = uat_new("ASAM CMP Devices",
2619 sizeof(generic_one_id_string_t), /* record size */
2620 DATAFILE_ASAM_CMP_DEVICES_IDS, /* filename */
2621 true, /* from profile */
2622 (void**)&asam_cmp_devices, /* data_ptr */
2623 &asam_cmp_devices_num, /* numitems_ptr */
2624 UAT_AFFECTS_DISSECTION, /* but not fields */
2625 NULL, /* help */
2626 copy_generic_one_id_string_cb, /* copy callback */
2627 update_generic_one_identifier_16bit, /* update callback */
2628 free_generic_one_id_string_cb, /* free callback */
2629 post_update_asam_cmp_devices_cb, /* post update callback */
2630 NULL, /* reset callback */
2631 asam_cmp_device_id_uat_fields /* UAT field definitions */
2634 prefs_register_uat_preference(asam_cmp_module, "_udf_asam_cmp_devices", "Devices",
2635 "A table to define names of Devices.", asam_cmp_deviceid_uat);
2637 asam_cmp_interfaceid_uat = uat_new("ASAM CMP Interfaces",
2638 sizeof(interface_config_t), /* record size */
2639 DATAFILE_ASAM_CMP_IFACE_IDS, /* filename */
2640 true, /* from profile */
2641 (void**)&asam_cmp_interfaces, /* data_ptr */
2642 &asam_cmp_interface_num, /* numitems_ptr */
2643 UAT_AFFECTS_DISSECTION, /* but not fields */
2644 NULL, /* help */
2645 copy_interface_config_cb, /* copy callback */
2646 update_interface_config, /* update callback */
2647 free_interface_config_cb, /* free callback */
2648 post_update_interface_config_cb, /* post update callback */
2649 NULL, /* reset callback */
2650 asam_cmp_interface_id_uat_fields /* UAT field definitions */
2653 prefs_register_uat_preference(asam_cmp_module, "_udf_asam_cmp_interfaces", "Interfaces",
2654 "A table to define names and mappings of Interfaces.", asam_cmp_interfaceid_uat);
2656 prefs_register_bool_preference(asam_cmp_module, "try_heuristic_first",
2657 "Try heuristic sub-dissectors first",
2658 "Try to decode a packet using an heuristic sub-dissector"
2659 " before using a sub-dissector registered to \"decode as\"",
2660 &heuristic_first);
2662 prefs_register_bool_preference(asam_cmp_module, "use_old_canid_11bit_format",
2663 "Use old encoding of 11bit CAN/CAN-FD IDs",
2664 "Use the old encoding of 11bit CAN/CAN-FD IDs",
2665 &old_11bit_canid_encoding);
2668 void
2669 proto_reg_handoff_asam_cmp(void) {
2670 dissector_handle_t asam_cmp_handle;
2672 asam_cmp_handle = register_dissector("asam-cmp", dissect_asam_cmp, proto_asam_cmp);
2673 eth_handle = find_dissector("eth_maybefcs");
2675 dissector_add_for_decode_as("ethertype", asam_cmp_handle);
2676 dissector_add_for_decode_as_with_preference("udp.port", asam_cmp_handle);
2678 lin_subdissector_table = find_dissector_table("lin.frame_id");
2682 * Editor modelines
2684 * Local Variables:
2685 * c-basic-offset: 4
2686 * tab-width: 8
2687 * indent-tabs-mode: nil
2688 * End:
2690 * ex: set shiftwidth=4 tabstop=8 expandtab:
2691 * :indentSize=4:tabSize=8:noTabs=true: