Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
canbus.h
Go to the documentation of this file.
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
16extern "C" {
17#endif
18
22struct canbus_api {
27 struct net_if_api iface_api;
28
30 int (*send)(const struct device *dev, struct net_pkt *pkt);
31
33 void (*close)(const struct device *dev, int filter_id);
34
36 int (*setsockopt)(const struct device *dev, void *obj, int level,
37 int optname,
38 const void *optval, socklen_t optlen);
39
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 */
49BUILD_ASSERT(offsetof(struct canbus_api, iface_api) == 0);
50
51#ifdef __cplusplus
52}
53#endif
54
55#endif /* ZEPHYR_INCLUDE_NET_CAN_H_ */
size_t socklen_t
Length of a socket address.
Definition: net_ip.h:168
Public API for network interface.
IPv6 and IPv4 definitions.
CAN L2 network driver API.
Definition: canbus.h:22
int(* getsockopt)(const struct device *dev, void *obj, int level, int optname, const void *optval, socklen_t *optlen)
Get socket CAN option.
Definition: canbus.h:41
int(* send)(const struct device *dev, struct net_pkt *pkt)
Send a CAN packet by socket.
Definition: canbus.h:30
int(* setsockopt)(const struct device *dev, void *obj, int level, int optname, const void *optval, socklen_t optlen)
Set socket CAN option.
Definition: canbus.h:36
void(* close)(const struct device *dev, int filter_id)
Close the related CAN socket.
Definition: canbus.h:33
struct net_if_api iface_api
The net_if_api must be placed in first position in this struct so that we are compatible with network...
Definition: canbus.h:27
Runtime device structure (in ROM) per driver instance.
Definition: device.h:381
Network packet.
Definition: net_pkt.h:63