1 /*
2  * Copyright (c) 2018 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /** @file
8  * @brief Dummy layer 2
9  *
10  * This is not to be included by the application.
11  */
12 
13 #ifndef ZEPHYR_INCLUDE_NET_DUMMY_H_
14 #define ZEPHYR_INCLUDE_NET_DUMMY_H_
15 
16 #include <zephyr/net/net_if.h>
17 #include <zephyr/net/net_pkt.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /**
24  * @brief Dummy L2/driver support functions
25  * @defgroup dummy Dummy L2/driver Support Functions
26  * @since 1.14
27  * @version 0.8.0
28  * @ingroup networking
29  * @{
30  */
31 
32 /** Dummy L2 API operations. */
33 struct dummy_api {
34 	/**
35 	 * The net_if_api must be placed in first position in this
36 	 * struct so that we are compatible with network interface API.
37 	 */
38 	struct net_if_api iface_api;
39 
40 	/** Send a network packet */
41 	int (*send)(const struct device *dev, struct net_pkt *pkt);
42 
43 	/**
44 	 * Receive a network packet (only limited use for this, for example
45 	 * receiving capturing packets and post processing them).
46 	 */
47 	enum net_verdict (*recv)(struct net_if *iface, struct net_pkt *pkt);
48 
49 	/** Start the device. Called when the bound network interface is brought up. */
50 	int (*start)(const struct device *dev);
51 
52 	/** Stop the device. Called when the bound network interface is taken down. */
53 	int (*stop)(const struct device *dev);
54 };
55 
56 /* Make sure that the network interface API is properly setup inside
57  * dummy API struct (it is the first one).
58  */
59 BUILD_ASSERT(offsetof(struct dummy_api, iface_api) == 0);
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 /**
66  * @}
67  */
68 
69 #endif /* ZEPHYR_INCLUDE_NET_DUMMY_H_ */
70