forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocket_can.h
88 lines (70 loc) · 1.69 KB
/
socket_can.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/** @file
* @brief Socket CAN definitions.
*
* Definitions for socket CAN support.
*/
/*
* Copyright (c) 2019 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_
#define ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <zephyr/types.h>
#include <net/net_ip.h>
#include <net/net_if.h>
#include <drivers/can.h>
/**
* @brief Socket CAN library
* @defgroup socket_can Network Core Library
* @ingroup networking
* @{
*/
/* Protocols of the protocol family PF_CAN */
#define CAN_RAW 1
/* Socket CAN options */
#define SOL_CAN_BASE 100
#define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW)
enum {
CAN_RAW_FILTER = 1,
};
/* Socket CAN MTU size */
#define CAN_MTU CAN_MAX_DLEN
/**
* struct sockaddr_can - The sockaddr structure for CAN sockets
*
*/
struct sockaddr_can {
sa_family_t can_family;
int can_ifindex;
};
/**
* CAN L2 driver API. Used by socket CAN.
*/
struct canbus_api {
/**
* The net_if_api must be placed in first position in this
* struct so that we are compatible with network interface API.
*/
struct net_if_api iface_api;
/** Send a CAN packet by socket */
int (*send)(struct device *dev, struct net_pkt *pkt);
/** Close the related CAN socket */
void (*close)(struct device *dev, int filter_id);
/** Set socket CAN option */
int (*setsockopt)(struct device *dev, void *obj, int level, int optname,
const void *optval, socklen_t optlen);
/** Get socket CAN option */
int (*getsockopt)(struct device *dev, void *obj, int level, int optname,
const void *optval, socklen_t *optlen);
};
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_NET_SOCKET_CAN_H_ */