File: socketcan.h

package info (click to toggle)
wireshark 4.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 351,244 kB
  • sloc: ansic: 3,101,885; cpp: 129,710; xml: 100,972; python: 56,512; perl: 24,575; sh: 5,874; lex: 4,383; pascal: 4,304; makefile: 165; ruby: 113; objc: 91; tcl: 35
file content (65 lines) | stat: -rw-r--r-- 1,655 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/** @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;
    unsigned int interface_id;
} wtap_can_msg_t;

#define WTAP_SOCKETCAN_INVALID_INTERFACE_ID     0xFFFFFFFF

/* Setup a wiretap to use SOCKETCAN encapsulation format */
extern void
wtap_set_as_socketcan(wtap* wth, int file_type_subtype, int tsprec, void* tap_priv, void (*tap_close)(void*));

/* Helper function to generate a SOCKETCAN packet from provided CAN data */
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);

/* Find or create a PCAPNG interface block
 * Return value is the interface ID used for the packet
 */
extern uint32_t
wtap_socketcan_find_or_create_new_interface(wtap* wth, const char* name);

/* Access to a wiretap's individual private data */
extern void*
wtap_socketcan_get_private_data(wtap* wth);

#endif  /* SOCKETCAN_H__ */