Line data Source code
1 1 : /*
2 : * Copyright (c) 2019 Intel Corporation
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /** @file
8 : * @brief CAN bus socket API definitions.
9 : */
10 :
11 : #ifndef ZEPHYR_INCLUDE_NET_CANBUS_H_
12 : #define ZEPHYR_INCLUDE_NET_CANBUS_H_
13 :
14 : #include <zephyr/types.h>
15 : #include <zephyr/net/net_ip.h>
16 : #include <zephyr/net/net_if.h>
17 : #include <zephyr/drivers/can.h>
18 :
19 : #ifdef __cplusplus
20 : extern "C" {
21 : #endif
22 :
23 : /**
24 : * CAN L2 network driver API.
25 : */
26 1 : struct canbus_api {
27 : /**
28 : * The net_if_api must be placed in first position in this
29 : * struct so that we are compatible with network interface API.
30 : */
31 1 : struct net_if_api iface_api;
32 :
33 : /** Send a CAN packet by socket */
34 1 : int (*send)(const struct device *dev, struct net_pkt *pkt);
35 :
36 : /** Close the related CAN socket */
37 1 : void (*close)(const struct device *dev, int filter_id);
38 :
39 : /** Set socket CAN option */
40 1 : int (*setsockopt)(const struct device *dev, void *obj, int level,
41 : int optname,
42 : const void *optval, socklen_t optlen);
43 :
44 : /** Get socket CAN option */
45 1 : int (*getsockopt)(const struct device *dev, void *obj, int level,
46 : int optname,
47 : const void *optval, socklen_t *optlen);
48 : };
49 :
50 : /* Make sure that the network interface API is properly setup inside
51 : * CANBUS API struct (it is the first one).
52 : */
53 : BUILD_ASSERT(offsetof(struct canbus_api, iface_api) == 0);
54 :
55 : #ifdef __cplusplus
56 : }
57 : #endif
58 :
59 : #endif /* ZEPHYR_INCLUDE_NET_CANBUS_H_ */
|