Use socketcan.[c|h] for shared (Socket)CAN functionality where the wiretaps create records of the WTAP_ENCAP_SOCKETCAN encapsulation type. Adjust existing "homegrown" structures to use as much of the "shared" data structures from socketcan.h so that all can use the single function wtap_socketcan_gen_packet() to create records.
51 lines
1.1 KiB
C
51 lines
1.1 KiB
C
/** @file
|
|
*
|
|
* Wiretap Library
|
|
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
|
|
*
|
|
* Support for Busmaster log file format
|
|
* Copyright (c) 2019 by Maksim Salau <maksim.salau@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#ifndef SOCKETCAN_H__
|
|
#define SOCKETCAN_H__
|
|
|
|
#include <gmodule.h>
|
|
#include <wtap-int.h>
|
|
|
|
#define CAN_MAX_DLEN 8
|
|
#define CANFD_MAX_DLEN 64
|
|
|
|
typedef enum {
|
|
MSG_TYPE_STD,
|
|
MSG_TYPE_EXT,
|
|
MSG_TYPE_STD_RTR,
|
|
MSG_TYPE_EXT_RTR,
|
|
MSG_TYPE_STD_FD,
|
|
MSG_TYPE_EXT_FD,
|
|
MSG_TYPE_ERR,
|
|
} wtap_can_msg_type_t;
|
|
|
|
typedef struct {
|
|
uint8_t length;
|
|
uint8_t data[CANFD_MAX_DLEN];
|
|
} wtap_can_msg_data_t;
|
|
|
|
typedef struct {
|
|
nstime_t ts;
|
|
uint32_t id;
|
|
wtap_can_msg_type_t type;
|
|
uint8_t flags;
|
|
wtap_can_msg_data_t data;
|
|
} wtap_can_msg_t;
|
|
|
|
extern void
|
|
wtap_set_as_socketcan(wtap* wth, int file_type_subtype, int tsprec);
|
|
|
|
extern bool
|
|
wtap_socketcan_gen_packet(wtap* wth, wtap_rec* rec, const wtap_can_msg_t* msg, char* module_name, int* err, char** err_info);
|
|
|
|
#endif /* SOCKETCAN_H__ */
|