NEEDED??? epan/dissectors/packet-dcerpc.c dissect_ndr_c_and_or_v_array_core dissect_n...
[wireshark-sm.git] / wiretap / busmaster_priv.h
blob633e4cf1aca9b3a1f59bb9f3f35f5c44afebd4e6
1 /** @file
3 * Wiretap Library
4 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
6 * Support for Busmaster log file format
7 * Copyright (c) 2019 by Maksim Salau <maksim.salau@gmail.com>
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef BUSMASTER_PRIV_H__
13 #define BUSMASTER_PRIV_H__
15 #include <gmodule.h>
16 #include <wiretap/wtap.h>
17 #include <wiretap/socketcan.h>
19 //#define BUSMASTER_DEBUG
20 //#define BUSMASTER_PARSER_TRACE
22 typedef enum {
23 LOG_ENTRY_ERROR = -1,
24 LOG_ENTRY_NONE = 0,
25 LOG_ENTRY_EMPTY,
26 LOG_ENTRY_HEADER,
27 LOG_ENTRY_FOOTER,
28 LOG_ENTRY_FOOTER_AND_HEADER,
29 LOG_ENTRY_MSG,
30 LOG_ENTRY_EOF,
31 } log_entry_type_t;
33 typedef enum {
34 PROTOCOL_UNKNOWN = 0,
35 PROTOCOL_CAN,
36 PROTOCOL_LIN,
37 PROTOCOL_J1939,
38 } protocol_type_t;
40 typedef enum {
41 DATA_MODE_UNKNOWN = 0,
42 DATA_MODE_HEX,
43 DATA_MODE_DEC,
44 } data_mode_t;
46 typedef enum {
47 TIME_MODE_UNKNOWN = 0,
48 TIME_MODE_ABSOLUTE,
49 TIME_MODE_SYSTEM,
50 TIME_MODE_RELATIVE,
51 } time_mode_t;
53 typedef enum {
54 MSG_TYPE_STD,
55 MSG_TYPE_EXT,
56 MSG_TYPE_STD_RTR,
57 MSG_TYPE_EXT_RTR,
58 MSG_TYPE_STD_FD,
59 MSG_TYPE_EXT_FD,
60 MSG_TYPE_ERR,
61 } msg_type_t;
63 typedef struct {
64 unsigned year;
65 unsigned month;
66 unsigned day;
67 } msg_date_t;
69 typedef struct {
70 unsigned hours;
71 unsigned minutes;
72 unsigned seconds;
73 unsigned micros;
74 } msg_time_t;
76 typedef struct {
77 msg_date_t date;
78 msg_time_t time;
79 } msg_date_time_t;
81 typedef struct {
82 unsigned length;
83 uint8_t data[CANFD_MAX_DLEN];
84 } msg_data_t;
86 typedef struct {
87 msg_time_t timestamp;
88 msg_type_t type;
89 uint32_t id;
90 msg_data_t data;
91 } msg_t;
93 typedef struct {
94 int64_t v0;
95 int64_t v1;
96 int64_t v2;
97 int64_t v3;
98 } token_t;
100 typedef struct {
101 int64_t file_start_offset;
102 int64_t file_end_offset;
103 protocol_type_t protocol;
104 data_mode_t data_mode;
105 time_mode_t time_mode;
106 msg_date_t start_date;
107 msg_time_t start_time;
108 } busmaster_priv_t;
110 typedef struct {
111 FILE_T fh;
112 int64_t file_bytes_read;
114 char *parse_error;
115 int err;
116 char *err_info;
118 token_t token;
120 log_entry_type_t entry_type;
121 busmaster_priv_t header;
122 msg_t msg;
123 } busmaster_state_t;
125 bool
126 run_busmaster_parser(busmaster_state_t *state,
127 int *err, char **err_info);
129 #ifdef BUSMASTER_DEBUG
130 #include <stdio.h>
131 #define busmaster_debug_printf(...) printf(__VA_ARGS__)
132 #else
133 #define busmaster_debug_printf(...) (void)0
134 #endif
136 #endif /* BUSMASTER_PRIV_H__ */