Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / file-blf.c
blobc33110806ce8b8dee4ffe3e3d0ae6e78e3d6d1ea
1 /* file-blf.c
2 * BLF File Format.
3 * By Dr. Lars Voelker <lars.voelker@technica-engineering.de>
4 * Copyright 2020-2021 Dr. Lars Voelker
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
12 * This dissector allows to parse BLF files.
16 * The following was used as a reference for the file format:
17 * https://bitbucket.org/tobylorenz/vector_blf
18 * The repo above includes multiple examples files as well.
21 #include "config.h"
23 #include <epan/packet.h>
24 #include <epan/expert.h>
26 #include <wiretap/blf.h>
27 #include <wsutil/array.h>
29 static int proto_blf;
30 static int proto_blf_ethernetstatus_obj;
31 static int proto_blf_ethernetphystate_obj;
33 static dissector_handle_t xml_handle;
35 static int hf_blf_file_header;
36 static int hf_blf_file_header_magic;
37 static int hf_blf_file_header_length;
38 static int hf_blf_file_header_api;
39 static int hf_blf_file_header_app;
40 static int hf_blf_file_header_comp_level;
41 static int hf_blf_file_header_app_major;
42 static int hf_blf_file_header_app_minor;
43 static int hf_blf_file_header_len_comp;
44 static int hf_blf_file_header_len_uncomp;
45 static int hf_blf_file_header_obj_count;
46 static int hf_blf_file_header_app_build;
47 static int hf_blf_file_header_start_date;
48 static int hf_blf_file_header_end_date;
49 static int hf_blf_file_header_restore_point_offset;
51 static int hf_blf_lobj;
52 static int hf_blf_lobj_hdr;
53 static int hf_blf_lobj_magic;
54 static int hf_blf_lobj_hdr_len;
55 static int hf_blf_lobj_hdr_type;
56 static int hf_blf_lobj_obj_len;
57 static int hf_blf_lobj_obj_type;
58 static int hf_blf_lobj_hdr_remains;
59 static int hf_blf_lobj_payload;
61 static int hf_blf_cont_comp_method;
62 static int hf_blf_cont_res1;
63 static int hf_blf_cont_res2;
64 static int hf_blf_cont_uncomp_size;
65 static int hf_blf_cont_res4;
66 static int hf_blf_cont_payload;
68 static int hf_blf_app_text_source;
69 static int hf_blf_app_text_reservedapptext1;
70 static int hf_blf_app_text_textlength;
71 static int hf_blf_app_text_reservedapptext2;
72 static int hf_blf_app_text_data_version;
73 static int hf_blf_app_text_channelno;
74 static int hf_blf_app_text_busstype;
75 static int hf_blf_app_text_can_fd_channel;
76 static int hf_blf_app_text_metadata_remaining_length;
77 static int hf_blf_app_text_metadata_type;
78 static int hf_blf_app_text_traceline_source;
79 static int hf_blf_app_text_traceline_display_in_tracewindow;
80 static int hf_blf_app_text_traceline_ascii_conversion_wo_comment_indicator_timestamp;
81 static int hf_blf_app_text_text;
82 static int hf_blf_trigg_cond_state;
83 static int hf_blf_trigg_cond_triggerblocknamelength;
84 static int hf_blf_trigg_cond_triggerconditionlength;
85 static int hf_blf_trigg_cond_triggerblockname;
86 static int hf_blf_trigg_cond_triggercondition;
87 static int hf_blf_sys_var_type;
88 static int hf_blf_sys_var_rep;
89 static int hf_blf_sys_var_reservedsystemvariable1;
90 static int hf_blf_sys_var_namelength;
91 static int hf_blf_sys_var_datalength;
92 static int hf_blf_sys_var_reservedsystemvariable2;
93 static int hf_blf_sys_var_name;
94 static int hf_blf_sys_var_data;
95 static int hf_blf_eth_status_channel;
96 static int hf_blf_eth_status_flags1_b0;
97 static int hf_blf_eth_status_flags1_b1;
98 static int hf_blf_eth_status_flags1_b2;
99 static int hf_blf_eth_status_flags1_b3;
100 static int hf_blf_eth_status_flags1_b4;
101 static int hf_blf_eth_status_flags1_b5;
102 static int hf_blf_eth_status_flags1_b6;
103 static int hf_blf_eth_status_flags1_b7;
104 static int hf_blf_eth_status_flags1_b8;
105 static int hf_blf_eth_status_flags1_b9;
107 static int hf_blf_eth_status_linkstatus;
108 static int hf_blf_eth_status_ethernetphy;
109 static int hf_blf_eth_status_duplex;
110 static int hf_blf_eth_status_mdi;
111 static int hf_blf_eth_status_connector;
112 static int hf_blf_eth_status_clockmode;
113 static int hf_blf_eth_status_pairs;
114 static int hf_blf_eth_status_hardwarechannel;
115 static int hf_blf_eth_status_bitrate;
116 static int hf_blf_eth_status_linkupduration;
117 static int hf_blf_eth_frame_ext_structlength;
118 static int hf_blf_eth_frame_ext_flags;
119 static int hf_blf_eth_frame_ext_channel;
120 static int hf_blf_eth_frame_ext_hardwarechannel;
121 static int hf_blf_eth_frame_ext_frameduration;
122 static int hf_blf_eth_frame_ext_framechecksum;
123 static int hf_blf_eth_frame_ext_dir;
124 static int hf_blf_eth_frame_ext_framelength;
125 static int hf_blf_eth_frame_ext_framehandle;
126 static int hf_blf_eth_frame_ext_reservedethernetframeex;
128 static int hf_blf_eth_phystate_channel;
129 static int hf_blf_eth_phy_state_flags1_b0;
130 static int hf_blf_eth_phy_state_flags1_b1;
131 static int hf_blf_eth_phy_state_flags1_b2;
132 static int hf_blf_eth_phy_state_phystate;
133 static int hf_blf_eth_phy_state_eventstate;
134 static int hf_blf_eth_phy_state_hardwarechannel;
135 static int hf_blf_eth_phy_state_res1;
137 static expert_field ei_blf_file_header_length_too_short;
138 static expert_field ei_blf_object_header_length_too_short;
139 static expert_field ei_blf_object_length_less_than_header_length;
141 static int ett_blf;
142 static int ett_blf_header;
143 static int ett_blf_obj;
144 static int ett_blf_obj_header;
145 static int ett_blf_logcontainer_payload;
146 static int ett_blf_app_text_payload;
148 static const value_string blf_object_names[] = {
149 { BLF_OBJTYPE_UNKNOWN, "Unknown" },
150 { BLF_OBJTYPE_CAN_MESSAGE, "CAN Message" },
151 { BLF_OBJTYPE_CAN_ERROR, "CAN Error" },
152 { BLF_OBJTYPE_CAN_OVERLOAD, "CAN Overload" },
153 { BLF_OBJTYPE_CAN_STATISTIC, "CAN Statistics" },
154 { BLF_OBJTYPE_APP_TRIGGER, "App Trigger" },
155 { BLF_OBJTYPE_ENV_INTEGER, "Env Integer" },
156 { BLF_OBJTYPE_ENV_DOUBLE, "Env Double" },
157 { BLF_OBJTYPE_ENV_STRING, "Env String" },
158 { BLF_OBJTYPE_ENV_DATA, "Env Data" },
159 { BLF_OBJTYPE_LOG_CONTAINER, "Log Container" },
160 { BLF_OBJTYPE_LIN_MESSAGE, "LIN Message" },
161 { BLF_OBJTYPE_LIN_CRC_ERROR, "LIN CRC Error" },
162 { BLF_OBJTYPE_LIN_DLC_INFO, "LIN DLC Info" },
163 { BLF_OBJTYPE_LIN_RCV_ERROR, "LIN Receive Error" },
164 { BLF_OBJTYPE_LIN_SND_ERROR, "LIN Send Error" },
165 { BLF_OBJTYPE_LIN_SLV_TIMEOUT, "LIN Slave Timeout" },
166 { BLF_OBJTYPE_LIN_SCHED_MODCH, "LIN Schedule Mode Change" },
167 { BLF_OBJTYPE_LIN_SYN_ERROR, "LIN Sync Error" },
168 { BLF_OBJTYPE_LIN_BAUDRATE, "LIN Baudrate" },
169 { BLF_OBJTYPE_LIN_SLEEP, "LIN Sleep" },
170 { BLF_OBJTYPE_LIN_WAKEUP, "LIN Wakeup" },
171 { BLF_OBJTYPE_MOST_SPY, "MOST Spy" },
172 { BLF_OBJTYPE_MOST_CTRL, "MOST Control" },
173 { BLF_OBJTYPE_MOST_LIGHTLOCK, "MOST Light Lock" },
174 { BLF_OBJTYPE_MOST_STATISTIC, "MOST Statistics" },
175 { BLF_OBJTYPE_FLEXRAY_DATA, "FlexRay Data" },
176 { BLF_OBJTYPE_FLEXRAY_SYNC, "FlexRay Sync" },
177 { BLF_OBJTYPE_CAN_DRIVER_ERROR, "CAN Driver Error" },
178 { BLF_OBJTYPE_MOST_PKT, "MOST Packet" },
179 { BLF_OBJTYPE_MOST_PKT2, "MOST Packet 2" },
180 { BLF_OBJTYPE_MOST_HWMODE, "MOST Hardware Mode" },
181 { BLF_OBJTYPE_MOST_REG, "MOST Register Data" },
182 { BLF_OBJTYPE_MOST_GENREG, "MOST Register Data" },
183 { BLF_OBJTYPE_MOST_NETSTATE, "MOST Net State" },
184 { BLF_OBJTYPE_MOST_DATALOST, "MOST Data Lost" },
185 { BLF_OBJTYPE_MOST_TRIGGER, "MOST Trigger" },
186 { BLF_OBJTYPE_FLEXRAY_CYCLE, "FlexRay Cycle" },
187 { BLF_OBJTYPE_FLEXRAY_MESSAGE, "FlexRay Message" },
188 { BLF_OBJTYPE_LIN_CHECKSUM_INFO, "LIN Checksum Info" },
189 { BLF_OBJTYPE_LIN_SPIKE_EVENT, "LIN Spike Event" },
190 { BLF_OBJTYPE_CAN_DRIVER_SYNC, "CAN Driver Sync" },
191 { BLF_OBJTYPE_FLEXRAY_STATUS, "FlexRay Status" },
192 { BLF_OBJTYPE_GPS_EVENT, "GPS Event" },
193 { BLF_OBJTYPE_FLEXRAY_ERROR, "FlexRay Error" },
194 { BLF_OBJTYPE_FLEXRAY_STATUS2, "FlexRay Status 2" },
195 { BLF_OBJTYPE_FLEXRAY_STARTCYCLE, "FlexRay Start Cycle" },
196 { BLF_OBJTYPE_FLEXRAY_RCVMESSAGE, "FlexRay Receive Message" },
197 { BLF_OBJTYPE_REALTIMECLOCK, "Realtime Clock" },
198 { BLF_OBJTYPE_LIN_STATISTIC, "LIN Statistics" },
199 { BLF_OBJTYPE_J1708_MESSAGE, "J1708 Message" },
200 { BLF_OBJTYPE_J1708_VIRTUAL_MSG, "J1708 Virtual Message" },
201 { BLF_OBJTYPE_LIN_MESSAGE2, "LIN Message 2" },
202 { BLF_OBJTYPE_LIN_SND_ERROR2, "LIN Send Error 2" },
203 { BLF_OBJTYPE_LIN_SYN_ERROR2, "LIN Sync Error 2" },
204 { BLF_OBJTYPE_LIN_CRC_ERROR2, "LIN CRC Error 2" },
205 { BLF_OBJTYPE_LIN_RCV_ERROR2, "LIN Receive Error 2" },
206 { BLF_OBJTYPE_LIN_WAKEUP2, "LIN Wakeup 2" },
207 { BLF_OBJTYPE_LIN_SPIKE_EVENT2, "LIN Spike Event 2" },
208 { BLF_OBJTYPE_LIN_LONG_DOM_SIG, "LIN Long Dominant Signal" },
209 { BLF_OBJTYPE_APP_TEXT, "Text" },
210 { BLF_OBJTYPE_FLEXRAY_RCVMESSAGE_EX, "FlexRay Receive Message Ext" },
211 { BLF_OBJTYPE_MOST_STATISTICEX, "MOST Statistics Ext" },
212 { BLF_OBJTYPE_MOST_TXLIGHT, "MOST TX Light" },
213 { BLF_OBJTYPE_MOST_ALLOCTAB, "MOST Allocation Table" },
214 { BLF_OBJTYPE_MOST_STRESS, "MOST Stress" },
215 { BLF_OBJTYPE_ETHERNET_FRAME, "Ethernet Frame" },
216 { BLF_OBJTYPE_SYS_VARIABLE, "System Variable" },
217 { BLF_OBJTYPE_CAN_ERROR_EXT, "CAN Error Ext" },
218 { BLF_OBJTYPE_CAN_DRIVER_ERROR_EXT, "CAN Driver Error Ext" },
219 { BLF_OBJTYPE_LIN_LONG_DOM_SIG2, "LIN Long Dominant Signal 2" },
220 { BLF_OBJTYPE_MOST_150_MESSAGE, "MOST150 Message" },
221 { BLF_OBJTYPE_MOST_150_PKT, "MOST150 Packet" },
222 { BLF_OBJTYPE_MOST_ETHERNET_PKT, "MOST Ethernet Packet" },
223 { BLF_OBJTYPE_MOST_150_MESSAGE_FRAGMENT, "MOST150 Message Fragment" },
224 { BLF_OBJTYPE_MOST_150_PKT_FRAGMENT, "MOST150 Packet Fragment" },
225 { BLF_OBJTYPE_MOST_ETHERNET_PKT_FRAGMENT, "MOST Ethernet Packet Fragment" },
226 { BLF_OBJTYPE_MOST_SYSTEM_EVENT, "MOST System Event" },
227 { BLF_OBJTYPE_MOST_150_ALLOCTAB, "MOST150 Allocation Table" },
228 { BLF_OBJTYPE_MOST_50_MESSAGE, "MOST50 Message" },
229 { BLF_OBJTYPE_MOST_50_PKT, "MOST50 Packet" },
230 { BLF_OBJTYPE_CAN_MESSAGE2, "CAN Message 2" },
231 { BLF_OBJTYPE_LIN_UNEXPECTED_WAKEUP, "LIN Unexpected Wakeup" },
232 { BLF_OBJTYPE_LIN_SHORT_OR_SLOW_RESPONSE, "LIN Short or Slow Response" },
233 { BLF_OBJTYPE_LIN_DISTURBANCE_EVENT, "LIN Disturbance" },
234 { BLF_OBJTYPE_SERIAL_EVENT, "Serial" },
235 { BLF_OBJTYPE_OVERRUN_ERROR, "Overrun Error" },
236 { BLF_OBJTYPE_EVENT_COMMENT, "Comment" },
237 { BLF_OBJTYPE_WLAN_FRAME, "WLAN Frame" },
238 { BLF_OBJTYPE_WLAN_STATISTIC, "WLAN Statistics" },
239 { BLF_OBJTYPE_MOST_ECL, "MOST Electric Control Line" },
240 { BLF_OBJTYPE_GLOBAL_MARKER, "Global Marker" },
241 { BLF_OBJTYPE_AFDX_FRAME, "AFDX Frame" },
242 { BLF_OBJTYPE_AFDX_STATISTIC, "AFDX Statistics" },
243 { BLF_OBJTYPE_KLINE_STATUSEVENT, "KLINE Status" },
244 { BLF_OBJTYPE_CAN_FD_MESSAGE, "CANFD Message" },
245 { BLF_OBJTYPE_CAN_FD_MESSAGE_64, "CANFD Message 64" },
246 { BLF_OBJTYPE_ETHERNET_RX_ERROR, "Ethernet RX Error" },
247 { BLF_OBJTYPE_ETHERNET_STATUS, "Ethernet Status" },
248 { BLF_OBJTYPE_CAN_FD_ERROR_64, "CANFD Error 64" },
249 { BLF_OBJTYPE_AFDX_STATUS, "AFDX Status" },
250 { BLF_OBJTYPE_AFDX_BUS_STATISTIC, "AFDX Bus Statistics" },
251 { BLF_OBJTYPE_AFDX_ERROR_EVENT, "AFDX Error" },
252 { BLF_OBJTYPE_A429_ERROR, "A429 Error" },
253 { BLF_OBJTYPE_A429_STATUS, "A429 Status" },
254 { BLF_OBJTYPE_A429_BUS_STATISTIC, "A429 Bus Statistics" },
255 { BLF_OBJTYPE_A429_MESSAGE, "A429 Message" },
256 { BLF_OBJTYPE_ETHERNET_STATISTIC, "Ethernet Statistics" },
257 { BLF_OBJTYPE_TEST_STRUCTURE, "Test Structure" },
258 { BLF_OBJTYPE_DIAG_REQUEST_INTERPRETATION, "Diagnostics Request Interpretation" },
259 { BLF_OBJTYPE_ETHERNET_FRAME_EX, "Ethernet Frame Ext" },
260 { BLF_OBJTYPE_ETHERNET_FRAME_FORWARDED, "Ethernet Frame Forwarded" },
261 { BLF_OBJTYPE_ETHERNET_ERROR_EX, "Ethernet Error Ext" },
262 { BLF_OBJTYPE_ETHERNET_ERROR_FORWARDED, "Ethernet Error Forwarded" },
263 { BLF_OBJTYPE_FUNCTION_BUS, "Function Bus" },
264 { BLF_OBJTYPE_DATA_LOST_BEGIN, "Data Lost Begin" },
265 { BLF_OBJTYPE_DATA_LOST_END, "Data Lost End" },
266 { BLF_OBJTYPE_WATER_MARK_EVENT, "Watermark" },
267 { BLF_OBJTYPE_TRIGGER_CONDITION, "Trigger Condition" },
268 { BLF_OBJTYPE_CAN_SETTING_CHANGED, "CAN Settings Changed" },
269 { BLF_OBJTYPE_DISTRIBUTED_OBJECT_MEMBER, "Distributed Object Member" },
270 { BLF_OBJTYPE_ATTRIBUTE_EVENT, "Attribute Event" },
271 { BLF_OBJTYPE_DISTRIBUTED_OBJECT_CHANGE, "Distributed Object Change" },
272 { BLF_OBJTYPE_ETHERNET_PHY_STATE, "Ethernet PHY State" },
273 { 0, NULL }
276 static const value_string application_names[] = {
277 { 0, "Unknown" },
278 { 1, "Vector CANalyzer" },
279 { 2, "Vector CANoe" },
280 { 3, "Vector CANstress" },
281 { 4, "Vector CANlog" },
282 { 5, "Vector CANape" },
283 { 6, "Vector CANcaseXL log" },
284 { 7, "Vector Logger Configurator" },
285 { 200, "Porsche Logger" },
286 { 201, "CAETEC Logger" },
287 { 202, "Vector Network Simulator" },
288 { 203, "IPETRONIK logger" },
289 { 204, "RT PK" },
290 { 205, "PikeTec" },
291 { 206, "Sparks" },
292 { 0, NULL }
296 #define BLF_COMPRESSION_NONE 0
297 #define BLF_COMPRESSION_ZLIB 2
299 static const value_string blf_compression_names[] = {
300 { BLF_COMPRESSION_NONE, "No Compression" },
301 { BLF_COMPRESSION_ZLIB, "Compression ZLIB" },
302 { 0, NULL }
305 static const value_string blf_app_text_source_vals[] = {
306 { 0, "Measurement comment" },
307 { 1, "Database channel information" },
308 { 2, "Meta data" },
309 { 3, "Attachment" },
310 { 4, "Trace line" },
311 { 0, NULL }
314 static const value_string blf_trigger_cond_state_vals[] = {
315 { 0, "Unknown" },
316 { 1, "Start" },
317 { 2, "Stop" },
318 { 3, "StartStop"},
319 { 0, NULL }
322 static const value_string blf_sys_var_type_vals[] = {
323 { 1, "Double" },
324 { 2, "Long" },
325 { 3, "String"},
326 { 4, "DoubleArray"},
327 { 5, "LongArray"},
328 { 6, "LongLong"},
329 { 7, "ByteArray"},
330 { 0, NULL }
333 static const value_string blf_eth_status_linkstatus_vals[] = {
334 { 0, "UnknownLinkStatus" },
335 { 1, "LinkDown" },
336 { 2, "LinkUp"},
337 { 3, "Negotiate"},
338 { 4, "LinkError"},
339 { 0, NULL }
342 static const value_string blf_eth_status_ethernetphy_vals[] = {
343 { 0, "UnknownEthernetPhy" },
344 { 1, "Ieee802_3" },
345 { 2, "BroadR_Reach"},
346 { 0, NULL }
349 static const value_string blf_eth_status_duplex_vals[] = {
350 { 0, "UnknownDuplex" },
351 { 1, "HalfDuplex" },
352 { 2, "FullDuplex"},
353 { 0, NULL }
356 static const value_string blf_eth_status_mdi_vals[] = {
357 { 0, "UnknownMDI" },
358 { 1, "Direct" },
359 { 2, "Crossover"},
360 { 0, NULL }
363 static const value_string blf_eth_status_connector_vals[] = {
364 { 0, "UnknownConnector" },
365 { 1, "RJ45" },
366 { 2, "D-sub"},
367 { 0, NULL }
370 static const value_string blf_eth_status_clockmode_vals[] = {
371 { 0, "UnknownClockMode" },
372 { 1, "Master" },
373 { 2, "Slave"},
374 { 0, NULL }
377 static const value_string blf_eth_status_pairs_vals[] = {
378 { 0, "UnknownPairs" },
379 { 1, "1" },
380 { 2, "2"},
381 { 3, "4"},
382 { 0, NULL }
385 static const value_string blf_bustype_vals[] = {
386 { BLF_BUSTYPE_CAN, "CAN" },
387 { BLF_BUSTYPE_LIN, "LIN" },
388 { BLF_BUSTYPE_MOST, "MOST"},
389 { BLF_BUSTYPE_FLEXRAY, "FLEXRAY"},
390 { BLF_BUSTYPE_J1708, "J1708"},
391 { BLF_BUSTYPE_ETHERNET, "ETHERNET"},
392 { BLF_BUSTYPE_WLAN, "WLAN"},
393 { BLF_BUSTYPE_AFDX, "AFDX"},
394 { 0, NULL }
397 static const value_string blf_app_text_metadata_type_vals[] = {
398 { 1, "General" },
399 { 2, "Channels" },
400 { 3, "Identity" },
401 { 0, NULL }
404 static const value_string hf_blf_app_text_traceline_source_vals[] = {
405 { 0, "Write to log" },
406 { 1, "Timer" },
407 { 2, "Write to X" },
408 { 3, "Node layer" },
409 { 4, "CAPL on board" },
410 { 0, NULL }
413 static const value_string blf_eth_phystate_phystate_vals[] = {
414 { 0, "Invalid" },
415 { 1, "Normal" },
416 { 2, "Sleep"},
417 { 3, "PowerOff"},
418 { 4, "SleepRequest"},
419 { 0, NULL }
422 static const value_string blf_eth_phystate_eventstate_vals[] = {
423 { 0, "Invalid" },
424 { 1, "SleepReceived" },
425 { 2, "SleepSent"},
426 { 3, "SleepAbort"},
427 { 4, "SleepAckReceived"},
428 { 8, "WakeUpReceived"},
429 { 9, "WakeUpSent"},
430 { 17, "PowerOff"},
431 { 18, "PowerOn"},
432 { 25, "Activated"},
433 { 0, NULL }
436 #define BLF_BUSTYPE_CAN 1
437 #define BLF_BUSTYPE_LIN 5
438 #define BLF_BUSTYPE_MOST 6
439 #define BLF_BUSTYPE_FLEXRAY 7
440 #define BLF_BUSTYPE_J1708 9
441 #define BLF_BUSTYPE_ETHERNET 11
442 #define BLF_BUSTYPE_WLAN 13
443 #define BLF_BUSTYPE_AFDX 14
445 void proto_register_file_blf(void);
446 void proto_reg_handoff_file_blf(void);
447 static int dissect_blf_next_object(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset);
449 #define MAGIC_NUMBER_SIZE 4
450 static const uint8_t blf_file_magic[MAGIC_NUMBER_SIZE] = { 'L', 'O', 'G', 'G' };
451 static const uint8_t blf_lobj_magic[MAGIC_NUMBER_SIZE] = { 'L', 'O', 'B', 'J' };
454 static proto_item *
455 dissect_blf_header_date(proto_tree *tree, int hf, tvbuff_t *tvb, int offset, int length) {
456 static const value_string weekday_names[] = {
457 { 0, "Sunday"},
458 { 1, "Monday"},
459 { 2, "Tuesday"},
460 { 3, "Wednesday"},
461 { 4, "Thursday"},
462 { 5, "Friday"},
463 { 6, "Saturday"},
464 { 0, NULL }
467 uint16_t year = tvb_get_uint16(tvb, offset + 0, ENC_LITTLE_ENDIAN);
468 uint16_t month = tvb_get_uint16(tvb, offset + 2, ENC_LITTLE_ENDIAN);
469 uint16_t day_of_week = tvb_get_uint16(tvb, offset + 4, ENC_LITTLE_ENDIAN);
470 uint16_t day = tvb_get_uint16(tvb, offset + 6, ENC_LITTLE_ENDIAN);
471 uint16_t hour = tvb_get_uint16(tvb, offset + 8, ENC_LITTLE_ENDIAN);
472 uint16_t minute = tvb_get_uint16(tvb, offset + 10, ENC_LITTLE_ENDIAN);
473 uint16_t sec = tvb_get_uint16(tvb, offset + 12, ENC_LITTLE_ENDIAN);
474 uint16_t ms = tvb_get_uint16(tvb, offset + 14, ENC_LITTLE_ENDIAN);
476 header_field_info *hfinfo = proto_registrar_get_nth(hf);
478 return proto_tree_add_bytes_format(tree, hf, tvb, offset, length, NULL,
479 "%s: %s %d-%02d-%02d %02d:%02d:%02d.%03d",
480 hfinfo->name,
481 val_to_str(day_of_week, weekday_names, "%d"),
482 year, month, day, hour, minute, sec, ms);
485 static proto_item *
486 dissect_blf_api_version(proto_tree *tree, int hf, tvbuff_t *tvb, int offset, int length) {
487 uint32_t api = tvb_get_uint32(tvb, offset, ENC_LITTLE_ENDIAN);
489 uint8_t patch = api % 100;
490 api /= 100;
492 uint8_t build = api % 100;
493 api /= 100;
495 uint8_t minor = api % 100;
496 api /= 100;
498 uint8_t major = api % 100;
500 header_field_info *hfinfo = proto_registrar_get_nth(hf);
502 return proto_tree_add_bytes_format(tree, hf, tvb, offset, length, NULL, "%s: %d.%d.%d.%d",
503 hfinfo->name, major, minor, build, patch);
506 static int
507 // NOLINTNEXTLINE(misc-no-recursion)
508 dissect_blf_lobj(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset_orig) {
509 proto_item *ti_root = NULL;
510 proto_item *ti = NULL;
511 proto_item *ti_lobj_hdr;
512 proto_tree *objtree = NULL;
513 proto_tree *subtree = NULL;
514 volatile int offset = offset_orig;
515 tvbuff_t *sub_tvb;
517 uint32_t hdr_length;
518 uint32_t obj_length;
519 unsigned obj_type;
520 uint32_t comp_method;
522 /* this should never happen since we should only be called with at least 16 Bytes present */
523 if (tvb_captured_length_remaining(tvb, offset_orig) < 16) {
524 return tvb_captured_length_remaining(tvb, offset_orig);
527 ti_root = proto_tree_add_item(tree, hf_blf_lobj, tvb, offset, -1, ENC_NA);
528 objtree = proto_item_add_subtree(ti_root, ett_blf_obj);
530 ti_lobj_hdr = proto_tree_add_item(objtree, hf_blf_lobj_hdr, tvb, offset, -1, ENC_NA);
531 subtree = proto_item_add_subtree(ti_lobj_hdr, ett_blf_obj);
533 proto_tree_add_item(subtree, hf_blf_lobj_magic, tvb, offset, 4, ENC_NA);
534 offset += 4;
535 ti = proto_tree_add_item_ret_uint(subtree, hf_blf_lobj_hdr_len, tvb, offset, 2, ENC_LITTLE_ENDIAN, &hdr_length);
536 if (hdr_length < sizeof (struct blf_blockheader)) {
537 expert_add_info(pinfo, ti, &ei_blf_object_header_length_too_short);
539 offset += 2;
540 proto_tree_add_item(subtree, hf_blf_lobj_hdr_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
541 offset += 2;
542 ti = proto_tree_add_item_ret_uint(subtree, hf_blf_lobj_obj_len, tvb, offset, 4, ENC_LITTLE_ENDIAN, &obj_length);
543 if (obj_length < hdr_length) {
544 expert_add_info(pinfo, ti, &ei_blf_object_length_less_than_header_length);
546 offset += 4;
547 proto_tree_add_item_ret_uint(subtree, hf_blf_lobj_obj_type, tvb, offset, 4, ENC_LITTLE_ENDIAN, &obj_type);
548 offset += 4;
549 proto_item_set_end(ti_lobj_hdr, tvb, offset);
551 /* check if the whole object is present or if it was truncated */
552 if (tvb_captured_length_remaining(tvb, offset_orig) < (int)obj_length) {
553 proto_item_set_end(ti_root, tvb, offset_orig + tvb_captured_length_remaining(tvb, offset_orig));
554 proto_item_append_text(ti_root, " TRUNCATED");
555 return tvb_captured_length_remaining(tvb, offset_orig);
558 proto_item_set_end(ti_root, tvb, offset_orig + obj_length);
559 proto_item_append_text(ti_root, " (%s)", val_to_str(obj_type, blf_object_names, "%d"));
561 switch (obj_type) {
562 case BLF_OBJTYPE_LOG_CONTAINER:
563 proto_tree_add_item_ret_uint(objtree, hf_blf_cont_comp_method, tvb, offset, 2, ENC_LITTLE_ENDIAN, &comp_method);
564 offset += 2;
565 proto_tree_add_item(objtree, hf_blf_cont_res1, tvb, offset, 2, ENC_LITTLE_ENDIAN);
566 offset += 2;
567 proto_tree_add_item(objtree, hf_blf_cont_res2, tvb, offset, 4, ENC_LITTLE_ENDIAN);
568 offset += 4;
569 proto_tree_add_item(objtree, hf_blf_cont_uncomp_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
570 offset += 4;
571 proto_tree_add_item(objtree, hf_blf_cont_res4, tvb, offset, 4, ENC_LITTLE_ENDIAN);
572 offset += 4;
573 if (comp_method == BLF_COMPRESSION_NONE) {
574 sub_tvb = tvb_new_subset_length(tvb, offset, offset_orig + obj_length - offset);
575 } else {
576 sub_tvb = tvb_child_uncompress_zlib(tvb, tvb, offset, offset_orig + obj_length - offset);
577 if (sub_tvb) {
578 add_new_data_source(pinfo, sub_tvb, "Decompressed Data");
582 /* TODO: actually the objects might overlap containers, which we do not consider here... */
583 if (sub_tvb && tvb_captured_length(sub_tvb) > 0) {
584 unsigned offset_sub = 0;
585 ti = proto_tree_add_item(objtree, hf_blf_cont_payload, sub_tvb, 0, offset_orig + obj_length - offset, ENC_NA);
586 subtree = proto_item_add_subtree(ti, ett_blf_logcontainer_payload);
588 unsigned tmp = 42;
589 while ((offset_sub + 16 <= offset_orig + obj_length - offset) && (tmp > 0)) {
590 tmp = dissect_blf_next_object(sub_tvb, pinfo, subtree, offset_sub);
591 offset_sub += tmp;
594 break;
595 case BLF_OBJTYPE_APP_TEXT:
597 unsigned source;
598 unsigned textlength;
599 if (offset - offset_orig < (int)hdr_length) {
600 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
601 offset = offset_orig + hdr_length;
604 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
605 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
607 proto_tree_add_item_ret_uint(subtree, hf_blf_app_text_source, tvb, offset, 4, ENC_LITTLE_ENDIAN, &source);
608 offset += 4;
610 /*uint32_t reservedAppText1 {};*/
611 switch (source) {
612 case BLF_APPTEXT_CHANNEL:
613 /* 1: Database channel information
614 * - reserved contains channel information. The following
615 * - table show how the 4 bytes are used:
616 * - Bit 0-7: Version of the data
617 * - Bit 8-15: Channel number
618 * - Bit 15-23: Bus type of the channel. One of the
619 * following values:
620 * - 1: BL_BUSTYPE_CAN
621 * - 5: BL_BUSTYPE_LIN
622 * - 6: BL_BUSTYPE_MOST
623 * - 7: BL_BUSTYPE_FLEXRAY
624 * - 9: BL_BUSTYPE_J1708
625 * - 10: BL_BUSTYPE_ETHERNET
626 * - 13: BL_BUSTYPE_WLAN
627 * - 14: BL_BUSTYPE_AFDX
628 * - Bit 24: Flag, that determines, if channel is a CAN-
629 * FD channel
630 * - Bit 25-31: Unused at the moment
631 * - text contains database information for the specific
632 * channel. Each database is defined by the database path and
633 * the cluster name (if available). The single databases and the
634 * cluster name are separated by a semicolon. Example:
635 * \<Path1\>;\<ClusterName1\>;\<Path2\>;\<ClusterName2\>;...
636 * If for a database there's no cluster name available, an
637 * empty string is written as cluster name.
639 proto_tree_add_item(subtree, hf_blf_app_text_data_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
640 proto_tree_add_item(subtree, hf_blf_app_text_channelno, tvb, offset, 4, ENC_LITTLE_ENDIAN);
641 proto_tree_add_item(subtree, hf_blf_app_text_busstype, tvb, offset, 4, ENC_LITTLE_ENDIAN);
642 proto_tree_add_item(subtree, hf_blf_app_text_can_fd_channel, tvb, offset, 4, ENC_LITTLE_ENDIAN);
643 break;
644 case BLF_APPTEXT_METADATA:
645 proto_tree_add_item(subtree, hf_blf_app_text_metadata_remaining_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
646 proto_tree_add_item(subtree, hf_blf_app_text_metadata_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
647 break;
648 case BLF_APPTEXT_TRACELINE:
649 proto_tree_add_item(subtree, hf_blf_app_text_traceline_source, tvb, offset, 4, ENC_LITTLE_ENDIAN);
650 proto_tree_add_item(subtree, hf_blf_app_text_traceline_display_in_tracewindow, tvb, offset, 4, ENC_LITTLE_ENDIAN);
651 proto_tree_add_item(subtree, hf_blf_app_text_traceline_ascii_conversion_wo_comment_indicator_timestamp, tvb, offset, 4, ENC_LITTLE_ENDIAN);
652 break;
653 default:
654 proto_tree_add_item(subtree, hf_blf_app_text_reservedapptext1, tvb, offset, 4, ENC_LITTLE_ENDIAN);
655 break;
657 offset += 4;
658 /*uint32_t textLength {};*/
659 proto_tree_add_item_ret_uint(subtree, hf_blf_app_text_textlength, tvb, offset, 4, ENC_LITTLE_ENDIAN, &textlength);
660 offset += 4;
661 /*uint32_t reservedAppText2 {};*/
662 proto_tree_add_item(subtree, hf_blf_app_text_reservedapptext2, tvb, offset, 4, ENC_LITTLE_ENDIAN);
663 offset += 4;
664 /* If there is less than 38 characters this is not XML
665 * <?xml version="1.0" encoding="UTF-8"?>
667 if ((textlength > 37) && (tvb_strncaseeql(tvb, offset, "<?xml", 5) == 0) &&( xml_handle)) {
668 tvbuff_t* new_tvb = tvb_new_subset_length(tvb, offset, textlength);
669 call_dissector(xml_handle, new_tvb, pinfo, subtree);
670 } else {
671 proto_tree_add_item(subtree, hf_blf_app_text_text, tvb, offset, textlength, ENC_UTF_8|ENC_NA);
674 break;
675 case BLF_OBJTYPE_SYS_VARIABLE:
677 uint32_t namelength;
678 uint32_t datalength;
680 if (offset - offset_orig < (int)hdr_length) {
681 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
682 offset = offset_orig + hdr_length;
685 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
686 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
688 /* uint32_t type {}; */
689 proto_tree_add_item(subtree, hf_blf_sys_var_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
690 offset += 4;
691 /* uint32_t representation {}; */
692 proto_tree_add_item(subtree, hf_blf_sys_var_rep, tvb, offset, 4, ENC_LITTLE_ENDIAN);
693 offset += 4;
694 /* uint64_t reservedSystemVariable1 {}; */
695 proto_tree_add_item(subtree, hf_blf_sys_var_reservedsystemvariable1, tvb, offset, 8, ENC_LITTLE_ENDIAN);
696 offset += 8;
697 /* uint32_t nameLength {}; */
698 proto_tree_add_item_ret_uint(subtree, hf_blf_sys_var_namelength, tvb, offset, 4, ENC_LITTLE_ENDIAN, &namelength);
699 offset += 4;
700 /* uint32_t dataLength {}; */
701 proto_tree_add_item_ret_uint(subtree, hf_blf_sys_var_datalength, tvb, offset, 4, ENC_LITTLE_ENDIAN, &datalength);
702 offset += 4;
703 /* uint64_t reservedSystemVariable2 {}; */
704 proto_tree_add_item(subtree, hf_blf_sys_var_reservedsystemvariable2, tvb, offset, 8, ENC_LITTLE_ENDIAN);
705 offset += 8;
706 proto_tree_add_item(subtree, hf_blf_sys_var_name, tvb, offset, namelength, ENC_UTF_8 | ENC_NA);
707 offset += namelength;
708 proto_tree_add_item(subtree, hf_blf_sys_var_data, tvb, offset, datalength, ENC_NA);
709 offset += datalength;
711 break;
712 case BLF_OBJTYPE_ETHERNET_STATUS:
714 static int* const flags1[] = {
715 &hf_blf_eth_status_flags1_b9,
716 &hf_blf_eth_status_flags1_b8,
717 &hf_blf_eth_status_flags1_b7,
718 &hf_blf_eth_status_flags1_b6,
719 &hf_blf_eth_status_flags1_b5,
720 &hf_blf_eth_status_flags1_b4,
721 &hf_blf_eth_status_flags1_b3,
722 &hf_blf_eth_status_flags1_b2,
723 &hf_blf_eth_status_flags1_b1,
724 &hf_blf_eth_status_flags1_b0,
725 NULL
727 if (offset - offset_orig < (int)hdr_length) {
728 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
729 offset = offset_orig + hdr_length;
732 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
733 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
735 /* uint16_t channel {}; */
736 proto_tree_add_item(subtree, hf_blf_eth_status_channel, tvb, offset, 2, ENC_LITTLE_ENDIAN);
737 offset += 2;
738 /* uint16_t flags; */
739 proto_tree_add_bitmask_list(subtree, tvb, offset, 2, flags1, ENC_LITTLE_ENDIAN);
740 offset += 2;
741 /* uint8_t linkStatus {}; */
742 proto_tree_add_item(subtree, hf_blf_eth_status_linkstatus, tvb, offset, 1, ENC_LITTLE_ENDIAN);
743 offset += 1;
744 /* uint8_t ethernetPhy {};*/
745 proto_tree_add_item(subtree, hf_blf_eth_status_ethernetphy, tvb, offset, 1, ENC_LITTLE_ENDIAN);
746 offset += 1;
747 /* uint8_t duplex {}; */
748 proto_tree_add_item(subtree, hf_blf_eth_status_duplex, tvb, offset, 1, ENC_LITTLE_ENDIAN);
749 offset += 1;
750 /* uint8_t mdi {}; */
751 proto_tree_add_item(subtree, hf_blf_eth_status_mdi, tvb, offset, 1, ENC_LITTLE_ENDIAN);
752 offset += 1;
753 /* uint8_t connector {};*/
754 proto_tree_add_item(subtree, hf_blf_eth_status_connector, tvb, offset, 1, ENC_LITTLE_ENDIAN);
755 offset += 1;
756 /* uint8_t clockMode {}; */
757 proto_tree_add_item(subtree, hf_blf_eth_status_clockmode, tvb, offset, 1, ENC_LITTLE_ENDIAN);
758 offset += 1;
759 /* uint8_t pairs {}; */
760 proto_tree_add_item(subtree, hf_blf_eth_status_pairs, tvb, offset, 1, ENC_LITTLE_ENDIAN);
761 offset += 1;
762 /* uint8_t hardwareChannel {};*/
763 proto_tree_add_item(subtree, hf_blf_eth_status_hardwarechannel, tvb, offset, 1, ENC_LITTLE_ENDIAN);
764 offset += 1;
765 /* uint32_t bitrate {}; */
766 proto_tree_add_item(subtree, hf_blf_eth_status_bitrate, tvb, offset, 4, ENC_LITTLE_ENDIAN);
767 offset += 4;
768 if (offset_orig + obj_length - offset >= 8) {
769 proto_tree_add_item(subtree, hf_blf_eth_status_linkupduration, tvb, offset, 8, ENC_LITTLE_ENDIAN);
772 break;
773 case BLF_OBJTYPE_ETHERNET_FRAME_EX:
775 if (offset - offset_orig < (int)hdr_length) {
776 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
777 offset = offset_orig + hdr_length;
780 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
781 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
783 /* uint16_t structLength {}; */
784 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_structlength, tvb, offset, 2, ENC_LITTLE_ENDIAN);
785 offset += 2;
786 /* uint16_t flags {}; */
787 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN);
788 offset += 2;
789 /* uint16_t channel {}; */
790 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_channel, tvb, offset, 2, ENC_LITTLE_ENDIAN);
791 offset += 2;
792 /* uint16_t hardwareChannel {}; */
793 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_hardwarechannel, tvb, offset, 2, ENC_LITTLE_ENDIAN);
794 offset += 2;
795 /* uint64_t frameDuration {}; */
796 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_frameduration, tvb, offset, 8, ENC_LITTLE_ENDIAN);
797 offset += 8;
798 /* uint32_t frameChecksum {}; */
799 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_framechecksum, tvb, offset, 4, ENC_LITTLE_ENDIAN);
800 offset += 4;
801 /* uint16_t dir {}; */
802 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_dir, tvb, offset, 2, ENC_LITTLE_ENDIAN);
803 offset += 2;
804 /* uint16_t frameLength {}; */
805 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_framelength, tvb, offset, 2, ENC_LITTLE_ENDIAN);
806 offset += 2;
807 /* uint32_t frameHandle {}; */
808 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_framehandle, tvb, offset, 4, ENC_LITTLE_ENDIAN);
809 offset += 4;
810 /* uint32_t reservedEthernetFrameEx {}; */
811 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_reservedethernetframeex, tvb, offset, 4, ENC_LITTLE_ENDIAN);
812 offset += 4;
814 break;
815 case BLF_OBJTYPE_TRIGGER_CONDITION:
817 uint32_t triggerblocknamelength;
818 uint32_t triggerconditionlength;
820 if (offset - offset_orig < (int)hdr_length) {
821 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
822 offset = offset_orig + hdr_length;
825 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
826 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
828 /* uint32_t state {}; */
829 proto_tree_add_item(subtree, hf_blf_trigg_cond_state, tvb, offset, 4, ENC_LITTLE_ENDIAN);
830 offset += 4;
831 /* uint32_t triggerBlockNameLength {}; */
832 proto_tree_add_item_ret_uint(subtree, hf_blf_trigg_cond_triggerblocknamelength, tvb, offset, 4, ENC_LITTLE_ENDIAN,&triggerblocknamelength);
833 offset += 4;
834 /* uint32_t triggerConditionLength {};*/
835 proto_tree_add_item_ret_uint(subtree, hf_blf_trigg_cond_triggerconditionlength, tvb, offset, 4, ENC_LITTLE_ENDIAN, &triggerconditionlength);
836 offset += 4;
837 /* std::string triggerBlockName {};*/
838 proto_tree_add_item(subtree, hf_blf_trigg_cond_triggerblockname, tvb, offset, triggerblocknamelength, ENC_UTF_8 | ENC_NA);
839 offset += triggerblocknamelength;
840 /* std::string triggerCondition {};*/
841 proto_tree_add_item(subtree, hf_blf_trigg_cond_triggercondition, tvb, offset, triggerconditionlength, ENC_UTF_8 | ENC_NA);
842 offset += triggerconditionlength;
844 break;
845 case BLF_OBJTYPE_ETHERNET_PHY_STATE:
847 static int* const flags1[] = {
848 &hf_blf_eth_phy_state_flags1_b2,
849 &hf_blf_eth_phy_state_flags1_b1,
850 &hf_blf_eth_phy_state_flags1_b0,
851 NULL
853 if (offset - offset_orig < (int)hdr_length) {
854 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
855 offset = offset_orig + hdr_length;
858 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
859 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
861 /* uint16_t channel {}; */
862 proto_tree_add_item(subtree, hf_blf_eth_phystate_channel, tvb, offset, 2, ENC_BIG_ENDIAN);
863 offset += 2;
864 /* uint16_t flags; */
865 proto_tree_add_bitmask_list(subtree, tvb, offset, 2, flags1, ENC_BIG_ENDIAN);
866 offset += 2;
867 /* uint8_t phyState {}; */
868 proto_tree_add_item(subtree, hf_blf_eth_phy_state_phystate, tvb, offset, 1, ENC_BIG_ENDIAN);
869 offset += 1;
870 /* uint8_t eventState {}; */
871 proto_tree_add_item(subtree, hf_blf_eth_phy_state_eventstate, tvb, offset, 1, ENC_BIG_ENDIAN);
872 offset += 1;
873 /* uint8_t hardwareChannel {}; */
874 proto_tree_add_item(subtree, hf_blf_eth_phy_state_hardwarechannel, tvb, offset, 1, ENC_BIG_ENDIAN);
875 offset += 1;
876 /* uint8_t res1 {}; */
877 proto_tree_add_item(subtree, hf_blf_eth_phy_state_res1, tvb, offset, 1, ENC_BIG_ENDIAN);
878 offset += 1;
880 break;
881 default:
882 if (offset - offset_orig < (int)hdr_length) {
883 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
884 offset = offset_orig + hdr_length;
887 proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
888 offset = offset_orig + obj_length;
889 break;
892 return (int)obj_length;
895 static int
896 // NOLINTNEXTLINE(misc-no-recursion)
897 dissect_blf_next_object(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) {
898 int offset_orig = offset;
900 while (tvb_captured_length_remaining(tvb, offset) >= 16) {
901 if (tvb_memeql(tvb, offset, blf_lobj_magic, MAGIC_NUMBER_SIZE) != 0) {
902 offset += 1;
903 } else {
904 increment_dissection_depth(pinfo);
905 int bytes_parsed = dissect_blf_lobj(tvb, pinfo, tree, offset);
906 decrement_dissection_depth(pinfo);
907 if (bytes_parsed <= 0) {
908 return 0;
909 } else {
910 offset += bytes_parsed;
915 return offset - offset_orig;
919 static int
920 dissect_blf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) {
921 volatile int offset = 0;
922 proto_tree *blf_tree;
923 uint32_t header_length;
924 proto_tree *subtree;
925 proto_item *ti;
926 unsigned length;
928 if (tvb_captured_length(tvb) < 8 || tvb_memeql(tvb, 0, blf_file_magic, MAGIC_NUMBER_SIZE) != 0) {
929 /* does not start with LOGG, so this is not BLF it seems */
930 return 0;
933 ti = proto_tree_add_item(tree, proto_blf, tvb, offset, -1, ENC_NA);
934 blf_tree = proto_item_add_subtree(ti, ett_blf);
935 length = tvb_get_uint32(tvb, 4, ENC_LITTLE_ENDIAN);
937 ti = proto_tree_add_item(blf_tree, hf_blf_file_header, tvb, offset, length, ENC_NA);
938 subtree = proto_item_add_subtree(ti, ett_blf_header);
940 proto_tree_add_item(subtree, hf_blf_file_header_magic, tvb, offset, 4, ENC_NA);
941 offset += 4;
942 ti = proto_tree_add_item_ret_uint(subtree, hf_blf_file_header_length, tvb, offset, 4, ENC_LITTLE_ENDIAN, &header_length);
943 if (header_length < sizeof (struct blf_fileheader)) {
944 expert_add_info(pinfo, ti, &ei_blf_file_header_length_too_short);
946 offset += 4;
947 dissect_blf_api_version(subtree, hf_blf_file_header_api, tvb, offset, 4);
948 offset += 4;
949 proto_tree_add_item(subtree, hf_blf_file_header_app, tvb, offset, 1, ENC_NA);
950 offset += 1;
951 proto_tree_add_item(subtree, hf_blf_file_header_comp_level, tvb, offset, 1, ENC_NA);
952 offset += 1;
953 proto_tree_add_item(subtree, hf_blf_file_header_app_major, tvb, offset, 1, ENC_NA);
954 offset += 1;
955 proto_tree_add_item(subtree, hf_blf_file_header_app_minor, tvb, offset, 1, ENC_NA);
956 offset += 1;
957 proto_tree_add_item(subtree, hf_blf_file_header_len_comp, tvb, offset, 8, ENC_LITTLE_ENDIAN);
958 offset += 8;
959 proto_tree_add_item(subtree, hf_blf_file_header_len_uncomp, tvb, offset, 8, ENC_LITTLE_ENDIAN);
960 offset += 8;
961 proto_tree_add_item(subtree, hf_blf_file_header_obj_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
962 offset += 4;
963 proto_tree_add_item(subtree, hf_blf_file_header_app_build, tvb, offset, 4, ENC_LITTLE_ENDIAN);
964 offset += 4;
965 dissect_blf_header_date(subtree, hf_blf_file_header_start_date, tvb, offset, 16);
966 offset += 16;
967 dissect_blf_header_date(subtree, hf_blf_file_header_end_date, tvb, offset, 16);
968 offset += 16;
969 proto_tree_add_item(subtree, hf_blf_file_header_restore_point_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
970 offset += 8;
972 offset += dissect_blf_next_object(tvb, pinfo, blf_tree, offset);
974 return offset;
977 static bool
978 dissect_blf_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
979 return dissect_blf(tvb, pinfo, tree, data) > 0;
982 static int
983 dissect_blf_ethernetstatus_obj(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) {
984 proto_item *ti;
985 proto_tree* blf_tree;
986 int offset = 0;
988 static int* const flags1[] = {
989 &hf_blf_eth_status_flags1_b9,
990 &hf_blf_eth_status_flags1_b8,
991 &hf_blf_eth_status_flags1_b7,
992 &hf_blf_eth_status_flags1_b6,
993 &hf_blf_eth_status_flags1_b5,
994 &hf_blf_eth_status_flags1_b4,
995 &hf_blf_eth_status_flags1_b3,
996 &hf_blf_eth_status_flags1_b2,
997 &hf_blf_eth_status_flags1_b1,
998 &hf_blf_eth_status_flags1_b0,
999 NULL
1002 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLF Ethernet Status");
1003 col_clear(pinfo->cinfo, COL_INFO);
1005 ti = proto_tree_add_item(tree, proto_blf_ethernetstatus_obj, tvb, offset, -1, ENC_NA);
1006 blf_tree = proto_item_add_subtree(ti, ett_blf);
1008 /* uint16_t channel {}; */
1009 uint32_t channel;
1010 proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_status_channel, tvb, offset, 2, ENC_BIG_ENDIAN, &channel);
1011 offset += 2;
1012 /* uint16_t flags; */
1013 uint16_t flags = tvb_get_ntohs(tvb, offset);
1014 proto_tree_add_bitmask_list(blf_tree, tvb, offset, 2, flags1, ENC_BIG_ENDIAN);
1015 offset += 2;
1017 /* uint8_t linkStatus {}; */
1018 uint32_t linkstatus;
1019 ti = proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_status_linkstatus, tvb, offset, 1, ENC_BIG_ENDIAN, &linkstatus);
1020 if ((flags & BLF_ETH_STATUS_LINKSTATUS) == 0) {
1021 proto_item_append_text(ti, " - Invalid");
1023 offset += 1;
1025 /* uint8_t ethernetPhy {};*/
1026 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_ethernetphy, tvb, offset, 1, ENC_BIG_ENDIAN);
1027 if ((flags & BLF_ETH_STATUS_ETHERNETPHY) == 0) {
1028 proto_item_append_text(ti, " - Invalid");
1030 offset += 1;
1032 /* uint8_t duplex {}; */
1033 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_duplex, tvb, offset, 1, ENC_BIG_ENDIAN);
1034 if ((flags & BLF_ETH_STATUS_DUPLEX) == 0) {
1035 proto_item_append_text(ti, " - Invalid");
1037 offset += 1;
1039 /* uint8_t mdi {}; */
1040 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_mdi, tvb, offset, 1, ENC_BIG_ENDIAN);
1041 if ((flags & BLF_ETH_STATUS_MDITYPE) == 0) {
1042 proto_item_append_text(ti, " - Invalid");
1044 offset += 1;
1046 /* uint8_t connector {};*/
1047 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_connector, tvb, offset, 1, ENC_BIG_ENDIAN);
1048 if ((flags & BLF_ETH_STATUS_CONNECTOR) == 0) {
1049 proto_item_append_text(ti, " - Invalid");
1051 offset += 1;
1053 /* uint8_t clockMode {}; */
1054 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_clockmode, tvb, offset, 1, ENC_BIG_ENDIAN);
1055 if ((flags & BLF_ETH_STATUS_CLOCKMODE) == 0) {
1056 proto_item_append_text(ti, " - Invalid");
1058 offset += 1;
1060 /* uint8_t pairs {}; */
1061 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_pairs, tvb, offset, 1, ENC_BIG_ENDIAN);
1062 if ((flags & BLF_ETH_STATUS_BRPAIR) == 0) {
1063 proto_item_append_text(ti, " - Invalid");
1065 offset += 1;
1067 /* uint8_t hardwareChannel {};*/
1068 uint32_t hardwarechannel;
1069 ti = proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_status_hardwarechannel, tvb, offset, 1, ENC_BIG_ENDIAN, &hardwarechannel);
1070 if ((flags & BLF_ETH_STATUS_HARDWARECHANNEL) == 0) {
1071 proto_item_append_text(ti, " - Invalid");
1073 offset += 1;
1075 /* uint32_t bitrate {}; */
1076 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_bitrate, tvb, offset, 4, ENC_BIG_ENDIAN);
1077 if ((flags & BLF_ETH_STATUS_BITRATE) == 0) {
1078 proto_item_append_text(ti, " - Invalid");
1080 offset += 4;
1082 if ((int)tvb_captured_length(tvb) >= offset + 8) {
1083 /* uint64_t linkUpDuration {}; */
1084 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_linkupduration, tvb, offset, 8, ENC_BIG_ENDIAN);
1085 if ((flags & BLF_ETH_STATUS_LINKUPDURATION) == 0) {
1086 proto_item_append_text(ti, " - Invalid");
1090 if ((flags & BLF_ETH_STATUS_LINKSTATUS) != 0) {
1091 if ((flags & BLF_ETH_STATUS_HARDWARECHANNEL) == 0) {
1092 col_add_fstr(pinfo->cinfo, COL_INFO, "ETH-%u %s", channel, val_to_str_const(linkstatus, blf_eth_status_linkstatus_vals, "Unknown"));
1093 } else {
1094 col_add_fstr(pinfo->cinfo, COL_INFO, "ETH-%u-%u %s", channel, hardwarechannel, val_to_str_const(linkstatus, blf_eth_status_linkstatus_vals, "Unknown"));
1098 return tvb_reported_length(tvb);
1101 static int
1102 dissect_blf_ethernetphystate_obj(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) {
1103 proto_item* ti;
1104 proto_tree* blf_tree;
1105 int offset = 0;
1107 static int* const flags1[] = {
1108 &hf_blf_eth_phy_state_flags1_b2,
1109 &hf_blf_eth_phy_state_flags1_b1,
1110 &hf_blf_eth_phy_state_flags1_b0,
1111 NULL
1114 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLF Ethernet PHY State");
1115 col_clear(pinfo->cinfo, COL_INFO);
1117 ti = proto_tree_add_item(tree, proto_blf_ethernetphystate_obj, tvb, offset, -1, ENC_NA);
1118 blf_tree = proto_item_add_subtree(ti, ett_blf);
1120 /* uint16_t channel {}; */
1121 uint32_t channel;
1122 proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_phystate_channel, tvb, offset, 2, ENC_BIG_ENDIAN, &channel);
1123 offset += 2;
1125 /* uint16_t flags; */
1126 uint16_t flags = tvb_get_ntohs(tvb, offset);
1127 proto_tree_add_bitmask_list(blf_tree, tvb, offset, 2, flags1, ENC_BIG_ENDIAN);
1128 offset += 2;
1130 /* uint8_t phyState {}; */
1131 uint32_t phyState;
1132 ti = proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_phy_state_phystate, tvb, offset, 1, ENC_BIG_ENDIAN, &phyState);
1133 if ((flags & BLF_PHY_STATE_PHYSTATE) == 0) {
1134 proto_item_append_text(ti, " - Invalid");
1136 offset += 1;
1138 /* uint8_t eventState {}; */
1139 uint32_t eventState;
1140 ti = proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_phy_state_eventstate, tvb, offset, 1, ENC_BIG_ENDIAN, &eventState);
1141 if ((flags & BLF_PHY_STATE_PHYEVENT) == 0) {
1142 proto_item_append_text(ti, " - Invalid");
1144 offset += 1;
1146 /* uint8_t hardwareChannel {}; */
1147 uint32_t hardwareChannel;
1148 ti = proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_phy_state_hardwarechannel, tvb, offset, 1, ENC_BIG_ENDIAN, &hardwareChannel);
1149 if ((flags & BLF_PHY_STATE_HARDWARECHANNEL) == 0) {
1150 proto_item_append_text(ti, " - Invalid");
1152 offset += 1;
1154 /* uint8_t res1 {}; */
1155 proto_tree_add_item(blf_tree, hf_blf_eth_phy_state_res1, tvb, offset, 1, ENC_BIG_ENDIAN);
1157 if ((flags & (BLF_PHY_STATE_PHYSTATE | BLF_PHY_STATE_PHYEVENT)) != 0) {
1158 /* One of the two is valid */
1159 if ((flags & BLF_PHY_STATE_HARDWARECHANNEL) == 0) {
1160 col_add_fstr(pinfo->cinfo, COL_INFO, "ETH-%u", channel);
1162 else {
1163 col_add_fstr(pinfo->cinfo, COL_INFO, "ETH-%u-%u", channel, hardwareChannel);
1165 if ((flags & BLF_PHY_STATE_PHYSTATE) != 0) {
1166 col_append_fstr(pinfo->cinfo, COL_INFO, " - State: %s", val_to_str_const(phyState, blf_eth_phystate_phystate_vals, "Unknown"));
1168 if ((flags & BLF_PHY_STATE_PHYEVENT) != 0) {
1169 col_append_fstr(pinfo->cinfo, COL_INFO, " - Event: %s", val_to_str_const(eventState, blf_eth_phystate_eventstate_vals, "Unknown"));
1173 return tvb_reported_length(tvb);
1177 void
1178 proto_register_file_blf(void) {
1179 expert_module_t *expert_blf;
1181 static hf_register_info hf[] = {
1182 { &hf_blf_file_header,
1183 { "File Header", "blf.file_header", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1184 { &hf_blf_file_header_magic,
1185 { "Magic", "blf.file_header.magic", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1186 { &hf_blf_file_header_length,
1187 { "Header Length", "blf.file_header.length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1188 { &hf_blf_file_header_api,
1189 { "API Version", "blf.file_header.api", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1190 { &hf_blf_file_header_app,
1191 { "Application", "blf.file_header.application", FT_UINT8, BASE_DEC, VALS(application_names), 0x00, NULL, HFILL }},
1192 { &hf_blf_file_header_comp_level,
1193 { "Compression Level", "blf.file_header.compression_level", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1194 { &hf_blf_file_header_app_major,
1195 { "Application Major Version", "blf.file_header.application_major", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1196 { &hf_blf_file_header_app_minor,
1197 { "Application Minor Version", "blf.file_header.application_minor", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1198 { &hf_blf_file_header_len_comp,
1199 { "Length (compressed)", "blf.file_header.length_compressed", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1200 { &hf_blf_file_header_len_uncomp,
1201 { "Length (uncompressed)", "blf.file_header.length_uncompressed", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1202 { &hf_blf_file_header_obj_count,
1203 { "Object Count", "blf.file_header.object_count", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1204 { &hf_blf_file_header_app_build,
1205 { "Application Build", "blf.file_header.application_build", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1206 { &hf_blf_file_header_start_date,
1207 { "Start Date", "blf.file_header.start_date", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1208 { &hf_blf_file_header_end_date,
1209 { "End Date", "blf.file_header.end_date", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1210 { &hf_blf_file_header_restore_point_offset,
1211 { "Restore Point Offset", "blf.file_header.restore_point_offset", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1213 { &hf_blf_lobj,
1214 { "Object", "blf.object", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1215 { &hf_blf_lobj_hdr,
1216 { "Object Header", "blf.object.header", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1217 { &hf_blf_lobj_magic,
1218 { "Magic", "blf.object.header.magic", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1219 { &hf_blf_lobj_hdr_len,
1220 { "Header Length", "blf.object.header.header_length", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1221 { &hf_blf_lobj_hdr_type,
1222 { "Header Type", "blf.object.header.header_type", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1223 { &hf_blf_lobj_obj_len,
1224 { "Object Length", "blf.object.header.object_length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1225 { &hf_blf_lobj_obj_type,
1226 { "Object Type", "blf.object.header.object_type", FT_UINT32, BASE_DEC, VALS(blf_object_names), 0x00, NULL, HFILL }},
1227 { &hf_blf_lobj_hdr_remains,
1228 { "Header unparsed", "blf.object.header.unparsed", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1229 { &hf_blf_lobj_payload,
1230 { "Payload", "blf.object.payload", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1232 { &hf_blf_cont_comp_method,
1233 { "Compression Method", "blf.object.logcontainer.compression_method", FT_UINT16, BASE_HEX, VALS(blf_compression_names), 0x00, NULL, HFILL }},
1234 { &hf_blf_cont_res1,
1235 { "Reserved", "blf.object.logcontainer.res1", FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL }},
1236 { &hf_blf_cont_res2,
1237 { "Reserved", "blf.object.logcontainer.res2", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }},
1238 { &hf_blf_cont_uncomp_size,
1239 { "Uncompressed Length", "blf.object.logcontainer.uncompressed_length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1240 { &hf_blf_cont_res4,
1241 { "Reserved", "blf.object.logcontainer.res4", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }},
1242 { &hf_blf_cont_payload,
1243 { "Payload", "blf.object.logcontainer.payload", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1244 { &hf_blf_app_text_source,
1245 { "Source", "blf.object.app_text.source", FT_UINT32, BASE_DEC, VALS(blf_app_text_source_vals), 0x00, NULL, HFILL }},
1246 { &hf_blf_app_text_reservedapptext1,
1247 { "reservedAppText1", "blf.object.app_text.reservedapptext1", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1248 { &hf_blf_app_text_textlength,
1249 { "Text length", "blf.object.app_text.textlength", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1250 { &hf_blf_app_text_reservedapptext2,
1251 { "reservedAppText2", "blf.object.app_text.reservedapptext2", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1252 { &hf_blf_app_text_data_version,
1253 { "Version", "blf.object.app_text.version", FT_UINT32, BASE_DEC, NULL, 0x000000ff, NULL, HFILL }},
1254 { &hf_blf_app_text_channelno,
1255 { "Channel number", "blf.object.app_text.channelno", FT_UINT32, BASE_DEC, NULL, 0x0000ff00, NULL, HFILL }},
1256 { &hf_blf_app_text_busstype,
1257 { "Bus type", "blf.object.app_text.bustype", FT_UINT32, BASE_DEC, VALS(blf_bustype_vals), 0x00ff0000, NULL, HFILL}},
1258 { &hf_blf_app_text_can_fd_channel,
1259 { "CAN FD-Channel", "blf.object.app_text.can_fd_channel", FT_BOOLEAN, 32, NULL, 0x01000000, NULL, HFILL }},
1260 { &hf_blf_app_text_metadata_remaining_length,
1261 { "Remaining length", "blf.object.app_text.remaining_length", FT_UINT32, BASE_DEC, NULL, 0x00ffffff, NULL, HFILL }},
1262 { &hf_blf_app_text_metadata_type,
1263 { "Metadata type", "blf.object.app_text.metadata_type", FT_UINT32, BASE_DEC, VALS(blf_app_text_metadata_type_vals), 0xff000000, NULL, HFILL}},
1264 { &hf_blf_app_text_traceline_source,
1265 { "Metadata type", "blf.object.app_text.traceline_source", FT_UINT32, BASE_DEC, VALS(hf_blf_app_text_traceline_source_vals), 0x0000000f, NULL, HFILL}},
1266 { &hf_blf_app_text_traceline_display_in_tracewindow,
1267 { "Display in trace window", "blf.object.app_text.display_in_tracewindow", FT_BOOLEAN, 32, NULL, 0x00000010, NULL, HFILL}},
1268 { &hf_blf_app_text_traceline_ascii_conversion_wo_comment_indicator_timestamp,
1269 { "ASCII conversion should be done without comment indicator and timestamp", "blf.object.app_text.ascii_conversion_wo_comment_indicator_timestamp", FT_BOOLEAN, 32, NULL, 0x00000020, NULL, HFILL}},
1270 { &hf_blf_app_text_text,
1271 { "Text", "blf.object.app_text.text", FT_STRINGZPAD, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1272 { &hf_blf_trigg_cond_state,
1273 { "State", "blf.object.trigg_con.state", FT_UINT32, BASE_DEC, VALS(blf_trigger_cond_state_vals), 0x00, NULL, HFILL}},
1274 { &hf_blf_trigg_cond_triggerblocknamelength,
1275 { "Trigger blockname length", "blf.object.trigg_con.triggerblocknamelength", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1276 { &hf_blf_trigg_cond_triggerconditionlength,
1277 { "Trigger condition length", "blf.object.trigg_con.triggerconditionlength", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1278 { &hf_blf_trigg_cond_triggerblockname,
1279 { "Trigger blockname", "blf.object.trigg_con.triggerblockname", FT_STRINGZPAD, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1280 { &hf_blf_trigg_cond_triggercondition,
1281 { "Trigger condition", "blf.object.trigg_con.triggercondition", FT_STRINGZPAD, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1282 { &hf_blf_sys_var_type,
1283 { "Type", "blf.object.sys_var.type", FT_UINT32, BASE_DEC, VALS(blf_sys_var_type_vals), 0x00, NULL, HFILL}},
1284 { &hf_blf_sys_var_rep,
1285 { "Representation", "blf.object.sys_var.representation", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1286 { &hf_blf_sys_var_reservedsystemvariable1,
1287 { "Reserved systemvariable 1", "blf.object.sys_var.reservedsystemvariable1", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1288 { &hf_blf_sys_var_namelength,
1289 { "Name length", "blf.object.sys_var.namelength", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL}},
1290 { &hf_blf_sys_var_datalength,
1291 { "Data length", "blf.object.sys_var.datalength", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL}},
1292 { &hf_blf_sys_var_reservedsystemvariable2,
1293 { "Reserved systemvariable 2", "blf.object.sys_var.reservedsystemvariable2", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1294 { &hf_blf_sys_var_name,
1295 { "Name", "blf.object.sys_var.name", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } },
1296 { &hf_blf_sys_var_data,
1297 { "Data", "blf.object.sys_var.data", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL } },
1298 { &hf_blf_eth_status_channel,
1299 { "Channel", "blf.object.eth_status.channel", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1300 { &hf_blf_eth_status_flags1_b0,
1301 { "LinkStatus", "blf.object.eth_status.flags.b0", FT_BOOLEAN, 16, NULL, 0x0001, NULL, HFILL } },
1302 { &hf_blf_eth_status_flags1_b1,
1303 { "Bitrate", "blf.object.eth_status.flags.b1", FT_BOOLEAN, 16, NULL, 0x0002, NULL, HFILL } },
1304 { &hf_blf_eth_status_flags1_b2,
1305 { "EthernetPhy", "blf.object.eth_status.flags.b2", FT_BOOLEAN, 16, NULL, 0x0004, NULL, HFILL } },
1306 { &hf_blf_eth_status_flags1_b3,
1307 { "Duplex", "blf.object.eth_status.flags.b3", FT_BOOLEAN, 16, NULL, 0x0008, NULL, HFILL } },
1308 { &hf_blf_eth_status_flags1_b4,
1309 { "MdiType", "blf.object.eth_status.flags.b4", FT_BOOLEAN, 16, NULL, 0x0010, NULL, HFILL } },
1310 { &hf_blf_eth_status_flags1_b5,
1311 { "Connector", "blf.object.eth_status.flags.b5", FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL } },
1312 { &hf_blf_eth_status_flags1_b6,
1313 { "ClockMode", "blf.object.eth_status.flags.b6", FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL } },
1314 { &hf_blf_eth_status_flags1_b7,
1315 { "BrPair", "blf.object.eth_status.flags.b7", FT_BOOLEAN, 16, NULL, 0x0080, NULL, HFILL } },
1316 { &hf_blf_eth_status_flags1_b8,
1317 { "HardwareChannel", "blf.object.eth_status.flags.b8", FT_BOOLEAN, 16, NULL, 0x0100, NULL, HFILL } },
1318 { &hf_blf_eth_status_flags1_b9,
1319 { "Link up duration", "blf.object.eth_status.flags.b9", FT_BOOLEAN, 16, NULL, 0x0200, NULL, HFILL } },
1320 { &hf_blf_eth_status_linkstatus,
1321 { "Link status", "blf.object.eth_status.linkstatus", FT_UINT8, BASE_DEC, VALS(blf_eth_status_linkstatus_vals), 0x00, NULL, HFILL}},
1322 { &hf_blf_eth_status_ethernetphy,
1323 { "Ethernet PHY", "blf.object.eth_status.ethernetphy", FT_UINT8, BASE_DEC, VALS(blf_eth_status_ethernetphy_vals), 0x00, NULL, HFILL}},
1324 { &hf_blf_eth_status_duplex,
1325 { "Duplex", "blf.object.eth_status.duplex", FT_UINT8, BASE_DEC, VALS(blf_eth_status_duplex_vals), 0x00, NULL, HFILL}},
1326 { &hf_blf_eth_status_mdi,
1327 { "MDI", "blf.object.eth_status.mdi", FT_UINT8, BASE_DEC, VALS(blf_eth_status_mdi_vals), 0x00, NULL, HFILL}},
1328 { &hf_blf_eth_status_connector,
1329 { "Connector", "blf.object.eth_status.connector", FT_UINT8, BASE_DEC, VALS(blf_eth_status_connector_vals), 0x00, NULL, HFILL}},
1330 { &hf_blf_eth_status_clockmode,
1331 { "Clock mode", "blf.object.eth_status.clockmode", FT_UINT8, BASE_DEC, VALS(blf_eth_status_clockmode_vals), 0x00, NULL, HFILL}},
1332 { &hf_blf_eth_status_pairs,
1333 { "Pairs", "blf.object.eth_status.pairs", FT_UINT8, BASE_DEC, VALS(blf_eth_status_pairs_vals), 0x00, NULL, HFILL}},
1334 { &hf_blf_eth_status_hardwarechannel,
1335 { "Hardware channel", "blf.object.eth_status.hardwarechannel", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1336 { &hf_blf_eth_status_bitrate,
1337 { "Bitrate (kbps)", "blf.object.eth_status.bitrate", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1338 { &hf_blf_eth_status_linkupduration,
1339 { "Link up duration (ns)", "blf.object.eth_status.linkupduration", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1340 { &hf_blf_eth_frame_ext_structlength,
1341 { "Struct length", "blf.object.eth_frame_ext.structlength", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1342 { &hf_blf_eth_frame_ext_flags,
1343 { "Flags", "blf.object.eth_frame_ext.flags", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1344 { &hf_blf_eth_frame_ext_channel,
1345 { "Channel", "blf.object.eth_frame_ext.channel", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1346 { &hf_blf_eth_frame_ext_hardwarechannel,
1347 { "Hardware Channel", "blf.object.eth_frame_ext.hardwarechannel", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1348 { &hf_blf_eth_frame_ext_frameduration,
1349 { "Frame duration", "blf.object.eth_frame_ext.frameduration", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1350 { &hf_blf_eth_frame_ext_framechecksum,
1351 { "Frame checksum", "blf.object.eth_frame_ext.framechecksum", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1352 { &hf_blf_eth_frame_ext_dir,
1353 { "Dir", "blf.object.eth_frame_ext.dir", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1354 { &hf_blf_eth_frame_ext_framelength,
1355 { "Frame length", "blf.object.eth_frame_ext.frame_length", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1356 { &hf_blf_eth_frame_ext_framehandle,
1357 { "Frame handle", "blf.object.eth_frame_ext.frame_handle", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1358 { &hf_blf_eth_frame_ext_reservedethernetframeex,
1359 { "Reserved ethernet frame ex", "blf.object.eth_frame_ext.reservedethernetframeex", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1360 { &hf_blf_eth_phystate_channel,
1361 { "Channel", "blf.object.eth_phy_state.channel", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1362 { &hf_blf_eth_phy_state_flags1_b0,
1363 { "PHYState", "blf.object.eth_phy_state.flags.b0", FT_BOOLEAN, 16, NULL, 0x0001, NULL, HFILL } },
1364 { &hf_blf_eth_phy_state_flags1_b1,
1365 { "PHYEvent", "blf.object.eth_phy_state.flags.b1", FT_BOOLEAN, 16, NULL, 0x0002, NULL, HFILL } },
1366 { &hf_blf_eth_phy_state_flags1_b2,
1367 { "HardwareChannel", "blf.object.eth_phy_state.flags.b2", FT_BOOLEAN, 16, NULL, 0x0004, NULL, HFILL } },
1368 { &hf_blf_eth_phy_state_phystate,
1369 { "PHY state", "blf.object.eth_status.phystate", FT_UINT8, BASE_DEC, VALS(blf_eth_phystate_phystate_vals), 0x00, NULL, HFILL} },
1370 { &hf_blf_eth_phy_state_eventstate,
1371 { "Event state", "blf.object.eth_status.eventstate", FT_UINT8, BASE_DEC, VALS(blf_eth_phystate_eventstate_vals), 0x00, NULL, HFILL} },
1372 { &hf_blf_eth_phy_state_hardwarechannel,
1373 { "Hardware channel", "blf.object.eth_status.hardwarechannel", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1374 { &hf_blf_eth_phy_state_res1,
1375 { "Reserved", "blf.object.eth_status.res1", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1378 static ei_register_info ei[] = {
1379 { &ei_blf_file_header_length_too_short,
1380 { "blf.file_header_length_too_short", PI_MALFORMED, PI_ERROR,
1381 "file header length is too short",
1382 EXPFILL }},
1383 { &ei_blf_object_header_length_too_short,
1384 { "blf.object_header_length_too_short", PI_MALFORMED, PI_ERROR,
1385 "object header length is too short",
1386 EXPFILL }},
1387 { &ei_blf_object_length_less_than_header_length,
1388 { "blf.object_length_less_than_header_length", PI_MALFORMED, PI_ERROR,
1389 "object length is less than the object header length",
1390 EXPFILL }},
1393 static int *ett[] = {
1394 &ett_blf,
1395 &ett_blf_header,
1396 &ett_blf_obj,
1397 &ett_blf_obj_header,
1398 &ett_blf_logcontainer_payload,
1399 &ett_blf_app_text_payload,
1402 proto_blf = proto_register_protocol("BLF File Format", "File-BLF", "file-blf");
1403 proto_blf_ethernetstatus_obj = proto_register_protocol("BLF Ethernet Status", "BLF-Ethernet-Status", "blf-ethernet-status");
1404 proto_blf_ethernetphystate_obj = proto_register_protocol("BLF Ethernet PHY State", "BLF-Ethernet-PHY-State", "blf-ethernet-phystate");
1405 expert_blf = expert_register_protocol(proto_blf);
1406 expert_register_field_array(expert_blf, ei, array_length(ei));
1408 proto_register_field_array(proto_blf, hf, array_length(hf));
1409 proto_register_subtree_array(ett, array_length(ett));
1411 register_dissector("file-blf", dissect_blf, proto_blf);
1412 register_dissector("blf-ethernetstatus-obj", dissect_blf_ethernetstatus_obj, proto_blf_ethernetstatus_obj);
1413 register_dissector("blf-ethernetphystate-obj", dissect_blf_ethernetphystate_obj, proto_blf_ethernetphystate_obj);
1416 void
1417 proto_reg_handoff_file_blf(void) {
1418 heur_dissector_add("wtap_file", dissect_blf_heur, "BLF File", "blf_wtap", proto_blf, HEURISTIC_ENABLE);
1419 xml_handle = find_dissector_add_dependency("xml", proto_blf);
1423 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1425 * Local Variables:
1426 * c-basic-offset: 4
1427 * tab-width: 8
1428 * indent-tabs-mode: nil
1429 * End:
1431 * ex: set shiftwidth=4 tabstop=8 expandtab:
1432 * :indentSize=4:tabSize=8:noTabs=true: