zephyr/include/net/dummy.h
Jukka Rissanen 6378ac4e38 net: Verify correctness of iface_api inside L2 driver API
Add build time check that guarantees that iface_api struct is the
first entry inside L2 driver data. This makes sure we do not miss
a case when the ordering of the fields in the struct is changed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2019-12-09 12:55:29 -05:00

49 lines
924 B
C

/*
* Copyright (c) 2018 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_NET_DUMMY_H_
#define ZEPHYR_INCLUDE_NET_DUMMY_H_
#include <net/net_if.h>
#include <net/net_pkt.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Dummy L2/driver support functions
* @defgroup dummy Dummy L2/driver Support Functions
* @ingroup networking
* @{
*/
struct dummy_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 network packet */
int (*send)(struct device *dev, struct net_pkt *pkt);
};
/* Make sure that the network interface API is properly setup inside
* dummy API struct (it is the first one).
*/
BUILD_ASSERT(offsetof(struct dummy_api, iface_api) == 0);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_NET_DUMMY_H_ */