1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gnrc_netif_xxx_create: use external netif allocation

This commit is contained in:
Jose Alamos 2019-12-19 19:23:15 +01:00
parent e9b71254ff
commit 67ed9defbe
55 changed files with 770 additions and 718 deletions

View File

@ -22,6 +22,8 @@
#include "esp_eth_netdev.h"
#include "net/gnrc/netif/ethernet.h"
static gnrc_netif_t _netif;
/** the only ESP32 Ethernet MAC (EMAC) device */
extern esp_eth_netdev_t _esp_eth_dev;
@ -34,7 +36,7 @@ extern void esp_eth_setup(esp_eth_netdev_t* dev);
void auto_init_esp_eth(void)
{
esp_eth_setup(&_esp_eth_dev);
gnrc_netif_ethernet_create(_esp_eth_stack, ESP_ETH_STACKSIZE, ESP_ETH_PRIO,
gnrc_netif_ethernet_create(&_netif, _esp_eth_stack, ESP_ETH_STACKSIZE, ESP_ETH_PRIO,
"netif-esp-eth", (netdev_t *)&_esp_eth_dev);
}

View File

@ -195,14 +195,15 @@ static const gnrc_netif_ops_t _esp_now_ops = {
.set = gnrc_netif_set_from_netdev,
};
gnrc_netif_t *gnrc_netif_esp_now_create(char *stack, int stacksize, char priority,
char *name, netdev_t *dev)
int gnrc_netif_esp_now_create(gnrc_netif_t *netif, char *stack, int stacksize, char priority,
char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name, dev, &_esp_now_ops);
return gnrc_netif_create(netif, stack, stacksize, priority, name, dev, &_esp_now_ops);
}
/* device thread stack */
static char _esp_now_stack[ESP_NOW_STACKSIZE];
static gnrc_netif_t _netif;
void auto_init_esp_now(void)
{
@ -212,7 +213,7 @@ void auto_init_esp_now(void)
if (!esp_now_dev) {
LOG_ERROR("[auto_init_netif] error initializing esp_now\n");
} else {
gnrc_netif_esp_now_create(_esp_now_stack, sizeof(_esp_now_stack),
gnrc_netif_esp_now_create(&_netif, _esp_now_stack, sizeof(_esp_now_stack),
ESP_NOW_PRIO,
"netif-esp-now",
&esp_now_dev->netdev);

View File

@ -27,14 +27,18 @@ extern "C" {
/**
* @brief Creates the ESP-NOW network interface
* @see gnrc_netif_create
* @param [in] netif The interface. May not be `NULL`.
* @param [in] stack The stack for the network interface's thread.
* @param [in] stacksize Size of stack.
* @param [in] priority Priority for the network interface's thread.
* @param [in] name Name for the network interface. May be NULL.
* @param [in] dev Device for the interface.
*
* @return 0 on success
* @return negative number on error
*/
gnrc_netif_t *gnrc_netif_esp_now_create(char *stack, int stacksize, char priority,
char *name, netdev_t *dev);
int gnrc_netif_esp_now_create(gnrc_netif_t *netif, char *stack, int stacksize, char priority,
char *name, netdev_t *dev);
#ifdef __cplusplus
}

View File

@ -24,6 +24,8 @@
#include "esp_wifi_params.h"
#include "esp_wifi_netdev.h"
static gnrc_netif_t _netif;
/** the only ESP WiFi device */
extern esp_wifi_netdev_t _esp_wifi_dev;
@ -36,14 +38,14 @@ extern void esp_wifi_setup (esp_wifi_netdev_t* dev);
void auto_init_esp_wifi (void)
{
esp_wifi_setup(&_esp_wifi_dev);
gnrc_netif_ethernet_create(_esp_wifi_stack, ESP_WIFI_STACKSIZE,
gnrc_netif_ethernet_create(&_netif, _esp_wifi_stack, ESP_WIFI_STACKSIZE,
#ifdef MODULE_ESP_NOW
ESP_WIFI_PRIO - 1,
ESP_WIFI_PRIO - 1,
#else
ESP_WIFI_PRIO,
ESP_WIFI_PRIO,
#endif
"netif-esp-wifi",
(netdev_t *)&_esp_wifi_dev);
"netif-esp-wifi",
(netdev_t *)&_esp_wifi_dev);
}
#else /* defined(MODULE_ESP_WIFI) && defined(MODULE_GNRC_NETIF_ETHERNET) */

View File

@ -49,6 +49,7 @@
* @brief Allocate the stack for the GNRC netdev thread to run in
*/
static char stack[NRFMIN_GNRC_STACKSIZE];
static gnrc_netif_t _netif;
static int hdr_netif_to_nrfmin(nrfmin_hdr_t *nrfmin, gnrc_pktsnip_t *pkt)
{
@ -184,6 +185,6 @@ void gnrc_nrfmin_init(void)
{
/* setup the NRFMIN driver */
nrfmin_setup();
gnrc_netif_create(stack, sizeof(stack), NRFMIN_GNRC_THREAD_PRIO, "nrfmin",
gnrc_netif_create(&_netif, stack, sizeof(stack), NRFMIN_GNRC_THREAD_PRIO, "nrfmin",
(netdev_t *)&nrfmin_dev, &gnrc_nrfmin_ops);
}

View File

@ -166,10 +166,9 @@ static const gnrc_netif_ops_t cc1xxx_netif_ops = {
.set = gnrc_netif_set_from_netdev,
};
gnrc_netif_t *gnrc_netif_cc1xxx_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev)
int gnrc_netif_cc1xxx_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name,
return gnrc_netif_create(netif, stack, stacksize, priority, name,
dev, &cc1xxx_netif_ops);
}

View File

@ -115,6 +115,7 @@ typedef struct netdev_radio_rx_info cc1xxx_rx_info_t;
/**
* @brief Creates a CC110x/CC1200 network interface
*
* @param[in] netif The interface. May not be `NULL`.
* @param[in] stack The stack for the network interface's thread.
* @param[in] stacksize Size of @p stack.
* @param[in] priority Priority for the network interface's thread.
@ -123,11 +124,11 @@ typedef struct netdev_radio_rx_info cc1xxx_rx_info_t;
*
* @see @ref gnrc_netif_create()
*
* @return The network interface on success.
* @return 0 on success
* @return negative number on error
*/
gnrc_netif_t *gnrc_netif_cc1xxx_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev);
int gnrc_netif_cc1xxx_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev);
#ifdef __cplusplus
}

View File

@ -167,10 +167,9 @@ static const gnrc_netif_ops_t _xbee_ops = {
.set = gnrc_netif_set_from_netdev,
};
gnrc_netif_t *gnrc_netif_xbee_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev)
int gnrc_netif_xbee_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name,
return gnrc_netif_create(netif, stack, stacksize, priority, name,
dev, &_xbee_ops);
}

View File

@ -24,9 +24,23 @@
extern "C" {
#endif
gnrc_netif_t *gnrc_netif_xbee_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev);
/**
* @brief Creates an Xbee network interface
*
* @param[in] netif The interface. May not be `NULL`.
* @param[in] stack The stack for the network interface's thread.
* @param[in] stacksize Size of @p stack.
* @param[in] priority Priority for the network interface's thread.
* @param[in] name Name for the network interface. May be NULL.
* @param[in] dev Device for the interface.
*
* @see @ref gnrc_netif_create()
*
* @return 0 on success
* @return negative number on error
*/
int gnrc_netif_xbee_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev);
#ifdef __cplusplus
}

View File

@ -518,6 +518,7 @@ static int _on_gap_slave_evt(struct ble_gap_event *event, void *arg)
return 0;
}
static gnrc_netif_t _netif;
void nimble_netif_init(void)
{
int res;
@ -537,7 +538,7 @@ void nimble_netif_init(void)
assert(res == 0);
(void)res;
gnrc_netif_create(_stack, sizeof(_stack), GNRC_NETIF_PRIO,
gnrc_netif_create(&_netif, _stack, sizeof(_stack), GNRC_NETIF_PRIO,
"nimble_netif", &_nimble_netdev_dummy, &_nimble_netif_ops);
}

View File

@ -70,6 +70,7 @@
static char _stack[(THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE)];
static gnrc_netif_t *_ble_netif = NULL;
static gnrc_netif_t _netif;
static uint8_t _sendbuf[BLE_SIXLOWPAN_MTU];
@ -281,6 +282,6 @@ static netdev_t _ble_dummy_dev = {
void gnrc_nordic_ble_6lowpan_init(void)
{
gnrc_netif_create(_stack, sizeof(_stack), BLE_PRIO,
gnrc_netif_create(&_netif, _stack, sizeof(_stack), BLE_PRIO,
"ble", &_ble_dummy_dev, &_ble_ops);
}

View File

@ -354,6 +354,7 @@ extern "C" {
/**
* @brief Creates an IEEE 802.15.4 GoMacH network interface
*
* @param[in] netif The interface. May not be `NULL`.
* @param[in] stack The stack for the GoMacH network interface's thread.
* @param[in] stacksize Size of @p stack.
* @param[in] priority Priority for the GoMacH network interface's thread.
@ -362,12 +363,11 @@ extern "C" {
*
* @see @ref gnrc_netif_create()
*
* @return The network interface on success.
* @return NULL, on error.
* @return 0 on success
* @return negative number on error
*/
gnrc_netif_t *gnrc_netif_gomach_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev);
int gnrc_netif_gomach_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev);
#ifdef __cplusplus
}

View File

@ -300,6 +300,7 @@ extern "C" {
/**
* @brief Creates an IEEE 802.15.4 LWMAC network interface
*
* @param[in] netif The interface. May not be `NULL`.
* @param[in] stack The stack for the LWMAC network interface's thread.
* @param[in] stacksize Size of @p stack.
* @param[in] priority Priority for the LWMAC network interface's thread.
@ -308,12 +309,11 @@ extern "C" {
*
* @see @ref gnrc_netif_create()
*
* @return The network interface on success.
* @return NULL, on error.
* @return 0 on success
* @return negative number on error
*/
gnrc_netif_t *gnrc_netif_lwmac_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev);
int gnrc_netif_lwmac_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev);
#ifdef __cplusplus
}
#endif

View File

@ -246,6 +246,7 @@ void gnrc_netif_init_devs(void);
/**
* @brief Creates a network interface
*
* @param[in] netif The interface. May not be `NULL`.
* @param[in] stack The stack for the network interface's thread.
* @param[in] stacksize Size of @p stack.
* @param[in] priority Priority for the network interface's thread.
@ -256,15 +257,12 @@ void gnrc_netif_init_devs(void);
* @note If @ref DEVELHELP is defined netif_params_t::name is used as the
* name of the network interface's thread.
*
* @attention Fails and crashes (assertion error with @ref DEVELHELP or
* segmentation fault without) if `GNRC_NETIF_NUMOF` is lower than
* the number of calls to this function.
*
* @return The network interface on success.
* @return 0 on success
* @return negative number on error
*/
gnrc_netif_t *gnrc_netif_create(char *stack, int stacksize, char priority,
const char *name, netdev_t *dev,
const gnrc_netif_ops_t *ops);
int gnrc_netif_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, const char *name, netdev_t *dev,
const gnrc_netif_ops_t *ops);
/**
* @brief Get number of network interfaces actually allocated

View File

@ -27,6 +27,7 @@ extern "C" {
/**
* @brief Creates an Ethernet network interface
*
* @param[in] netif The interface. May not be `NULL`.
* @param[in] stack The stack for the network interface's thread.
* @param[in] stacksize Size of @p stack.
* @param[in] priority Priority for the network interface's thread.
@ -35,14 +36,11 @@ extern "C" {
*
* @see @ref gnrc_netif_create()
*
* @attention Fails and crashes (assertion error with @ref DEVELHELP or
* segmentation fault without) if `GNRC_NETIF_NUMOF` is lower than
* the number of calls to this function.
*
* @return The network interface on success.
* @return 0 on success
* @return negative number on error
*/
gnrc_netif_t *gnrc_netif_ethernet_create(char *stack, int stacksize, char priority,
char *name, netdev_t *dev);
int gnrc_netif_ethernet_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev);
#ifdef __cplusplus
}

View File

@ -27,6 +27,7 @@ extern "C" {
/**
* @brief Creates an IEEE 802.15.4 network interface
*
* @param[in] netif The interface. May not be `NULL`.
* @param[in] stack The stack for the network interface's thread.
* @param[in] stacksize Size of @p stack.
* @param[in] priority Priority for the network interface's thread.
@ -35,12 +36,11 @@ extern "C" {
*
* @see @ref gnrc_netif_create()
*
* @return The network interface on success.
* @return NULL, on error.
* @return 0 on success
* @return negative number on error
*/
gnrc_netif_t *gnrc_netif_ieee802154_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev);
int gnrc_netif_ieee802154_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev);
#ifdef __cplusplus
}

View File

@ -27,6 +27,7 @@ extern "C" {
/**
* @brief Creates a raw network interface
*
* @param[in] netif The interface. May not be `NULL`.
* @param[in] stack The stack for the network interface's thread.
* @param[in] stacksize Size of @p stack.
* @param[in] priority Priority for the network interface's thread.
@ -35,11 +36,11 @@ extern "C" {
*
* @see @ref gnrc_netif_create()
*
* @return The network interface on success.
* @return NULL, on error.
* @return 0 on success
* @return negative number on error
*/
gnrc_netif_t *gnrc_netif_lorawan_create(char *stack, int stacksize, char priority,
char *name, netdev_t *dev);
int gnrc_netif_lorawan_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev);
#ifdef __cplusplus
}

View File

@ -28,6 +28,7 @@ extern "C" {
/**
* @brief Creates a raw network interface
*
* @param[in] netif The interface. May not be `NULL`.
* @param[in] stack The stack for the network interface's thread.
* @param[in] stacksize Size of @p stack.
* @param[in] priority Priority for the network interface's thread.
@ -36,11 +37,11 @@ extern "C" {
*
* @see @ref gnrc_netif_create()
*
* @return The network interface on success.
* @return NULL, on error.
* @return 0 on success
* @return negative number on error
*/
gnrc_netif_t *gnrc_netif_raw_create(char *stack, int stacksize, char priority,
char *name, netdev_t *dev);
int gnrc_netif_raw_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev);
#ifdef __cplusplus
}

View File

@ -70,11 +70,10 @@ static const gnrc_netif_ops_t gomach_ops = {
.msg_handler = _gomach_msg_handler,
};
gnrc_netif_t *gnrc_netif_gomach_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev)
int gnrc_netif_gomach_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name, dev,
return gnrc_netif_create(netif, stack, stacksize, priority, name, dev,
&gomach_ops);
}

View File

@ -76,11 +76,10 @@ static const gnrc_netif_ops_t lwmac_ops = {
.msg_handler = _lwmac_msg_handler,
};
gnrc_netif_t *gnrc_netif_lwmac_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev)
int gnrc_netif_lwmac_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name, dev,
return gnrc_netif_create(netif, stack, stacksize, priority, name, dev,
&lwmac_ops);
}

View File

@ -49,11 +49,10 @@ static const gnrc_netif_ops_t ethernet_ops = {
.set = _set,
};
gnrc_netif_t *gnrc_netif_ethernet_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev)
int gnrc_netif_ethernet_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name, dev,
return gnrc_netif_create(netif, stack, stacksize, priority, name, dev,
&ethernet_ops);
}

View File

@ -46,7 +46,7 @@ static void _configure_netdev(netdev_t *dev);
static void *_gnrc_netif_thread(void *args);
static void _event_cb(netdev_t *dev, netdev_event_t event);
gnrc_netif_t *gnrc_netif_create(char *stack, int stacksize, char priority,
int gnrc_netif_create(gnrc_netif_t *netif, char *stack, int stacksize, char priority,
const char *name, netdev_t *netdev,
const gnrc_netif_ops_t *ops)
{
@ -71,7 +71,7 @@ gnrc_netif_t *gnrc_netif_create(char *stack, int stacksize, char priority,
_gnrc_netif_thread, (void *)netif, name);
(void)res;
assert(res > 0);
return netif;
return 0;
}
bool gnrc_netif_dev_is_6lo(const gnrc_netif_t *netif)
@ -107,15 +107,7 @@ unsigned gnrc_netif_numof(void)
gnrc_netif_t *gnrc_netif_iter(const gnrc_netif_t *prev)
{
assert((prev == NULL) || (prev >= _netifs));
for (const gnrc_netif_t *netif = (prev == NULL) ? _netifs : (prev + 1);
netif < (_netifs + GNRC_NETIF_NUMOF); netif++) {
if (netif->ops != NULL) {
/* we don't care about external modification */
return (gnrc_netif_t *)netif;
}
}
return NULL;
return (gnrc_netif_t*) netif_iter((netif_t*) prev);
}
int gnrc_netif_get_from_netdev(gnrc_netif_t *netif, gnrc_netapi_opt_t *opt)

View File

@ -35,11 +35,10 @@ static const gnrc_netif_ops_t raw_ops = {
.set = gnrc_netif_set_from_netdev,
};
gnrc_netif_t *gnrc_netif_raw_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev)
int gnrc_netif_raw_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name, dev,
return gnrc_netif_create(netif, stack, stacksize, priority, name, dev,
&raw_ops);
}

View File

@ -39,11 +39,10 @@ static const gnrc_netif_ops_t ieee802154_ops = {
.set = gnrc_netif_set_from_netdev,
};
gnrc_netif_t *gnrc_netif_ieee802154_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev)
int gnrc_netif_ieee802154_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name, dev,
return gnrc_netif_create(netif, stack, stacksize, priority, name, dev,
&ieee802154_ops);
}

View File

