aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/candump_priv.h
diff options
context:
space:
mode:
authorMaksim Salau <maksim.salau@gmail.com>2019-06-27 21:19:53 +0300
committerAnders Broman <a.broman58@gmail.com>2019-07-11 04:44:00 +0000
commit8bb5320cb2c2574f657679e387068d27bc178fdb (patch)
tree88a8c69f849a63b3d5fcecd73b11969282cfd11a /wiretap/candump_priv.h
parentdb9ec7fc46dfa685fd4ff0376d6ea594f73cf081 (diff)
wiretap: Add support of candump logs
The change adds ability to import text logs produced by the candump tool. E.g.: candump -L can0 -or- candump -l can0 The whole file is read and converted into a temporary PCAPNG file with Exported PDU packets containing SocketCAN frames. Bug: 15889 Change-Id: I5ad93dca96d6e955a4b21cf624f0553e60f060f6 Reviewed-on: https://code.wireshark.org/review/33800 Petri-Dish: Jim Young <jim.young.ws@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wiretap/candump_priv.h')
-rw-r--r--wiretap/candump_priv.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/wiretap/candump_priv.h b/wiretap/candump_priv.h
new file mode 100644
index 0000000000..9749daec3e
--- /dev/null
+++ b/wiretap/candump_priv.h
@@ -0,0 +1,87 @@
+/* candump-priv.h
+ *
+ * Wiretap Library
+ * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
+ *
+ * Support for candump log file format
+ * Copyright (c) 2019 by Maksim Salau <maksim.salau@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef CANDUMP_PRIV_H__
+#define CANDUMP_PRIV_H__
+
+#include <gmodule.h>
+#include <wiretap/wtap.h>
+#include <epan/dissectors/packet-socketcan.h>
+
+#define CAN_MAX_DLEN 8
+#define CANFD_MAX_DLEN 64
+
+typedef struct can_frame {
+ guint32 can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
+ guint8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
+ guint8 __pad; /* padding */
+ guint8 __res0; /* reserved / padding */
+ guint8 __res1; /* reserved / padding */
+ guint8 data[CAN_MAX_DLEN];
+} can_frame_t;
+
+typedef struct canfd_frame {
+ guint32 can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
+ guint8 len; /* frame payload length in byte (0 .. CANFD_MAX_DLEN) */
+ guint8 flags; /* additional flags for CAN FD */
+ guint8 __res0; /* reserved / padding */
+ guint8 __res1; /* reserved / padding */
+ guint8 data[CANFD_MAX_DLEN];
+} canfd_frame_t;
+
+typedef struct {
+ guint8 length;
+ guint8 data[CANFD_MAX_DLEN];
+} msg_data_t;
+
+typedef struct {
+ nstime_t ts;
+ guint32 id;
+ gboolean is_fd;
+ guint8 flags;
+ msg_data_t data;
+} msg_t;
+
+typedef struct {
+ gint64 v0;
+ gint64 v1;
+} token_t;
+
+typedef struct {
+ wtap *tmp_file;
+ char *tmp_filename;
+} candump_priv_t;
+
+typedef struct {
+ GSList *packets;
+
+ FILE_T fh;
+ int err;
+ gchar *err_info;
+ gchar *parse_error;
+
+ token_t token;
+} candump_state_t;
+
+GSList *
+run_candump_parser(FILE_T fh, int *err, gchar **err_info);
+
+#include <wsutil/ws_printf.h>
+
+/* Uncomment the following line to make decoder verbose */
+//#undef NDEBUG
+
+#ifdef NDEBUG
+#undef ws_debug_printf
+#define ws_debug_printf(...) (void)0
+#endif
+
+#endif /* CANDUMP_PRIV_H__ */