Zephyr Project API  3.2.0
A Scalable Open Source RTOS
socketcan.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2019 Intel Corporation
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 */
12
13#ifndef ZEPHYR_INCLUDE_NET_SOCKETCAN_H_
14#define ZEPHYR_INCLUDE_NET_SOCKETCAN_H_
15
16#include <zephyr/types.h>
17#include <zephyr/net/net_ip.h>
18#include <zephyr/net/net_if.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
31/* Protocols of the protocol family PF_CAN */
32#define CAN_RAW 1
33
34/* SocketCAN options */
35#define SOL_CAN_BASE 100
36#define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW)
37
38enum {
40};
41
42/* SocketCAN MTU size compatible with Linux */
43#ifdef CONFIG_CAN_FD_MODE
44#define SOCKETCAN_MAX_DLEN 64U
45#define CANFD_MTU (sizeof(struct socketcan_frame))
46#define CAN_MTU (CANFD_MTU - 56U)
47#else /* CONFIG_CAN_FD_MODE */
48#define SOCKETCAN_MAX_DLEN 8U
49#define CAN_MTU (sizeof(struct socketcan_frame))
50#endif /* !CONFIG_CAN_FD_MODE */
51
52/* CAN-FD specific flags from Linux Kernel (include/uapi/linux/can.h) */
53#define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */
54#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */
55#define CANFD_FDF 0x04 /* mark CAN FD for dual use of struct canfd_frame */
56
64};
65
97
109 uint8_t res0; /* reserved/padding. */
110 uint8_t res1; /* reserved/padding. */
115};
116
127};
128
135#ifdef __cplusplus
136}
137#endif
138
139#endif /* ZEPHYR_INCLUDE_NET_SOCKETCAN_H_ */
unsigned short int sa_family_t
Definition: net_ip.h:164
uint32_t socketcan_id_t
Definition: socketcan.h:96
#define SOCKETCAN_MAX_DLEN
Definition: socketcan.h:48
@ CAN_RAW_FILTER
Definition: socketcan.h:39
Public API for network interface.
IPv6 and IPv4 definitions.
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Definition: socketcan.h:61
sa_family_t can_family
Definition: socketcan.h:62
int can_ifindex
Definition: socketcan.h:63
CAN filter for Linux SocketCAN compatibility.
Definition: socketcan.h:122
socketcan_id_t can_mask
Definition: socketcan.h:126
socketcan_id_t can_id
Definition: socketcan.h:124
CAN frame for Linux SocketCAN compatibility.
Definition: socketcan.h:101
socketcan_id_t can_id
Definition: socketcan.h:103
uint8_t data[8U]
Definition: socketcan.h:114
uint8_t len
Definition: socketcan.h:105
uint8_t flags
Definition: socketcan.h:107