dcerpc-netlogon: maintain netlogon_auth_vars for NetrServerAuthenticateKerberos
[wireshark-sm.git] / epan / dissectors / file-blf.c
blob16b0a1da10844e71446d68de903ef41e423d2b00
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 uint8_t major = tvb_get_uint8(tvb, offset + 0);
488 uint8_t minor = tvb_get_uint8(tvb, offset + 1);
489 uint8_t build = tvb_get_uint8(tvb, offset + 2);
490 uint8_t patch = tvb_get_uint8(tvb, offset + 3);
492 header_field_info *hfinfo = proto_registrar_get_nth(hf);
494 return proto_tree_add_bytes_format(tree, hf, tvb, offset, length, NULL, "%s: %d.%d.%d.%d",
495 hfinfo->name, major, minor, build, patch);
498 static int
499 // NOLINTNEXTLINE(misc-no-recursion)
500 dissect_blf_lobj(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset_orig) {
501 proto_item *ti_root = NULL;
502 proto_item *ti = NULL;
503 proto_item *ti_lobj_hdr;
504 proto_tree *objtree = NULL;
505 proto_tree *subtree = NULL;
506 volatile int offset = offset_orig;
507 tvbuff_t *sub_tvb;
509 uint32_t hdr_length;
510 uint32_t obj_length;
511 unsigned obj_type;
512 uint32_t comp_method;
514 /* this should never happen since we should only be called with at least 16 Bytes present */
515 if (tvb_captured_length_remaining(tvb, offset_orig) < 16) {
516 return tvb_captured_length_remaining(tvb, offset_orig);
519 ti_root = proto_tree_add_item(tree, hf_blf_lobj, tvb, offset, -1, ENC_NA);
520 objtree = proto_item_add_subtree(ti_root, ett_blf_obj);
522 ti_lobj_hdr = proto_tree_add_item(objtree, hf_blf_lobj_hdr, tvb, offset, -1, ENC_NA);
523 subtree = proto_item_add_subtree(ti_lobj_hdr, ett_blf_obj);
525 proto_tree_add_item(subtree, hf_blf_lobj_magic, tvb, offset, 4, ENC_NA);
526 offset += 4;
527 ti = proto_tree_add_item_ret_uint(subtree, hf_blf_lobj_hdr_len, tvb, offset, 2, ENC_LITTLE_ENDIAN, &hdr_length);
528 if (hdr_length < sizeof (struct blf_blockheader)) {
529 expert_add_info(pinfo, ti, &ei_blf_object_header_length_too_short);
531 offset += 2;
532 proto_tree_add_item(subtree, hf_blf_lobj_hdr_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);
533 offset += 2;
534 ti = proto_tree_add_item_ret_uint(subtree, hf_blf_lobj_obj_len, tvb, offset, 4, ENC_LITTLE_ENDIAN, &obj_length);
535 if (obj_length < hdr_length) {
536 expert_add_info(pinfo, ti, &ei_blf_object_length_less_than_header_length);
538 offset += 4;
539 proto_tree_add_item_ret_uint(subtree, hf_blf_lobj_obj_type, tvb, offset, 4, ENC_LITTLE_ENDIAN, &obj_type);
540 offset += 4;
541 proto_item_set_end(ti_lobj_hdr, tvb, offset);
543 /* check if the whole object is present or if it was truncated */
544 if (tvb_captured_length_remaining(tvb, offset_orig) < (int)obj_length) {
545 proto_item_set_end(ti_root, tvb, offset_orig + tvb_captured_length_remaining(tvb, offset_orig));
546 proto_item_append_text(ti_root, " TRUNCATED");
547 return tvb_captured_length_remaining(tvb, offset_orig);
550 proto_item_set_end(ti_root, tvb, offset_orig + obj_length);
551 proto_item_append_text(ti_root, " (%s)", val_to_str(obj_type, blf_object_names, "%d"));
553 switch (obj_type) {
554 case BLF_OBJTYPE_LOG_CONTAINER:
555 proto_tree_add_item_ret_uint(objtree, hf_blf_cont_comp_method, tvb, offset, 2, ENC_LITTLE_ENDIAN, &comp_method);
556 offset += 2;
557 proto_tree_add_item(objtree, hf_blf_cont_res1, tvb, offset, 2, ENC_LITTLE_ENDIAN);
558 offset += 2;
559 proto_tree_add_item(objtree, hf_blf_cont_res2, tvb, offset, 4, ENC_LITTLE_ENDIAN);
560 offset += 4;
561 proto_tree_add_item(objtree, hf_blf_cont_uncomp_size, tvb, offset, 4, ENC_LITTLE_ENDIAN);
562 offset += 4;
563 proto_tree_add_item(objtree, hf_blf_cont_res4, tvb, offset, 4, ENC_LITTLE_ENDIAN);
564 offset += 4;
565 if (comp_method == BLF_COMPRESSION_NONE) {
566 sub_tvb = tvb_new_subset_length(tvb, offset, offset_orig + obj_length - offset);
567 } else {
568 sub_tvb = tvb_child_uncompress_zlib(tvb, tvb, offset, offset_orig + obj_length - offset);
569 if (sub_tvb) {
570 add_new_data_source(pinfo, sub_tvb, "Decompressed Data");
574 /* TODO: actually the objects might overlap containers, which we do not consider here... */
575 if (sub_tvb && tvb_captured_length(sub_tvb) > 0) {
576 unsigned offset_sub = 0;
577 ti = proto_tree_add_item(objtree, hf_blf_cont_payload, sub_tvb, 0, offset_orig + obj_length - offset, ENC_NA);
578 subtree = proto_item_add_subtree(ti, ett_blf_logcontainer_payload);
580 unsigned tmp = 42;
581 while ((offset_sub + 16 <= offset_orig + obj_length - offset) && (tmp > 0)) {
582 tmp = dissect_blf_next_object(sub_tvb, pinfo, subtree, offset_sub);
583 offset_sub += tmp;
586 break;
587 case BLF_OBJTYPE_APP_TEXT:
589 unsigned source;
590 unsigned textlength;
591 if (offset - offset_orig < (int)hdr_length) {
592 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
593 offset = offset_orig + hdr_length;
596 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
597 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
599 proto_tree_add_item_ret_uint(subtree, hf_blf_app_text_source, tvb, offset, 4, ENC_LITTLE_ENDIAN, &source);
600 offset += 4;
602 /*uint32_t reservedAppText1 {};*/
603 switch (source) {
604 case BLF_APPTEXT_CHANNEL:
605 /* 1: Database channel information
606 * - reserved contains channel information. The following
607 * - table show how the 4 bytes are used:
608 * - Bit 0-7: Version of the data
609 * - Bit 8-15: Channel number
610 * - Bit 15-23: Bus type of the channel. One of the
611 * following values:
612 * - 1: BL_BUSTYPE_CAN
613 * - 5: BL_BUSTYPE_LIN
614 * - 6: BL_BUSTYPE_MOST
615 * - 7: BL_BUSTYPE_FLEXRAY
616 * - 9: BL_BUSTYPE_J1708
617 * - 10: BL_BUSTYPE_ETHERNET
618 * - 13: BL_BUSTYPE_WLAN
619 * - 14: BL_BUSTYPE_AFDX
620 * - Bit 24: Flag, that determines, if channel is a CAN-
621 * FD channel
622 * - Bit 25-31: Unused at the moment
623 * - text contains database information for the specific
624 * channel. Each database is defined by the database path and
625 * the cluster name (if available). The single databases and the
626 * cluster name are separated by a semicolon. Example:
627 * \<Path1\>;\<ClusterName1\>;\<Path2\>;\<ClusterName2\>;...
628 * If for a database there's no cluster name available, an
629 * empty string is written as cluster name.
631 proto_tree_add_item(subtree, hf_blf_app_text_data_version, tvb, offset, 4, ENC_LITTLE_ENDIAN);
632 proto_tree_add_item(subtree, hf_blf_app_text_channelno, tvb, offset, 4, ENC_LITTLE_ENDIAN);
633 proto_tree_add_item(subtree, hf_blf_app_text_busstype, tvb, offset, 4, ENC_LITTLE_ENDIAN);
634 proto_tree_add_item(subtree, hf_blf_app_text_can_fd_channel, tvb, offset, 4, ENC_LITTLE_ENDIAN);
635 break;
636 case BLF_APPTEXT_METADATA:
637 proto_tree_add_item(subtree, hf_blf_app_text_metadata_remaining_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
638 proto_tree_add_item(subtree, hf_blf_app_text_metadata_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
639 break;
640 case BLF_APPTEXT_TRACELINE:
641 proto_tree_add_item(subtree, hf_blf_app_text_traceline_source, tvb, offset, 4, ENC_LITTLE_ENDIAN);
642 proto_tree_add_item(subtree, hf_blf_app_text_traceline_display_in_tracewindow, tvb, offset, 4, ENC_LITTLE_ENDIAN);
643 proto_tree_add_item(subtree, hf_blf_app_text_traceline_ascii_conversion_wo_comment_indicator_timestamp, tvb, offset, 4, ENC_LITTLE_ENDIAN);
644 break;
645 default:
646 proto_tree_add_item(subtree, hf_blf_app_text_reservedapptext1, tvb, offset, 4, ENC_LITTLE_ENDIAN);
647 break;
649 offset += 4;
650 /*uint32_t textLength {};*/
651 proto_tree_add_item_ret_uint(subtree, hf_blf_app_text_textlength, tvb, offset, 4, ENC_LITTLE_ENDIAN, &textlength);
652 offset += 4;
653 /*uint32_t reservedAppText2 {};*/
654 proto_tree_add_item(subtree, hf_blf_app_text_reservedapptext2, tvb, offset, 4, ENC_LITTLE_ENDIAN);
655 offset += 4;
656 /* If there is less than 38 characters this is not XML
657 * <?xml version="1.0" encoding="UTF-8"?>
659 if ((textlength > 37) && (tvb_strncaseeql(tvb, offset, "<?xml", 5) == 0) &&( xml_handle)) {
660 tvbuff_t* new_tvb = tvb_new_subset_length(tvb, offset, textlength);
661 call_dissector(xml_handle, new_tvb, pinfo, subtree);
662 } else {
663 proto_tree_add_item(subtree, hf_blf_app_text_text, tvb, offset, textlength, ENC_UTF_8|ENC_NA);
666 break;
667 case BLF_OBJTYPE_SYS_VARIABLE:
669 uint32_t namelength;
670 uint32_t datalength;
672 if (offset - offset_orig < (int)hdr_length) {
673 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
674 offset = offset_orig + hdr_length;
677 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
678 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
680 /* uint32_t type {}; */
681 proto_tree_add_item(subtree, hf_blf_sys_var_type, tvb, offset, 4, ENC_LITTLE_ENDIAN);
682 offset += 4;
683 /* uint32_t representation {}; */
684 proto_tree_add_item(subtree, hf_blf_sys_var_rep, tvb, offset, 4, ENC_LITTLE_ENDIAN);
685 offset += 4;
686 /* uint64_t reservedSystemVariable1 {}; */
687 proto_tree_add_item(subtree, hf_blf_sys_var_reservedsystemvariable1, tvb, offset, 8, ENC_LITTLE_ENDIAN);
688 offset += 8;
689 /* uint32_t nameLength {}; */
690 proto_tree_add_item_ret_uint(subtree, hf_blf_sys_var_namelength, tvb, offset, 4, ENC_LITTLE_ENDIAN, &namelength);
691 offset += 4;
692 /* uint32_t dataLength {}; */
693 proto_tree_add_item_ret_uint(subtree, hf_blf_sys_var_datalength, tvb, offset, 4, ENC_LITTLE_ENDIAN, &datalength);
694 offset += 4;
695 /* uint64_t reservedSystemVariable2 {}; */
696 proto_tree_add_item(subtree, hf_blf_sys_var_reservedsystemvariable2, tvb, offset, 8, ENC_LITTLE_ENDIAN);
697 offset += 8;
698 proto_tree_add_item(subtree, hf_blf_sys_var_name, tvb, offset, namelength, ENC_UTF_8 | ENC_NA);
699 offset += namelength;
700 proto_tree_add_item(subtree, hf_blf_sys_var_data, tvb, offset, datalength, ENC_NA);
701 offset += datalength;
703 break;
704 case BLF_OBJTYPE_ETHERNET_STATUS:
706 static int* const flags1[] = {
707 &hf_blf_eth_status_flags1_b9,
708 &hf_blf_eth_status_flags1_b8,
709 &hf_blf_eth_status_flags1_b7,
710 &hf_blf_eth_status_flags1_b6,
711 &hf_blf_eth_status_flags1_b5,
712 &hf_blf_eth_status_flags1_b4,
713 &hf_blf_eth_status_flags1_b3,
714 &hf_blf_eth_status_flags1_b2,
715 &hf_blf_eth_status_flags1_b1,
716 &hf_blf_eth_status_flags1_b0,
717 NULL
719 if (offset - offset_orig < (int)hdr_length) {
720 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
721 offset = offset_orig + hdr_length;
724 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
725 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
727 /* uint16_t channel {}; */
728 proto_tree_add_item(subtree, hf_blf_eth_status_channel, tvb, offset, 2, ENC_LITTLE_ENDIAN);
729 offset += 2;
730 /* uint16_t flags; */
731 proto_tree_add_bitmask_list(subtree, tvb, offset, 2, flags1, ENC_LITTLE_ENDIAN);
732 offset += 2;
733 /* uint8_t linkStatus {}; */
734 proto_tree_add_item(subtree, hf_blf_eth_status_linkstatus, tvb, offset, 1, ENC_LITTLE_ENDIAN);
735 offset += 1;
736 /* uint8_t ethernetPhy {};*/
737 proto_tree_add_item(subtree, hf_blf_eth_status_ethernetphy, tvb, offset, 1, ENC_LITTLE_ENDIAN);
738 offset += 1;
739 /* uint8_t duplex {}; */
740 proto_tree_add_item(subtree, hf_blf_eth_status_duplex, tvb, offset, 1, ENC_LITTLE_ENDIAN);
741 offset += 1;
742 /* uint8_t mdi {}; */
743 proto_tree_add_item(subtree, hf_blf_eth_status_mdi, tvb, offset, 1, ENC_LITTLE_ENDIAN);
744 offset += 1;
745 /* uint8_t connector {};*/
746 proto_tree_add_item(subtree, hf_blf_eth_status_connector, tvb, offset, 1, ENC_LITTLE_ENDIAN);
747 offset += 1;
748 /* uint8_t clockMode {}; */
749 proto_tree_add_item(subtree, hf_blf_eth_status_clockmode, tvb, offset, 1, ENC_LITTLE_ENDIAN);
750 offset += 1;
751 /* uint8_t pairs {}; */
752 proto_tree_add_item(subtree, hf_blf_eth_status_pairs, tvb, offset, 1, ENC_LITTLE_ENDIAN);
753 offset += 1;
754 /* uint8_t hardwareChannel {};*/
755 proto_tree_add_item(subtree, hf_blf_eth_status_hardwarechannel, tvb, offset, 1, ENC_LITTLE_ENDIAN);
756 offset += 1;
757 /* uint32_t bitrate {}; */
758 proto_tree_add_item(subtree, hf_blf_eth_status_bitrate, tvb, offset, 4, ENC_LITTLE_ENDIAN);
759 offset += 4;
760 if (offset_orig + obj_length - offset >= 8) {
761 proto_tree_add_item(subtree, hf_blf_eth_status_linkupduration, tvb, offset, 8, ENC_LITTLE_ENDIAN);
764 break;
765 case BLF_OBJTYPE_ETHERNET_FRAME_EX:
767 if (offset - offset_orig < (int)hdr_length) {
768 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
769 offset = offset_orig + hdr_length;
772 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
773 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
775 /* uint16_t structLength {}; */
776 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_structlength, tvb, offset, 2, ENC_LITTLE_ENDIAN);
777 offset += 2;
778 /* uint16_t flags {}; */
779 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN);
780 offset += 2;
781 /* uint16_t channel {}; */
782 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_channel, tvb, offset, 2, ENC_LITTLE_ENDIAN);
783 offset += 2;
784 /* uint16_t hardwareChannel {}; */
785 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_hardwarechannel, tvb, offset, 2, ENC_LITTLE_ENDIAN);
786 offset += 2;
787 /* uint64_t frameDuration {}; */
788 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_frameduration, tvb, offset, 8, ENC_LITTLE_ENDIAN);
789 offset += 8;
790 /* uint32_t frameChecksum {}; */
791 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_framechecksum, tvb, offset, 4, ENC_LITTLE_ENDIAN);
792 offset += 4;
793 /* uint16_t dir {}; */
794 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_dir, tvb, offset, 2, ENC_LITTLE_ENDIAN);
795 offset += 2;
796 /* uint16_t frameLength {}; */
797 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_framelength, tvb, offset, 2, ENC_LITTLE_ENDIAN);
798 offset += 2;
799 /* uint32_t frameHandle {}; */
800 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_framehandle, tvb, offset, 4, ENC_LITTLE_ENDIAN);
801 offset += 4;
802 /* uint32_t reservedEthernetFrameEx {}; */
803 proto_tree_add_item(subtree, hf_blf_eth_frame_ext_reservedethernetframeex, tvb, offset, 4, ENC_LITTLE_ENDIAN);
804 offset += 4;
806 break;
807 case BLF_OBJTYPE_TRIGGER_CONDITION:
809 uint32_t triggerblocknamelength;
810 uint32_t triggerconditionlength;
812 if (offset - offset_orig < (int)hdr_length) {
813 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
814 offset = offset_orig + hdr_length;
817 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
818 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
820 /* uint32_t state {}; */
821 proto_tree_add_item(subtree, hf_blf_trigg_cond_state, tvb, offset, 4, ENC_LITTLE_ENDIAN);
822 offset += 4;
823 /* uint32_t triggerBlockNameLength {}; */
824 proto_tree_add_item_ret_uint(subtree, hf_blf_trigg_cond_triggerblocknamelength, tvb, offset, 4, ENC_LITTLE_ENDIAN,&triggerblocknamelength);
825 offset += 4;
826 /* uint32_t triggerConditionLength {};*/
827 proto_tree_add_item_ret_uint(subtree, hf_blf_trigg_cond_triggerconditionlength, tvb, offset, 4, ENC_LITTLE_ENDIAN, &triggerconditionlength);
828 offset += 4;
829 /* std::string triggerBlockName {};*/
830 proto_tree_add_item(subtree, hf_blf_trigg_cond_triggerblockname, tvb, offset, triggerblocknamelength, ENC_UTF_8 | ENC_NA);
831 offset += triggerblocknamelength;
832 /* std::string triggerCondition {};*/
833 proto_tree_add_item(subtree, hf_blf_trigg_cond_triggercondition, tvb, offset, triggerconditionlength, ENC_UTF_8 | ENC_NA);
834 offset += triggerconditionlength;
836 break;
837 case BLF_OBJTYPE_ETHERNET_PHY_STATE:
839 static int* const flags1[] = {
840 &hf_blf_eth_phy_state_flags1_b2,
841 &hf_blf_eth_phy_state_flags1_b1,
842 &hf_blf_eth_phy_state_flags1_b0,
843 NULL
845 if (offset - offset_orig < (int)hdr_length) {
846 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
847 offset = offset_orig + hdr_length;
850 ti = proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
851 subtree = proto_item_add_subtree(ti, ett_blf_app_text_payload);
853 /* uint16_t channel {}; */
854 proto_tree_add_item(subtree, hf_blf_eth_phystate_channel, tvb, offset, 2, ENC_BIG_ENDIAN);
855 offset += 2;
856 /* uint16_t flags; */
857 proto_tree_add_bitmask_list(subtree, tvb, offset, 2, flags1, ENC_BIG_ENDIAN);
858 offset += 2;
859 /* uint8_t phyState {}; */
860 proto_tree_add_item(subtree, hf_blf_eth_phy_state_phystate, tvb, offset, 1, ENC_BIG_ENDIAN);
861 offset += 1;
862 /* uint8_t eventState {}; */
863 proto_tree_add_item(subtree, hf_blf_eth_phy_state_eventstate, tvb, offset, 1, ENC_BIG_ENDIAN);
864 offset += 1;
865 /* uint8_t hardwareChannel {}; */
866 proto_tree_add_item(subtree, hf_blf_eth_phy_state_hardwarechannel, tvb, offset, 1, ENC_BIG_ENDIAN);
867 offset += 1;
868 /* uint8_t res1 {}; */
869 proto_tree_add_item(subtree, hf_blf_eth_phy_state_res1, tvb, offset, 1, ENC_BIG_ENDIAN);
870 offset += 1;
872 break;
873 default:
874 if (offset - offset_orig < (int)hdr_length) {
875 proto_tree_add_item(subtree, hf_blf_lobj_hdr_remains, tvb, offset, hdr_length - (offset - offset_orig), ENC_NA);
876 offset = offset_orig + hdr_length;
879 proto_tree_add_item(objtree, hf_blf_lobj_payload, tvb, offset, obj_length - hdr_length, ENC_NA);
880 offset = offset_orig + obj_length;
881 break;
884 return (int)obj_length;
887 static int
888 // NOLINTNEXTLINE(misc-no-recursion)
889 dissect_blf_next_object(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) {
890 int offset_orig = offset;
892 while (tvb_captured_length_remaining(tvb, offset) >= 16) {
893 if (tvb_memeql(tvb, offset, blf_lobj_magic, MAGIC_NUMBER_SIZE) != 0) {
894 offset += 1;
895 } else {
896 increment_dissection_depth(pinfo);
897 int bytes_parsed = dissect_blf_lobj(tvb, pinfo, tree, offset);
898 decrement_dissection_depth(pinfo);
899 if (bytes_parsed <= 0) {
900 return 0;
901 } else {
902 offset += bytes_parsed;
907 return offset - offset_orig;
911 static int
912 dissect_blf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) {
913 volatile int offset = 0;
914 proto_tree *blf_tree;
915 uint32_t header_length;
916 proto_tree *subtree;
917 proto_item *ti;
918 unsigned length;
920 if (tvb_captured_length(tvb) < 8 || tvb_memeql(tvb, 0, blf_file_magic, MAGIC_NUMBER_SIZE) != 0) {
921 /* does not start with LOGG, so this is not BLF it seems */
922 return 0;
925 ti = proto_tree_add_item(tree, proto_blf, tvb, offset, -1, ENC_NA);
926 blf_tree = proto_item_add_subtree(ti, ett_blf);
927 length = tvb_get_uint32(tvb, 4, ENC_LITTLE_ENDIAN);
929 ti = proto_tree_add_item(blf_tree, hf_blf_file_header, tvb, offset, length, ENC_NA);
930 subtree = proto_item_add_subtree(ti, ett_blf_header);
932 proto_tree_add_item(subtree, hf_blf_file_header_magic, tvb, offset, 4, ENC_NA);
933 offset += 4;
934 ti = proto_tree_add_item_ret_uint(subtree, hf_blf_file_header_length, tvb, offset, 4, ENC_LITTLE_ENDIAN, &header_length);
935 if (header_length < sizeof (struct blf_fileheader)) {
936 expert_add_info(pinfo, ti, &ei_blf_file_header_length_too_short);
938 offset += 4;
939 dissect_blf_api_version(subtree, hf_blf_file_header_api, tvb, offset, 4);
940 offset += 4;
941 proto_tree_add_item(subtree, hf_blf_file_header_app, tvb, offset, 1, ENC_NA);
942 offset += 1;
943 proto_tree_add_item(subtree, hf_blf_file_header_comp_level, tvb, offset, 1, ENC_NA);
944 offset += 1;
945 proto_tree_add_item(subtree, hf_blf_file_header_app_major, tvb, offset, 1, ENC_NA);
946 offset += 1;
947 proto_tree_add_item(subtree, hf_blf_file_header_app_minor, tvb, offset, 1, ENC_NA);
948 offset += 1;
949 proto_tree_add_item(subtree, hf_blf_file_header_len_comp, tvb, offset, 8, ENC_LITTLE_ENDIAN);
950 offset += 8;
951 proto_tree_add_item(subtree, hf_blf_file_header_len_uncomp, tvb, offset, 8, ENC_LITTLE_ENDIAN);
952 offset += 8;
953 proto_tree_add_item(subtree, hf_blf_file_header_obj_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
954 offset += 4;
955 proto_tree_add_item(subtree, hf_blf_file_header_app_build, tvb, offset, 4, ENC_LITTLE_ENDIAN);
956 offset += 4;
957 dissect_blf_header_date(subtree, hf_blf_file_header_start_date, tvb, offset, 16);
958 offset += 16;
959 dissect_blf_header_date(subtree, hf_blf_file_header_end_date, tvb, offset, 16);
960 offset += 16;
961 proto_tree_add_item(subtree, hf_blf_file_header_restore_point_offset, tvb, offset, 4, ENC_LITTLE_ENDIAN);
962 offset += 8;
964 offset += dissect_blf_next_object(tvb, pinfo, blf_tree, offset);
966 return offset;
969 static bool
970 dissect_blf_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
971 return dissect_blf(tvb, pinfo, tree, data) > 0;
974 static int
975 dissect_blf_ethernetstatus_obj(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) {
976 proto_item *ti;
977 proto_tree* blf_tree;
978 int offset = 0;
980 static int* const flags1[] = {
981 &hf_blf_eth_status_flags1_b9,
982 &hf_blf_eth_status_flags1_b8,
983 &hf_blf_eth_status_flags1_b7,
984 &hf_blf_eth_status_flags1_b6,
985 &hf_blf_eth_status_flags1_b5,
986 &hf_blf_eth_status_flags1_b4,
987 &hf_blf_eth_status_flags1_b3,
988 &hf_blf_eth_status_flags1_b2,
989 &hf_blf_eth_status_flags1_b1,
990 &hf_blf_eth_status_flags1_b0,
991 NULL
994 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLF Ethernet Status");
995 col_clear(pinfo->cinfo, COL_INFO);
997 ti = proto_tree_add_item(tree, proto_blf_ethernetstatus_obj, tvb, offset, -1, ENC_NA);
998 blf_tree = proto_item_add_subtree(ti, ett_blf);
1000 /* uint16_t channel {}; */
1001 uint32_t channel;
1002 proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_status_channel, tvb, offset, 2, ENC_BIG_ENDIAN, &channel);
1003 offset += 2;
1004 /* uint16_t flags; */
1005 uint16_t flags = tvb_get_ntohs(tvb, offset);
1006 proto_tree_add_bitmask_list(blf_tree, tvb, offset, 2, flags1, ENC_BIG_ENDIAN);
1007 offset += 2;
1009 /* uint8_t linkStatus {}; */
1010 uint32_t linkstatus;
1011 ti = proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_status_linkstatus, tvb, offset, 1, ENC_BIG_ENDIAN, &linkstatus);
1012 if ((flags & BLF_ETH_STATUS_LINKSTATUS) == 0) {
1013 proto_item_append_text(ti, " - Invalid");
1015 offset += 1;
1017 /* uint8_t ethernetPhy {};*/
1018 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_ethernetphy, tvb, offset, 1, ENC_BIG_ENDIAN);
1019 if ((flags & BLF_ETH_STATUS_ETHERNETPHY) == 0) {
1020 proto_item_append_text(ti, " - Invalid");
1022 offset += 1;
1024 /* uint8_t duplex {}; */
1025 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_duplex, tvb, offset, 1, ENC_BIG_ENDIAN);
1026 if ((flags & BLF_ETH_STATUS_DUPLEX) == 0) {
1027 proto_item_append_text(ti, " - Invalid");
1029 offset += 1;
1031 /* uint8_t mdi {}; */
1032 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_mdi, tvb, offset, 1, ENC_BIG_ENDIAN);
1033 if ((flags & BLF_ETH_STATUS_MDITYPE) == 0) {
1034 proto_item_append_text(ti, " - Invalid");
1036 offset += 1;
1038 /* uint8_t connector {};*/
1039 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_connector, tvb, offset, 1, ENC_BIG_ENDIAN);
1040 if ((flags & BLF_ETH_STATUS_CONNECTOR) == 0) {
1041 proto_item_append_text(ti, " - Invalid");
1043 offset += 1;
1045 /* uint8_t clockMode {}; */
1046 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_clockmode, tvb, offset, 1, ENC_BIG_ENDIAN);
1047 if ((flags & BLF_ETH_STATUS_CLOCKMODE) == 0) {
1048 proto_item_append_text(ti, " - Invalid");
1050 offset += 1;
1052 /* uint8_t pairs {}; */
1053 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_pairs, tvb, offset, 1, ENC_BIG_ENDIAN);
1054 if ((flags & BLF_ETH_STATUS_BRPAIR) == 0) {
1055 proto_item_append_text(ti, " - Invalid");
1057 offset += 1;
1059 /* uint8_t hardwareChannel {};*/
1060 uint32_t hardwarechannel;
1061 ti = proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_status_hardwarechannel, tvb, offset, 1, ENC_BIG_ENDIAN, &hardwarechannel);
1062 if ((flags & BLF_ETH_STATUS_HARDWARECHANNEL) == 0) {
1063 proto_item_append_text(ti, " - Invalid");
1065 offset += 1;
1067 /* uint32_t bitrate {}; */
1068 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_bitrate, tvb, offset, 4, ENC_BIG_ENDIAN);
1069 if ((flags & BLF_ETH_STATUS_BITRATE) == 0) {
1070 proto_item_append_text(ti, " - Invalid");
1072 offset += 4;
1074 if ((int)tvb_captured_length(tvb) >= offset + 8) {
1075 /* uint64_t linkUpDuration {}; */
1076 ti = proto_tree_add_item(blf_tree, hf_blf_eth_status_linkupduration, tvb, offset, 8, ENC_BIG_ENDIAN);
1077 if ((flags & BLF_ETH_STATUS_LINKUPDURATION) == 0) {
1078 proto_item_append_text(ti, " - Invalid");
1082 if ((flags & BLF_ETH_STATUS_LINKSTATUS) != 0) {
1083 if ((flags & BLF_ETH_STATUS_HARDWARECHANNEL) == 0) {
1084 col_add_fstr(pinfo->cinfo, COL_INFO, "ETH-%u %s", channel, val_to_str_const(linkstatus, blf_eth_status_linkstatus_vals, "Unknown"));
1085 } else {
1086 col_add_fstr(pinfo->cinfo, COL_INFO, "ETH-%u-%u %s", channel, hardwarechannel, val_to_str_const(linkstatus, blf_eth_status_linkstatus_vals, "Unknown"));
1090 return tvb_reported_length(tvb);
1093 static int
1094 dissect_blf_ethernetphystate_obj(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_) {
1095 proto_item* ti;
1096 proto_tree* blf_tree;
1097 int offset = 0;
1099 static int* const flags1[] = {
1100 &hf_blf_eth_phy_state_flags1_b2,
1101 &hf_blf_eth_phy_state_flags1_b1,
1102 &hf_blf_eth_phy_state_flags1_b0,
1103 NULL
1106 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BLF Ethernet PHY State");
1107 col_clear(pinfo->cinfo, COL_INFO);
1109 ti = proto_tree_add_item(tree, proto_blf_ethernetphystate_obj, tvb, offset, -1, ENC_NA);
1110 blf_tree = proto_item_add_subtree(ti, ett_blf);
1112 /* uint16_t channel {}; */
1113 uint32_t channel;
1114 proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_phystate_channel, tvb, offset, 2, ENC_BIG_ENDIAN, &channel);
1115 offset += 2;
1117 /* uint16_t flags; */
1118 uint16_t flags = tvb_get_ntohs(tvb, offset);
1119 proto_tree_add_bitmask_list(blf_tree, tvb, offset, 2, flags1, ENC_BIG_ENDIAN);
1120 offset += 2;
1122 /* uint8_t phyState {}; */
1123 uint32_t phyState;
1124 ti = proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_phy_state_phystate, tvb, offset, 1, ENC_BIG_ENDIAN, &phyState);
1125 if ((flags & BLF_PHY_STATE_PHYSTATE) == 0) {
1126 proto_item_append_text(ti, " - Invalid");
1128 offset += 1;
1130 /* uint8_t eventState {}; */
1131 uint32_t eventState;
1132 ti = proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_phy_state_eventstate, tvb, offset, 1, ENC_BIG_ENDIAN, &eventState);
1133 if ((flags & BLF_PHY_STATE_PHYEVENT) == 0) {
1134 proto_item_append_text(ti, " - Invalid");
1136 offset += 1;
1138 /* uint8_t hardwareChannel {}; */
1139 uint32_t hardwareChannel;
1140 ti = proto_tree_add_item_ret_uint(blf_tree, hf_blf_eth_phy_state_hardwarechannel, tvb, offset, 1, ENC_BIG_ENDIAN, &hardwareChannel);
1141 if ((flags & BLF_PHY_STATE_HARDWARECHANNEL) == 0) {
1142 proto_item_append_text(ti, " - Invalid");
1144 offset += 1;
1146 /* uint8_t res1 {}; */
1147 proto_tree_add_item(blf_tree, hf_blf_eth_phy_state_res1, tvb, offset, 1, ENC_BIG_ENDIAN);
1149 if ((flags & (BLF_PHY_STATE_PHYSTATE | BLF_PHY_STATE_PHYEVENT)) != 0) {
1150 /* One of the two is valid */
1151 if ((flags & BLF_PHY_STATE_HARDWARECHANNEL) == 0) {
1152 col_add_fstr(pinfo->cinfo, COL_INFO, "ETH-%u", channel);
1154 else {
1155 col_add_fstr(pinfo->cinfo, COL_INFO, "ETH-%u-%u", channel, hardwareChannel);
1157 if ((flags & BLF_PHY_STATE_PHYSTATE) != 0) {
1158 col_append_fstr(pinfo->cinfo, COL_INFO, " - State: %s", val_to_str_const(phyState, blf_eth_phystate_phystate_vals, "Unknown"));
1160 if ((flags & BLF_PHY_STATE_PHYEVENT) != 0) {
1161 col_append_fstr(pinfo->cinfo, COL_INFO, " - Event: %s", val_to_str_const(eventState, blf_eth_phystate_eventstate_vals, "Unknown"));
1165 return tvb_reported_length(tvb);
1169 void
1170 proto_register_file_blf(void) {
1171 expert_module_t *expert_blf;
1173 static hf_register_info hf[] = {
1174 { &hf_blf_file_header,
1175 { "File Header", "blf.file_header", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1176 { &hf_blf_file_header_magic,
1177 { "Magic", "blf.file_header.magic", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1178 { &hf_blf_file_header_length,
1179 { "Header Length", "blf.file_header.length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1180 { &hf_blf_file_header_api,
1181 { "API Version", "blf.file_header.api", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1182 { &hf_blf_file_header_app,
1183 { "Application", "blf.file_header.application", FT_UINT8, BASE_DEC, VALS(application_names), 0x00, NULL, HFILL }},
1184 { &hf_blf_file_header_comp_level,
1185 { "Compression Level", "blf.file_header.compression_level", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1186 { &hf_blf_file_header_app_major,
1187 { "Application Major Version", "blf.file_header.application_major", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1188 { &hf_blf_file_header_app_minor,
1189 { "Application Minor Version", "blf.file_header.application_minor", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1190 { &hf_blf_file_header_len_comp,
1191 { "Length (compressed)", "blf.file_header.length_compressed", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1192 { &hf_blf_file_header_len_uncomp,
1193 { "Length (uncompressed)", "blf.file_header.length_uncompressed", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1194 { &hf_blf_file_header_obj_count,
1195 { "Object Count", "blf.file_header.object_count", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1196 { &hf_blf_file_header_app_build,
1197 { "Application Build", "blf.file_header.application_build", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1198 { &hf_blf_file_header_start_date,
1199 { "Start Date", "blf.file_header.start_date", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1200 { &hf_blf_file_header_end_date,
1201 { "End Date", "blf.file_header.end_date", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1202 { &hf_blf_file_header_restore_point_offset,
1203 { "Restore Point Offset", "blf.file_header.restore_point_offset", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1205 { &hf_blf_lobj,
1206 { "Object", "blf.object", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1207 { &hf_blf_lobj_hdr,
1208 { "Object Header", "blf.object.header", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1209 { &hf_blf_lobj_magic,
1210 { "Magic", "blf.object.header.magic", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1211 { &hf_blf_lobj_hdr_len,
1212 { "Header Length", "blf.object.header.header_length", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1213 { &hf_blf_lobj_hdr_type,
1214 { "Header Type", "blf.object.header.header_type", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1215 { &hf_blf_lobj_obj_len,
1216 { "Object Length", "blf.object.header.object_length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1217 { &hf_blf_lobj_obj_type,
1218 { "Object Type", "blf.object.header.object_type", FT_UINT32, BASE_DEC, VALS(blf_object_names), 0x00, NULL, HFILL }},
1219 { &hf_blf_lobj_hdr_remains,
1220 { "Header unparsed", "blf.object.header.unparsed", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1221 { &hf_blf_lobj_payload,
1222 { "Payload", "blf.object.payload", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1224 { &hf_blf_cont_comp_method,
1225 { "Compression Method", "blf.object.logcontainer.compression_method", FT_UINT16, BASE_HEX, VALS(blf_compression_names), 0x00, NULL, HFILL }},
1226 { &hf_blf_cont_res1,
1227 { "Reserved", "blf.object.logcontainer.res1", FT_UINT16, BASE_HEX, NULL, 0x00, NULL, HFILL }},
1228 { &hf_blf_cont_res2,
1229 { "Reserved", "blf.object.logcontainer.res2", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }},
1230 { &hf_blf_cont_uncomp_size,
1231 { "Uncompressed Length", "blf.object.logcontainer.uncompressed_length", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1232 { &hf_blf_cont_res4,
1233 { "Reserved", "blf.object.logcontainer.res4", FT_UINT32, BASE_HEX, NULL, 0x00, NULL, HFILL }},
1234 { &hf_blf_cont_payload,
1235 { "Payload", "blf.object.logcontainer.payload", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1236 { &hf_blf_app_text_source,
1237 { "Source", "blf.object.app_text.source", FT_UINT32, BASE_DEC, VALS(blf_app_text_source_vals), 0x00, NULL, HFILL }},
1238 { &hf_blf_app_text_reservedapptext1,
1239 { "reservedAppText1", "blf.object.app_text.reservedapptext1", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1240 { &hf_blf_app_text_textlength,
1241 { "Text length", "blf.object.app_text.textlength", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1242 { &hf_blf_app_text_reservedapptext2,
1243 { "reservedAppText2", "blf.object.app_text.reservedapptext2", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1244 { &hf_blf_app_text_data_version,
1245 { "Version", "blf.object.app_text.version", FT_UINT32, BASE_DEC, NULL, 0x000000ff, NULL, HFILL }},
1246 { &hf_blf_app_text_channelno,
1247 { "Channel number", "blf.object.app_text.channelno", FT_UINT32, BASE_DEC, NULL, 0x0000ff00, NULL, HFILL }},
1248 { &hf_blf_app_text_busstype,
1249 { "Bus type", "blf.object.app_text.bustype", FT_UINT32, BASE_DEC, VALS(blf_bustype_vals), 0x00ff0000, NULL, HFILL}},
1250 { &hf_blf_app_text_can_fd_channel,
1251 { "CAN FD-Channel", "blf.object.app_text.can_fd_channel", FT_BOOLEAN, 32, NULL, 0x01000000, NULL, HFILL }},
1252 { &hf_blf_app_text_metadata_remaining_length,
1253 { "Remaining length", "blf.object.app_text.remaining_length", FT_UINT32, BASE_DEC, NULL, 0x00ffffff, NULL, HFILL }},
1254 { &hf_blf_app_text_metadata_type,
1255 { "Metadata type", "blf.object.app_text.metadata_type", FT_UINT32, BASE_DEC, VALS(blf_app_text_metadata_type_vals), 0xff000000, NULL, HFILL}},
1256 { &hf_blf_app_text_traceline_source,
1257 { "Metadata type", "blf.object.app_text.traceline_source", FT_UINT32, BASE_DEC, VALS(hf_blf_app_text_traceline_source_vals), 0x0000000f, NULL, HFILL}},
1258 { &hf_blf_app_text_traceline_display_in_tracewindow,
1259 { "Display in trace window", "blf.object.app_text.display_in_tracewindow", FT_BOOLEAN, 32, NULL, 0x00000010, NULL, HFILL}},
1260 { &hf_blf_app_text_traceline_ascii_conversion_wo_comment_indicator_timestamp,
1261 { "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}},
1262 { &hf_blf_app_text_text,
1263 { "Text", "blf.object.app_text.text", FT_STRINGZPAD, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1264 { &hf_blf_trigg_cond_state,
1265 { "State", "blf.object.trigg_con.state", FT_UINT32, BASE_DEC, VALS(blf_trigger_cond_state_vals), 0x00, NULL, HFILL}},
1266 { &hf_blf_trigg_cond_triggerblocknamelength,
1267 { "Trigger blockname length", "blf.object.trigg_con.triggerblocknamelength", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1268 { &hf_blf_trigg_cond_triggerconditionlength,
1269 { "Trigger condition length", "blf.object.trigg_con.triggerconditionlength", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1270 { &hf_blf_trigg_cond_triggerblockname,
1271 { "Trigger blockname", "blf.object.trigg_con.triggerblockname", FT_STRINGZPAD, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1272 { &hf_blf_trigg_cond_triggercondition,
1273 { "Trigger condition", "blf.object.trigg_con.triggercondition", FT_STRINGZPAD, BASE_NONE, NULL, 0x00, NULL, HFILL }},
1274 { &hf_blf_sys_var_type,
1275 { "Type", "blf.object.sys_var.type", FT_UINT32, BASE_DEC, VALS(blf_sys_var_type_vals), 0x00, NULL, HFILL}},
1276 { &hf_blf_sys_var_rep,
1277 { "Representation", "blf.object.sys_var.representation", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1278 { &hf_blf_sys_var_reservedsystemvariable1,
1279 { "Reserved systemvariable 1", "blf.object.sys_var.reservedsystemvariable1", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1280 { &hf_blf_sys_var_namelength,
1281 { "Name length", "blf.object.sys_var.namelength", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL}},
1282 { &hf_blf_sys_var_datalength,
1283 { "Data length", "blf.object.sys_var.datalength", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL}},
1284 { &hf_blf_sys_var_reservedsystemvariable2,
1285 { "Reserved systemvariable 2", "blf.object.sys_var.reservedsystemvariable2", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL }},
1286 { &hf_blf_sys_var_name,
1287 { "Name", "blf.object.sys_var.name", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } },
1288 { &hf_blf_sys_var_data,
1289 { "Data", "blf.object.sys_var.data", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL } },
1290 { &hf_blf_eth_status_channel,
1291 { "Channel", "blf.object.eth_status.channel", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1292 { &hf_blf_eth_status_flags1_b0,
1293 { "LinkStatus", "blf.object.eth_status.flags.b0", FT_BOOLEAN, 16, NULL, 0x0001, NULL, HFILL } },
1294 { &hf_blf_eth_status_flags1_b1,
1295 { "Bitrate", "blf.object.eth_status.flags.b1", FT_BOOLEAN, 16, NULL, 0x0002, NULL, HFILL } },
1296 { &hf_blf_eth_status_flags1_b2,
1297 { "EthernetPhy", "blf.object.eth_status.flags.b2", FT_BOOLEAN, 16, NULL, 0x0004, NULL, HFILL } },
1298 { &hf_blf_eth_status_flags1_b3,
1299 { "Duplex", "blf.object.eth_status.flags.b3", FT_BOOLEAN, 16, NULL, 0x0008, NULL, HFILL } },
1300 { &hf_blf_eth_status_flags1_b4,
1301 { "MdiType", "blf.object.eth_status.flags.b4", FT_BOOLEAN, 16, NULL, 0x0010, NULL, HFILL } },
1302 { &hf_blf_eth_status_flags1_b5,
1303 { "Connector", "blf.object.eth_status.flags.b5", FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL } },
1304 { &hf_blf_eth_status_flags1_b6,
1305 { "ClockMode", "blf.object.eth_status.flags.b6", FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL } },
1306 { &hf_blf_eth_status_flags1_b7,
1307 { "BrPair", "blf.object.eth_status.flags.b7", FT_BOOLEAN, 16, NULL, 0x0080, NULL, HFILL } },
1308 { &hf_blf_eth_status_flags1_b8,
1309 { "HardwareChannel", "blf.object.eth_status.flags.b8", FT_BOOLEAN, 16, NULL, 0x0100, NULL, HFILL } },
1310 { &hf_blf_eth_status_flags1_b9,
1311 { "Link up duration", "blf.object.eth_status.flags.b9", FT_BOOLEAN, 16, NULL, 0x0200, NULL, HFILL } },
1312 { &hf_blf_eth_status_linkstatus,
1313 { "Link status", "blf.object.eth_status.linkstatus", FT_UINT8, BASE_DEC, VALS(blf_eth_status_linkstatus_vals), 0x00, NULL, HFILL}},
1314 { &hf_blf_eth_status_ethernetphy,
1315 { "Ethernet PHY", "blf.object.eth_status.ethernetphy", FT_UINT8, BASE_DEC, VALS(blf_eth_status_ethernetphy_vals), 0x00, NULL, HFILL}},
1316 { &hf_blf_eth_status_duplex,
1317 { "Duplex", "blf.object.eth_status.duplex", FT_UINT8, BASE_DEC, VALS(blf_eth_status_duplex_vals), 0x00, NULL, HFILL}},
1318 { &hf_blf_eth_status_mdi,
1319 { "MDI", "blf.object.eth_status.mdi", FT_UINT8, BASE_DEC, VALS(blf_eth_status_mdi_vals), 0x00, NULL, HFILL}},
1320 { &hf_blf_eth_status_connector,
1321 { "Connector", "blf.object.eth_status.connector", FT_UINT8, BASE_DEC, VALS(blf_eth_status_connector_vals), 0x00, NULL, HFILL}},
1322 { &hf_blf_eth_status_clockmode,
1323 { "Clock mode", "blf.object.eth_status.clockmode", FT_UINT8, BASE_DEC, VALS(blf_eth_status_clockmode_vals), 0x00, NULL, HFILL}},
1324 { &hf_blf_eth_status_pairs,
1325 { "Pairs", "blf.object.eth_status.pairs", FT_UINT8, BASE_DEC, VALS(blf_eth_status_pairs_vals), 0x00, NULL, HFILL}},
1326 { &hf_blf_eth_status_hardwarechannel,
1327 { "Hardware channel", "blf.object.eth_status.hardwarechannel", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1328 { &hf_blf_eth_status_bitrate,
1329 { "Bitrate (kbps)", "blf.object.eth_status.bitrate", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1330 { &hf_blf_eth_status_linkupduration,
1331 { "Link up duration (ns)", "blf.object.eth_status.linkupduration", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1332 { &hf_blf_eth_frame_ext_structlength,
1333 { "Struct length", "blf.object.eth_frame_ext.structlength", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1334 { &hf_blf_eth_frame_ext_flags,
1335 { "Flags", "blf.object.eth_frame_ext.flags", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1336 { &hf_blf_eth_frame_ext_channel,
1337 { "Channel", "blf.object.eth_frame_ext.channel", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1338 { &hf_blf_eth_frame_ext_hardwarechannel,
1339 { "Hardware Channel", "blf.object.eth_frame_ext.hardwarechannel", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1340 { &hf_blf_eth_frame_ext_frameduration,
1341 { "Frame duration", "blf.object.eth_frame_ext.frameduration", FT_UINT64, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1342 { &hf_blf_eth_frame_ext_framechecksum,
1343 { "Frame checksum", "blf.object.eth_frame_ext.framechecksum", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1344 { &hf_blf_eth_frame_ext_dir,
1345 { "Dir", "blf.object.eth_frame_ext.dir", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1346 { &hf_blf_eth_frame_ext_framelength,
1347 { "Frame length", "blf.object.eth_frame_ext.frame_length", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1348 { &hf_blf_eth_frame_ext_framehandle,
1349 { "Frame handle", "blf.object.eth_frame_ext.frame_handle", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1350 { &hf_blf_eth_frame_ext_reservedethernetframeex,
1351 { "Reserved ethernet frame ex", "blf.object.eth_frame_ext.reservedethernetframeex", FT_UINT32, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1352 { &hf_blf_eth_phystate_channel,
1353 { "Channel", "blf.object.eth_phy_state.channel", FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1354 { &hf_blf_eth_phy_state_flags1_b0,
1355 { "PHYState", "blf.object.eth_phy_state.flags.b0", FT_BOOLEAN, 16, NULL, 0x0001, NULL, HFILL } },
1356 { &hf_blf_eth_phy_state_flags1_b1,
1357 { "PHYEvent", "blf.object.eth_phy_state.flags.b1", FT_BOOLEAN, 16, NULL, 0x0002, NULL, HFILL } },
1358 { &hf_blf_eth_phy_state_flags1_b2,
1359 { "HardwareChannel", "blf.object.eth_phy_state.flags.b2", FT_BOOLEAN, 16, NULL, 0x0004, NULL, HFILL } },
1360 { &hf_blf_eth_phy_state_phystate,
1361 { "PHY state", "blf.object.eth_status.phystate", FT_UINT8, BASE_DEC, VALS(blf_eth_phystate_phystate_vals), 0x00, NULL, HFILL} },
1362 { &hf_blf_eth_phy_state_eventstate,
1363 { "Event state", "blf.object.eth_status.eventstate", FT_UINT8, BASE_DEC, VALS(blf_eth_phystate_eventstate_vals), 0x00, NULL, HFILL} },
1364 { &hf_blf_eth_phy_state_hardwarechannel,
1365 { "Hardware channel", "blf.object.eth_status.hardwarechannel", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1366 { &hf_blf_eth_phy_state_res1,
1367 { "Reserved", "blf.object.eth_status.res1", FT_UINT8, BASE_DEC, NULL, 0x00, NULL, HFILL} },
1370 static ei_register_info ei[] = {
1371 { &ei_blf_file_header_length_too_short,
1372 { "blf.file_header_length_too_short", PI_MALFORMED, PI_ERROR,
1373 "file header length is too short",
1374 EXPFILL }},
1375 { &ei_blf_object_header_length_too_short,
1376 { "blf.object_header_length_too_short", PI_MALFORMED, PI_ERROR,
1377 "object header length is too short",
1378 EXPFILL }},
1379 { &ei_blf_object_length_less_than_header_length,
1380 { "blf.object_length_less_than_header_length", PI_MALFORMED, PI_ERROR,
1381 "object length is less than the object header length",
1382 EXPFILL }},
1385 static int *ett[] = {
1386 &ett_blf,
1387 &ett_blf_header,
1388 &ett_blf_obj,
1389 &ett_blf_obj_header,
1390 &ett_blf_logcontainer_payload,
1391 &ett_blf_app_text_payload,
1394 proto_blf = proto_register_protocol("BLF File Format", "File-BLF", "file-blf");
1395 proto_blf_ethernetstatus_obj = proto_register_protocol("BLF Ethernet Status", "BLF-Ethernet-Status", "blf-ethernet-status");
1396 proto_blf_ethernetphystate_obj = proto_register_protocol("BLF Ethernet PHY State", "BLF-Ethernet-PHY-State", "blf-ethernet-phystate");
1397 expert_blf = expert_register_protocol(proto_blf);
1398 expert_register_field_array(expert_blf, ei, array_length(ei));
1400 proto_register_field_array(proto_blf, hf, array_length(hf));
1401 proto_register_subtree_array(ett, array_length(ett));
1403 register_dissector("file-blf", dissect_blf, proto_blf);
1404 register_dissector("blf-ethernetstatus-obj", dissect_blf_ethernetstatus_obj, proto_blf_ethernetstatus_obj);
1405 register_dissector("blf-ethernetphystate-obj", dissect_blf_ethernetphystate_obj, proto_blf_ethernetphystate_obj);
1408 void
1409 proto_reg_handoff_file_blf(void) {
1410 heur_dissector_add("wtap_file", dissect_blf_heur, "BLF File", "blf_wtap", proto_blf, HEURISTIC_ENABLE);
1411 xml_handle = find_dissector_add_dependency("xml", proto_blf);
1415 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1417 * Local Variables:
1418 * c-basic-offset: 4
1419 * tab-width: 8
1420 * indent-tabs-mode: nil
1421 * End:
1423 * ex: set shiftwidth=4 tabstop=8 expandtab:
1424 * :indentSize=4:tabSize=8:noTabs=true: