Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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
32#define CAN_RAW 1
33
36/* SocketCAN options */
37#define SOL_CAN_BASE 100
38#define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW)
39
40enum {
41 CAN_RAW_FILTER = 1,
42};
43
46/* SocketCAN MTU size compatible with Linux */
47#ifdef CONFIG_CAN_FD_MODE
49#define SOCKETCAN_MAX_DLEN 64U
51#define CANFD_MTU (sizeof(struct socketcan_frame))
53#define CAN_MTU (CANFD_MTU - 56U)
54#else /* CONFIG_CAN_FD_MODE */
56#define SOCKETCAN_MAX_DLEN 8U
58#define CAN_MTU (sizeof(struct socketcan_frame))
59#endif /* !CONFIG_CAN_FD_MODE */
60
61/* CAN FD specific flags from Linux Kernel (include/uapi/linux/can.h) */
62#define CANFD_BRS 0x01
63#define CANFD_ESI 0x02
64#define CANFD_FDF 0x04
73};
74
106
118 uint8_t res0; /* reserved/padding. */
119 uint8_t res1; /* reserved/padding. */
124};
125
138};
139
146#ifdef __cplusplus
147}
148#endif
149
150#endif /* ZEPHYR_INCLUDE_NET_SOCKETCAN_H_ */
unsigned short int sa_family_t
Socket address family type.
Definition: net_ip.h:164
uint32_t socketcan_id_t
CAN Identifier structure for Linux SocketCAN compatibility.
Definition: socketcan.h:105
#define SOCKETCAN_MAX_DLEN
SocketCAN max data length.
Definition: socketcan.h:56
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
struct sockaddr_can - The sockaddr structure for CAN sockets
Definition: socketcan.h:70
sa_family_t can_family
Address family.
Definition: socketcan.h:71
int can_ifindex
SocketCAN network interface index.
Definition: socketcan.h:72
CAN filter for Linux SocketCAN compatibility.
Definition: socketcan.h:131
socketcan_id_t can_mask
The mask applied to can_id for matching.
Definition: socketcan.h:135
uint8_t flags
Additional flags for FD frame filter.
Definition: socketcan.h:137
socketcan_id_t can_id
The CAN identifier to match.
Definition: socketcan.h:133
CAN frame for Linux SocketCAN compatibility.
Definition: socketcan.h:110
socketcan_id_t can_id
32-bit CAN ID + EFF/RTR/ERR flags.
Definition: socketcan.h:112
uint8_t data[8U]
The payload data.
Definition: socketcan.h:123
uint8_t len
Frame payload length in bytes.
Definition: socketcan.h:114
uint8_t flags
Additional flags for CAN FD.
Definition: socketcan.h:116