Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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
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
20extern "C" {
21#endif
22
26struct canbus_api {
31 struct net_if_api iface_api;
32
34 int (*send)(const struct device *dev, struct net_pkt *pkt);
35
37 void (*close)(const struct device *dev, int filter_id);
38
40 int (*setsockopt)(const struct device *dev, void *obj, int level,
41 int optname,
42 const void *optval, socklen_t optlen);
43
45 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 */
53BUILD_ASSERT(offsetof(struct canbus_api, iface_api) == 0);
54
55#ifdef __cplusplus
56}
57#endif
58
59#endif /* ZEPHYR_INCLUDE_NET_CANBUS_H_ */
Controller Area Network (CAN) driver API.
size_t socklen_t
Length of a socket address.
Definition net_ip.h:172
Public API for network interface.
IPv6 and IPv4 definitions.
CAN L2 network driver API.
Definition canbus.h:26
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:45
int(* send)(const struct device *dev, struct net_pkt *pkt)
Send a CAN packet by socket.
Definition canbus.h:34
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:40
void(* close)(const struct device *dev, int filter_id)
Close the related CAN socket.
Definition canbus.h:37
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:31
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
Network packet.
Definition net_pkt.h:91