Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
socket_can.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_SOCKET_CAN_H_
14#define ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_
15
16#include <zephyr/types.h>
17#include <net/net_ip.h>
18#include <net/net_if.h>
19#include <drivers/can.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
32/* Protocols of the protocol family PF_CAN */
33#define CAN_RAW 1
34
35/* Socket CAN options */
36#define SOL_CAN_BASE 100
37#define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW)
38
39enum {
41};
42
43/* Socket CAN MTU size */
44#define CAN_MTU CAN_MAX_DLEN
45
53};
54
58struct canbus_api {
63 struct net_if_api iface_api;
64
66 int (*send)(const struct device *dev, struct net_pkt *pkt);
67
69 void (*close)(const struct device *dev, int filter_id);
70
72 int (*setsockopt)(const struct device *dev, void *obj, int level,
73 int optname,
74 const void *optval, socklen_t optlen);
75
77 int (*getsockopt)(const struct device *dev, void *obj, int level,
78 int optname,
79 const void *optval, socklen_t *optlen);
80};
81
82/* Make sure that the network interface API is properly setup inside
83 * CANBUS API struct (it is the first one).
84 */
85BUILD_ASSERT(offsetof(struct canbus_api, iface_api) == 0);
86
91#ifdef __cplusplus
92}
93#endif
94
95#endif /* ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_ */
Public APIs for the CAN drivers.
void
Definition: eswifi_shell.c:15
unsigned short int sa_family_t
Definition: net_ip.h:158
size_t socklen_t
Definition: net_ip.h:161
@ CAN_RAW_FILTER
Definition: socket_can.h:40
Public API for network interface.
IPv6 and IPv4 definitions.
Definition: socket_can.h:58
int(* getsockopt)(const struct device *dev, void *obj, int level, int optname, const void *optval, socklen_t *optlen)
Definition: socket_can.h:77
int(* send)(const struct device *dev, struct net_pkt *pkt)
Definition: socket_can.h:66
int(* setsockopt)(const struct device *dev, void *obj, int level, int optname, const void *optval, socklen_t optlen)
Definition: socket_can.h:72
void(* close)(const struct device *dev, int filter_id)
Definition: socket_can.h:69
struct net_if_api iface_api
Definition: socket_can.h:63
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
Network packet.
Definition: net_pkt.h:62
Definition: socket_can.h:50
sa_family_t can_family
Definition: socket_can.h:51
int can_ifindex
Definition: socket_can.h:52