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