@ -57,28 +57,31 @@
#define AT86RF215_NUM ARRAY_SIZE(at86rf215_params)
static at86rf215_t at86rf215_devs[AT86RF215_NUM * USED_BANDS];
static gnrc_netif_t _netif[AT86RF215_NUM * USED_BANDS];
static char _at86rf215_stacks[AT86RF215_NUM * USED_BANDS][AT86RF215_MAC_STACKSIZE];
static inline void _setup_netif(void* netdev, void* stack, int prio) {
if (netdev == NULL) {
static inline void _setup_netif(gnrc_netif_t *netif, void* netdev, void* stack,
int prio)
{
if (netif == NULL || netdev == NULL) {
return;
}
#if defined(MODULE_GNRC_GOMACH)
gnrc_netif_gomach_create(stack,
gnrc_netif_gomach_create(netif, stack,
AT86RF215_MAC_STACKSIZE,
prio, "at86rf215-gomach",
netdev);
#elif defined(MODULE_GNRC_LWMAC)
gnrc_netif_lwmac_create(stack,
AT86RF215_MAC_STACKSIZE,
prio, "at86rf215-lwmac",
netdev);
gnrc_netif_lwmac_create(netif, stack,
AT86RF215_MAC_STACKSIZE,
prio, "at86rf215-lwmac",
netdev);
#else
gnrc_netif_ieee802154_create(stack,
AT86RF215_MAC_STACKSIZE,
prio, "at86rf215",
netdev);
gnrc_netif_ieee802154_create(netif, stack,
AT86RF215_MAC_STACKSIZE,
prio, "at86rf215",
netdev);
#endif
}
@ -92,26 +95,30 @@ void auto_init_at86rf215(void)
at86rf215_t *dev_24 = NULL;
void *stack_09 = NULL;
void *stack_24 = NULL;
gnrc_netif_t *netif_09 = NULL;
gnrc_netif_t *netif_24 = NULL;
if (IS_USED(MODULE_AT86RF215_SUBGHZ)) {
dev_09 = &at86rf215_devs[i];
stack_09 = &_at86rf215_stacks[i];
netif_09 = &_netif[i];
++i;
}
if (IS_USED(MODULE_AT86RF215_24GHZ)) {
dev_24 = &at86rf215_devs[i];
stack_24 = &_at86rf215_stacks[i];
netif_24 = &_netif[i];
++i;
}
at86rf215_setup(dev_09, dev_24, &at86rf215_params[j++]);
/* setup sub-GHz interface */
_setup_netif(dev_09, stack_09, AT86RF215_MAC_PRIO_SUBGHZ);
_setup_netif(netif_09, dev_09, stack_09, AT86RF215_MAC_PRIO_SUBGHZ);
/* setup 2.4-GHz interface */
_setup_netif(dev_24, stack_24, AT86RF215_MAC_PRIO);
_setup_netif(netif_24, dev_24, stack_24, AT86RF215_MAC_PRIO);
}
}

View File

@ -45,6 +45,7 @@
#define AT86RF2XX_NUM ARRAY_SIZE(at86rf2xx_params)
static at86rf2xx_t at86rf2xx_devs[AT86RF2XX_NUM];
static gnrc_netif_t _netif[AT86RF2XX_NUM];
static char _at86rf2xx_stacks[AT86RF2XX_NUM][AT86RF2XX_MAC_STACKSIZE];
void auto_init_at86rf2xx(void)
@ -54,17 +55,17 @@ void auto_init_at86rf2xx(void)
at86rf2xx_setup(&at86rf2xx_devs[i], &at86rf2xx_params[i]);
#if defined(MODULE_GNRC_GOMACH)
gnrc_netif_gomach_create(_at86rf2xx_stacks[i],
gnrc_netif_gomach_create(&_netif[i], _at86rf2xx_stacks[i],
AT86RF2XX_MAC_STACKSIZE,
AT86RF2XX_MAC_PRIO, "at86rf2xx-gomach",
(netdev_t *)&at86rf2xx_devs[i]);
#elif defined(MODULE_GNRC_LWMAC)
gnrc_netif_lwmac_create(_at86rf2xx_stacks[i],
gnrc_netif_lwmac_create(&_netif[i], _at86rf2xx_stacks[i],
AT86RF2XX_MAC_STACKSIZE,
AT86RF2XX_MAC_PRIO, "at86rf2xx-lwmac",
(netdev_t *)&at86rf2xx_devs[i]);
#else
gnrc_netif_ieee802154_create(_at86rf2xx_stacks[i],
gnrc_netif_ieee802154_create(&_netif[i], _at86rf2xx_stacks[i],
AT86RF2XX_MAC_STACKSIZE,
AT86RF2XX_MAC_PRIO, "at86rf2xx",
(netdev_t *)&at86rf2xx_devs[i]);

View File

@ -63,6 +63,7 @@
* @brief Statically allocate memory for device descriptors
*/
cc110x_t _cc110x_devs[CC110X_NUM];
static gnrc_netif_t _netif[CC110X_NUM];
/**
* @brief Statically allocate memory for the MAC layer thread(s)
*/
@ -74,7 +75,7 @@ void auto_init_cc110x(void)
LOG_DEBUG("[auto_init_netif] initializing cc110x #%u\n", i);
cc110x_setup(&_cc110x_devs[i], &cc110x_params[i]);
gnrc_netif_cc1xxx_create(stacks[i], CC110X_MAC_STACKSIZE, CC110X_MAC_PRIO,
gnrc_netif_cc1xxx_create(&_netif[i], stacks[i], CC110X_MAC_STACKSIZE, CC110X_MAC_PRIO,
"cc110x", (netdev_t *)&_cc110x_devs[i]);
}
}

View File

@ -50,6 +50,7 @@
*/
static cc2420_t cc2420_devs[CC2420_NUMOF];
static char _cc2420_stacks[CC2420_NUMOF][CC2420_MAC_STACKSIZE];
static gnrc_netif_t _netif[CC2420_NUMOF];
/** @} */
void auto_init_cc2420(void)
@ -58,7 +59,7 @@ void auto_init_cc2420(void)
LOG_DEBUG("[auto_init_netif] initializing cc2420 #%u\n", i);
cc2420_setup(&cc2420_devs[i], &cc2420_params[i]);
gnrc_netif_ieee802154_create(_cc2420_stacks[i], CC2420_MAC_STACKSIZE,
gnrc_netif_ieee802154_create(&_netif[i], _cc2420_stacks[i], CC2420_MAC_STACKSIZE,
CC2420_MAC_PRIO, "cc2420",
(netdev_t *)&cc2420_devs[i]);
}

View File

@ -35,13 +35,14 @@
static cc2538_rf_t cc2538_rf_dev;
static char _cc2538_rf_stack[CC2538_MAC_STACKSIZE];
static gnrc_netif_t _netif;
void auto_init_cc2538_rf(void)
{
LOG_DEBUG("[auto_init_netif] initializing cc2538 radio\n");
cc2538_setup(&cc2538_rf_dev);
gnrc_netif_ieee802154_create(_cc2538_rf_stack,
gnrc_netif_ieee802154_create(&_netif, _cc2538_rf_stack,
CC2538_MAC_STACKSIZE,
CC2538_MAC_PRIO, "cc2538_rf",
(netdev_t *)&cc2538_rf_dev);

View File

@ -43,6 +43,7 @@ extern usbus_cdcecm_device_t cdcecm;
* @brief Stacks for the MAC layer threads
*/
static char _netdev_eth_stack[CDCECM_MAC_STACKSIZE];
static gnrc_netif_t _netif;
extern void cdcecm_netdev_setup(usbus_cdcecm_device_t *cdcecm);
void auto_init_netdev_cdcecm(void)
@ -51,7 +52,7 @@ void auto_init_netdev_cdcecm(void)
cdcecm_netdev_setup(&cdcecm);
/* initialize netdev<->gnrc adapter state */
gnrc_netif_ethernet_create(_netdev_eth_stack, CDCECM_MAC_STACKSIZE,
gnrc_netif_ethernet_create(&_netif, _netdev_eth_stack, CDCECM_MAC_STACKSIZE,
CDCECM_MAC_PRIO, "cdcecm", &cdcecm.netdev);
}

View File

@ -38,6 +38,7 @@
static char _netdev_eth_stack[DOSE_NUM][DOSE_MAC_STACKSIZE];
static dose_t dose[DOSE_NUM];
static gnrc_netif_t _netif[DOSE_NUM];
void auto_init_dose(void)
{
@ -46,7 +47,7 @@ void auto_init_dose(void)
LOG_DEBUG("[auto_init_netif] initializing dose #%d.\n", i);
dose_setup(&dose[i], &dose_params[i]);
gnrc_netif_ethernet_create(_netdev_eth_stack[i], DOSE_MAC_STACKSIZE,
gnrc_netif_ethernet_create(&_netif[i], _netdev_eth_stack[i], DOSE_MAC_STACKSIZE,
DOSE_MAC_PRIO, "dose", (netdev_t *)&dose[i]);
}
}

View File

@ -48,6 +48,8 @@
static enc28j60_t dev[ENC28J60_NUM];
/** @} */
static gnrc_netif_t _netif[ENC28J60_NUM];
/**
* @brief Stacks for the MAC layer threads
*/
@ -61,7 +63,7 @@ void auto_init_enc28j60(void)
/* setup netdev device */
enc28j60_setup(&dev[i], &enc28j60_params[i]);
gnrc_netif_ethernet_create(stack[i], ENC28J60_MAC_STACKSIZE,
gnrc_netif_ethernet_create(&_netif[i], stack[i], ENC28J60_MAC_STACKSIZE,
ENC28J60_MAC_PRIO, "enc28j60",
(netdev_t *)&dev[i]);
}

View File

@ -25,6 +25,7 @@
#include "net/gnrc/netif/ethernet.h"
static encx24j600_t encx24j600;
static gnrc_netif_t _netif;
/**
* @brief Define stack parameters for the MAC layer thread
@ -52,7 +53,7 @@ void auto_init_encx24j600(void)
encx24j600_setup(&encx24j600, &p);
/* initialize netdev<->gnrc adapter state */
gnrc_netif_ethernet_create(_netdev_eth_stack, ENCX24J600_MAC_STACKSIZE,
gnrc_netif_ethernet_create(&_netif, _netdev_eth_stack, ENCX24J600_MAC_STACKSIZE,
ENCX24J600_MAC_PRIO, "encx24j600",
(netdev_t *)&encx24j600);
}

View File

@ -30,6 +30,8 @@
*/
ethos_t ethos;
static gnrc_netif_t _netif;
/**
* @brief Define stack parameters for the MAC layer thread
* @{
@ -59,7 +61,7 @@ void auto_init_ethos(void)
ethos_setup(&ethos, &p);
/* initialize netdev<->gnrc adapter state */
gnrc_netif_ethernet_create(_netdev_eth_stack, ETHOS_MAC_STACKSIZE,
gnrc_netif_ethernet_create(&_netif, _netdev_eth_stack, ETHOS_MAC_STACKSIZE,
ETHOS_MAC_PRIO, "ethos", (netdev_t *)&ethos);
}

View File

@ -44,6 +44,8 @@
static kw2xrf_t kw2xrf_devs[KW2XRF_NUM];
static char _kw2xrf_stacks[KW2XRF_NUM][KW2XRF_MAC_STACKSIZE];
static gnrc_netif_t _netif[KW2XRF_NUM];
void auto_init_kw2xrf(void)
{
for (unsigned i = 0; i < KW2XRF_NUM; i++) {
@ -51,7 +53,7 @@ void auto_init_kw2xrf(void)
LOG_DEBUG("[auto_init_netif] initializing kw2xrf #%u\n", i);
kw2xrf_setup(&kw2xrf_devs[i], (kw2xrf_params_t*) p);
gnrc_netif_ieee802154_create(_kw2xrf_stacks[i], KW2XRF_MAC_STACKSIZE,
gnrc_netif_ieee802154_create(&_netif[i], _kw2xrf_stacks[i], KW2XRF_MAC_STACKSIZE,
KW2XRF_MAC_PRIO, "kw2xrf",
(netdev_t *)&kw2xrf_devs[i]);
}

View File

@ -52,6 +52,7 @@
static kw41zrf_t kw41zrf_devs[KW41ZRF_NUMOF];
static char _kw41zrf_stacks[KW41ZRF_NUMOF][KW41ZRF_NETIF_STACKSIZE];
static gnrc_netif_t _netif[KW41ZRF_NUMOF];
void auto_init_kw41zrf(void)
{
@ -60,15 +61,15 @@ void auto_init_kw41zrf(void)
kw41zrf_setup(&kw41zrf_devs[i]);
#if defined(MODULE_GNRC_GOMACH)
gnrc_netif_gomach_create(_kw41zrf_stacks[i], KW41ZRF_NETIF_STACKSIZE,
KW41ZRF_NETIF_PRIO, "kw41zrf-gomach",
(netdev_t *)&kw41zrf_devs[i]);
gnrc_netif_gomach_create(&_netif[i], _kw41zrf_stacks[i], KW41ZRF_NETIF_STACKSIZE,
KW41ZRF_NETIF_PRIO, "kw41zrf-gomach",
(netdev_t *)&kw41zrf_devs[i]);
#elif defined(MODULE_GNRC_LWMAC)
gnrc_netif_lwmac_create(_kw41zrf_stacks[i], KW41ZRF_NETIF_STACKSIZE,
KW41ZRF_NETIF_PRIO, "kw41zrf-lwmac",
(netdev_t *)&kw41zrf_devs[i]);
gnrc_netif_lwmac_create(&_netif[i], _kw41zrf_stacks[i], KW41ZRF_NETIF_STACKSIZE,
KW41ZRF_NETIF_PRIO, "kw41zrf-lwmac",
(netdev_t *)&kw41zrf_devs[i]);
#else
gnrc_netif_ieee802154_create(_kw41zrf_stacks[i], KW41ZRF_NETIF_STACKSIZE,
gnrc_netif_ieee802154_create(&_netif[i], _kw41zrf_stacks[i], KW41ZRF_NETIF_STACKSIZE,
KW41ZRF_NETIF_PRIO, "kw41zrf",
(netdev_t *)&kw41zrf_devs[i]);
#endif

View File

@ -41,13 +41,15 @@
static mrf24j40_t mrf24j40_devs[MRF24J40_NUM];
static char _mrf24j40_stacks[MRF24J40_NUM][MRF24J40_MAC_STACKSIZE];
static gnrc_netif_t _netif[MRF24J40_NUM];
void auto_init_mrf24j40(void)
{
for (unsigned i = 0; i < MRF24J40_NUM; i++) {
LOG_DEBUG("[auto_init_netif] initializing mrf24j40 #%u\n", i);
mrf24j40_setup(&mrf24j40_devs[i], &mrf24j40_params[i]);
gnrc_netif_ieee802154_create(_mrf24j40_stacks[i],
gnrc_netif_ieee802154_create(&_netif[i], _mrf24j40_stacks[i],
MRF24J40_MAC_STACKSIZE, MRF24J40_MAC_PRIO,
"mrf24j40",
(netdev_t *)&mrf24j40_devs[i]);

View File

@ -30,6 +30,8 @@
static netdev_tap_t netdev_tap[NETDEV_TAP_MAX];
static char _netdev_eth_stack[NETDEV_TAP_MAX][TAP_MAC_STACKSIZE];
static gnrc_netif_t _netif[NETDEV_TAP_MAX];
void auto_init_netdev_tap(void)
{
for (unsigned i = 0; i < NETDEV_TAP_MAX; i++) {
@ -39,7 +41,7 @@ void auto_init_netdev_tap(void)
i, *(p->tap_name));
netdev_tap_setup(&netdev_tap[i], p);
gnrc_netif_ethernet_create(_netdev_eth_stack[i], TAP_MAC_STACKSIZE,
gnrc_netif_ethernet_create(&_netif[i], _netdev_eth_stack[i], TAP_MAC_STACKSIZE,
TAP_MAC_PRIO, "gnrc_netdev_tap",
&netdev_tap[i].netdev);
}

View File

@ -38,12 +38,13 @@
/** @} */
static char _stack[NRF802154_MAC_STACKSIZE];
static gnrc_netif_t _netif;
void auto_init_nrf802154(void)
{
LOG_DEBUG("[auto_init_netif] initializing nrf802154\n");
gnrc_netif_ieee802154_create(_stack,
gnrc_netif_ieee802154_create(&_netif, _stack,
NRF802154_MAC_STACKSIZE,
NRF802154_MAC_PRIO, "nrf802154",
(netdev_t *)&nrf802154_dev);

View File

@ -41,6 +41,8 @@
static slipdev_t slipdevs[SLIPDEV_NUM];
static char _slipdev_stacks[SLIPDEV_NUM][SLIPDEV_STACKSIZE];
static gnrc_netif_t _netif[SLIPDEV_NUM];
void auto_init_slipdev(void)
{
for (unsigned i = 0; i < SLIPDEV_NUM; i++) {
@ -49,7 +51,7 @@ void auto_init_slipdev(void)
LOG_DEBUG("[auto_init_netif] initializing slip #%u\n", i);
slipdev_setup(&slipdevs[i], p);
gnrc_netif_raw_create(_slipdev_stacks[i], SLIPDEV_STACKSIZE,
gnrc_netif_raw_create(&_netif[i], _slipdev_stacks[i], SLIPDEV_STACKSIZE,
SLIPDEV_PRIO, "slipdev",
(netdev_t *)&slipdevs[i]);
}

View File

@ -40,6 +40,7 @@
*/
static char _socket_zep_stacks[SOCKET_ZEP_MAX][SOCKET_ZEP_MAC_STACKSIZE];
static socket_zep_t _socket_zeps[SOCKET_ZEP_MAX];
static gnrc_netif_t _netif[SOCKET_ZEP_MAX];
void auto_init_socket_zep(void)
{
@ -47,7 +48,7 @@ void auto_init_socket_zep(void)
LOG_DEBUG("[auto_init_netif: initializing socket ZEP device #%u\n", i);
/* setup netdev device */
socket_zep_setup(&_socket_zeps[i], &socket_zep_params[i]);
gnrc_netif_ieee802154_create(_socket_zep_stacks[i],
gnrc_netif_ieee802154_create(&_netif[i], _socket_zep_stacks[i],
SOCKET_ZEP_MAC_STACKSIZE,
SOCKET_ZEP_MAC_PRIO, "socket_zep",
(netdev_t *)&_socket_zeps[i]);

View File

@ -14,13 +14,14 @@
static netdev_t stm32eth;
static char stack[THREAD_STACKSIZE_DEFAULT];
static gnrc_netif_t _netif;
void auto_init_stm32_eth(void)
{
/* setup netdev device */
stm32_eth_netdev_setup(&stm32eth);
/* initialize netdev <-> gnrc adapter state */
gnrc_netif_ethernet_create(stack, THREAD_STACKSIZE_DEFAULT, GNRC_NETIF_PRIO, "stm32_eth",
gnrc_netif_ethernet_create(&_netif, stack, THREAD_STACKSIZE_DEFAULT, GNRC_NETIF_PRIO, "stm32_eth",
&stm32eth);
}

View File

@ -49,6 +49,7 @@
*/
static sx127x_t sx127x_devs[SX127X_NUMOF];
static char sx127x_stacks[SX127X_NUMOF][SX127X_STACKSIZE];
static gnrc_netif_t _netif[SX127X_NUMOF];
void auto_init_sx127x(void)
{
@ -64,10 +65,10 @@ void auto_init_sx127x(void)
/* Currently only one lora device is supported */
assert(SX127X_NUMOF == 1);
gnrc_netif_lorawan_create(sx127x_stacks[i], SX127X_STACKSIZE, SX127X_PRIO,
gnrc_netif_lorawan_create(&_netif[i], sx127x_stacks[i], SX127X_STACKSIZE, SX127X_PRIO,
"sx127x", (netdev_t *)&sx127x_devs[i]);
#else
gnrc_netif_raw_create(sx127x_stacks[i], SX127X_STACKSIZE, SX127X_PRIO,
gnrc_netif_raw_create(&_netif[i], sx127x_stacks[i], SX127X_STACKSIZE, SX127X_PRIO,
"sx127x", (netdev_t *)&sx127x_devs[i]);
#endif
}

View File

@ -44,6 +44,8 @@
static w5100_t dev[W5100_NUM];
/** @} */
static gnrc_netif_t _netif[W5100_NUM];
/**
* @brief Stacks for the MAC layer threads
*/
@ -58,7 +60,7 @@ void auto_init_w5100(void)
/* setup netdev device */
w5100_setup(&dev[i], &w5100_params[i]);
/* initialize netdev <-> gnrc adapter state */
gnrc_netif_ethernet_create(stack[i], MAC_STACKSIZE, MAC_PRIO, "w5100",
gnrc_netif_ethernet_create(&_netif[i], stack[i], MAC_STACKSIZE, MAC_PRIO, "w5100",
(netdev_t *)&dev[i]);
}
}

View File

@ -46,13 +46,15 @@
static xbee_t xbee_devs[XBEE_NUM];
static char stacks[XBEE_NUM][XBEE_MAC_STACKSIZE];
static gnrc_netif_t _netif[XBEE_NUM];
void auto_init_xbee(void)
{
for (unsigned i = 0; i < XBEE_NUM; i++) {
LOG_DEBUG("[auto_init_netif] initializing xbee #%u\n", i);
xbee_setup(&xbee_devs[i], &xbee_params[i]);
gnrc_netif_xbee_create(stacks[i], XBEE_MAC_STACKSIZE, XBEE_MAC_PRIO,
gnrc_netif_xbee_create(&_netif[i], stacks[i], XBEE_MAC_STACKSIZE, XBEE_MAC_PRIO,
"xbee", (netdev_t *)&xbee_devs[i]);
}
}

View File

@ -180,11 +180,10 @@ static void _init(gnrc_netif_t *netif)
gnrc_lorawan_init(&netif->lorawan.mac, netif->lorawan.nwkskey, netif->lorawan.appskey);
}
gnrc_netif_t *gnrc_netif_lorawan_create(char *stack, int stacksize,
char priority, char *name,
netdev_t *dev)
int gnrc_netif_lorawan_create(gnrc_netif_t *netif, char *stack, int stacksize,
char priority, char *name, netdev_t *dev)
{
return gnrc_netif_create(stack, stacksize, priority, name, dev,
return gnrc_netif_create(netif, stack, stacksize, priority, name, dev,
&lorawan_ops);
}

View File

@ -82,6 +82,7 @@ static int shell_test_cmd(int argc, char **argv);
static netdev_test_t mock_netdev;
static gnrc_netif_t *eth_netif, *mock_netif;
static gnrc_netif_t _netif;
static ipv6_addr_t *local_addr;
static char mock_netif_stack[THREAD_STACKSIZE_DEFAULT];
static char line_buf[SHELL_DEFAULT_BUFSIZE];
@ -686,10 +687,12 @@ int main(void)
netdev_test_set_get_cb(&mock_netdev, NETOPT_MAX_PDU_SIZE,
mock_get_max_packet_size);
netdev_test_set_send_cb(&mock_netdev, mock_send);
mock_netif = gnrc_netif_raw_create(mock_netif_stack,
sizeof(mock_netif_stack),
GNRC_NETIF_PRIO, "mock_netif",
(netdev_t *)&mock_netdev);
int res = gnrc_netif_raw_create(&_netif, mock_netif_stack,
sizeof(mock_netif_stack),
GNRC_NETIF_PRIO, "mock_netif",
(netdev_t *)&mock_netdev);
mock_netif = &_netif;
assert(res == 0);
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
return 0;
}

View File

@ -23,6 +23,7 @@
#include "thread.h"
gnrc_netif_t *_mock_netif = NULL;
static gnrc_netif_t _netif;
static netdev_test_t _mock_netdev;
static char _mock_netif_stack[THREAD_STACKSIZE_MAIN];
@ -62,11 +63,12 @@ void _tests_init(void)
_get_max_packet_size);
netdev_test_set_get_cb(&_mock_netdev, NETOPT_ADDRESS,
_get_address);
_mock_netif = gnrc_netif_ethernet_create(
int res = gnrc_netif_ethernet_create(&_netif,
_mock_netif_stack, THREAD_STACKSIZE_DEFAULT, GNRC_NETIF_PRIO,
"mockup_eth", &_mock_netdev.netdev
);
expect(_mock_netif != NULL);
_mock_netif = &_netif;
expect(res == 0);
gnrc_ipv6_nib_init();
gnrc_netif_acquire(_mock_netif);
gnrc_ipv6_nib_init_iface(_mock_netif);

View File

@ -28,6 +28,7 @@
#define _MSG_QUEUE_SIZE (2)
gnrc_netif_t *_mock_netif = NULL;
static gnrc_netif_t _netif;
static netdev_test_t _mock_netdev;
static char _mock_netif_stack[THREAD_STACKSIZE_DEFAULT];
@ -79,11 +80,12 @@ void _tests_init(void)
_get_max_packet_size);
netdev_test_set_get_cb(&_mock_netdev, NETOPT_ADDRESS,
_get_address);
_mock_netif = gnrc_netif_ethernet_create(
int res = gnrc_netif_ethernet_create(&_netif,
_mock_netif_stack, THREAD_STACKSIZE_DEFAULT, GNRC_NETIF_PRIO,
"mockup_eth", &_mock_netdev.netdev
);
expect(_mock_netif != NULL);
_mock_netif = &_netif;
expect(res == 0);
/* we do not want to test for SLAAC here so just assure the configured
* address is valid */
expect(!ipv6_addr_is_unspecified(&_mock_netif->ipv6.addrs[0]));

View File

@ -28,6 +28,7 @@
#define _MSG_QUEUE_SIZE (2)
gnrc_netif_t *_mock_netif = NULL;
static gnrc_netif_t _netif;
static netdev_test_t _mock_netdev;
static char _mock_netif_stack[THREAD_STACKSIZE_DEFAULT];
@ -100,11 +101,12 @@ void _tests_init(void)
_get_address_long);
netdev_test_set_get_cb(&_mock_netdev, NETOPT_PROTO,
_get_proto);
_mock_netif = gnrc_netif_ieee802154_create(
int res = gnrc_netif_ieee802154_create(&_netif,
_mock_netif_stack, THREAD_STACKSIZE_DEFAULT, GNRC_NETIF_PRIO,
"mockup_wpan", &_mock_netdev.netdev.netdev
);
expect(_mock_netif != NULL);
_mock_netif = &_netif;
expect(res == 0);
gnrc_netreg_entry_init_pid(&dumper, GNRC_NETREG_DEMUX_CTX_ALL,
sched_active_pid);
gnrc_netreg_register(GNRC_NETTYPE_NDP, &dumper);

View File

@ -67,6 +67,7 @@ static const ipv6_addr_t test_pfx = { { 0x47, 0x25, 0xd9, 0x3b, 0x7f, 0xcc, 0x15
static const uint8_t test_src_l2[] = { 0xe7, 0x43, 0xb7, 0x74, 0xd7, 0xa9, 0x30, 0x74 };
static gnrc_netif_t *test_netif = NULL;
static gnrc_netif_t _netif;
static void init_pkt_handler(void);
static inline size_t ceil8(size_t size);
@ -1283,10 +1284,11 @@ static void init_pkt_handler(void)
netdev_test_set_get_cb(&dev, NETOPT_MAX_PDU_SIZE,
_netdev_test_max_pdu_size);
netdev_test_set_get_cb(&dev, NETOPT_DEVICE_TYPE, _netdev_test_device_type);
test_netif = gnrc_netif_create(test_netif_stack, sizeof(test_netif_stack),
int res = gnrc_netif_create(&_netif, test_netif_stack, sizeof(test_netif_stack),
GNRC_NETIF_PRIO, "test-netif",
&dev.netdev.netdev, &_test_netif_ops);
TEST_ASSERT_MESSAGE(test_netif != NULL,
test_netif = &_netif;
TEST_ASSERT_MESSAGE(res == 0,
"Unable to start test interface");
memcpy(&test_netif->ipv6.addrs[0], &test_src,
sizeof(test_netif->ipv6.addrs[0]));

File diff suppressed because it is too large Load Diff

View File

@ -46,6 +46,7 @@
0x02, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x02 \
}
static gnrc_netif_t _netif;
static char _netif_stack[THREAD_STACKSIZE_DEFAULT];
static netdev_test_t _ieee802154_dev;
static const uint8_t _ieee802154_local_eui64[] = IEEE802154_LOCAL_EUI64;
@ -97,8 +98,6 @@ static int _get_netdev_addr_long(netdev_t *netdev, void *value, size_t max_len)
static void _init_interface(void)
{
gnrc_netif_t *netif;
netdev_test_setup(&_ieee802154_dev, NULL);
netdev_test_set_get_cb(&_ieee802154_dev, NETOPT_DEVICE_TYPE,
_get_netdev_device_type);
@ -110,7 +109,7 @@ static void _init_interface(void)
_get_netdev_src_len);
netdev_test_set_get_cb(&_ieee802154_dev, NETOPT_ADDRESS_LONG,
_get_netdev_addr_long);
netif = gnrc_netif_ieee802154_create(
gnrc_netif_ieee802154_create(&_netif,
_netif_stack, THREAD_STACKSIZE_DEFAULT, GNRC_NETIF_PRIO,
"dummy_netif", (netdev_t *)&_ieee802154_dev);
ipv6_addr_t addr = IPV6_ADDR_UNSPECIFIED;
@ -121,10 +120,10 @@ static void _init_interface(void)
addr.u8[15] = 0x01;
xtimer_usleep(500); /* wait for thread to start */
if (gnrc_netapi_set(netif->pid, NETOPT_IPV6_ADDR, 64U << 8U, &addr,
if (gnrc_netapi_set(_netif.pid, NETOPT_IPV6_ADDR, 64U << 8U, &addr,
sizeof(addr)) < 0) {
printf("error: unable to add IPv6 address fd01::1/64 to interface %u\n",
netif->pid);
_netif.pid);
}
}

View File

@ -101,6 +101,7 @@ const ipv6_addr_t _test_tgt_ipv6 = { .u8 = TEST_TGT_IPV6 };
static char _mock_netif_stack[THREAD_STACKSIZE_DEFAULT];
static netdev_test_t _mock_dev;
static gnrc_netif_t _netif;
static gnrc_netif_t *_mock_netif;
void _set_up(void)
@ -308,9 +309,10 @@ static void _init_mock_netif(void)
_get_netdev_src_len);
netdev_test_set_get_cb(&_mock_dev, NETOPT_ADDRESS_LONG,
_get_netdev_addr_long);
_mock_netif = gnrc_netif_ieee802154_create(
_mock_netif_stack, THREAD_STACKSIZE_DEFAULT, GNRC_NETIF_PRIO,
"mock_netif", (netdev_t *)&_mock_dev);
gnrc_netif_ieee802154_create(&_netif, _mock_netif_stack,
THREAD_STACKSIZE_DEFAULT, GNRC_NETIF_PRIO,
"mock_netif", (netdev_t *)&_mock_dev);
_mock_netif = &_netif;
thread_yield_higher();
}

View File

@ -52,6 +52,8 @@ static uint8_t _dev_addr[] = { 0x6c, 0x5d, 0xff, 0x73, 0x84, 0x6f };
static const uint8_t _test_dst[] = { 0xf5, 0x19, 0x9a, 0x1d, 0xd8, 0x8f };
static const uint8_t _test_src[] = { 0x41, 0x9b, 0x9f, 0x56, 0x36, 0x46 };
static gnrc_netif_t _netif;
static char _mac_stack[_MAC_STACKSIZE];
static netdev_test_t _dev;
static msg_t _main_msg_queue[_MAIN_MSG_QUEUE_SIZE];
@ -258,8 +260,9 @@ int main(void)
netdev_test_set_send_cb(&_dev, _dev_send);
netdev_test_set_get_cb(&_dev, NETOPT_ADDRESS, _dev_get_addr);
netdev_test_set_set_cb(&_dev, NETOPT_ADDRESS, _dev_set_addr);
_mac_pid = gnrc_netif_ethernet_create(_mac_stack, _MAC_STACKSIZE, _MAC_PRIO,
"netdev_test", (netdev_t *)&_dev)->pid;
gnrc_netif_ethernet_create(&_netif, _mac_stack, _MAC_STACKSIZE, _MAC_PRIO,
"netdev_test", (netdev_t *)&_dev);
_mac_pid = _netif.pid;
/* test execution */
EXECUTE(test_get_addr);