1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 04:52:59 +01:00

gnrc: integrate gnrc_netif2

Not link-able, since NDP and NC are missing (intentionally)
This commit is contained in:
Martine Lenders 2017-07-27 15:26:49 +02:00
parent b1e69a776f
commit 861035f22d
44 changed files with 246 additions and 1246 deletions

View File

@ -36,9 +36,8 @@ ifneq (,$(filter sntp,$(USEMODULE)))
endif
ifneq (,$(filter gnrc_netdev_default,$(USEMODULE)))
USEMODULE += gnrc_netif
USEMODULE += gnrc_netdev
USEMODULE += netdev_default
USEMODULE += gnrc_netif2
endif
ifneq (,$(filter netdev_ieee802154,$(USEMODULE)))
@ -58,8 +57,6 @@ ifneq (,$(filter nordic_softdevice_ble,$(USEPKG)))
USEMODULE += gnrc_sixlowpan
USEMODULE += gnrc_sixlowpan_iphc
USEMODULE += gnrc_ipv6_default
USEMODULE += gnrc_netdev
USEMODULE += gnrc_ipv6_netif
endif
ifneq (,$(filter gnrc_%,$(filter-out gnrc_netapi gnrc_netreg gnrc_netif% gnrc_pkt%,$(USEMODULE))))
@ -92,9 +89,6 @@ endif
ifneq (,$(filter netdev_tap,$(USEMODULE)))
USEMODULE += netif
USEMODULE += netdev_eth
ifneq (,$(filter gnrc_%,$(USEMODULE)))
USEMODULE += gnrc_netdev
endif
endif
ifneq (,$(filter gnrc_tftp,$(USEMODULE)))
@ -176,7 +170,6 @@ endif
ifneq (,$(filter gnrc_sixlowpan,$(USEMODULE)))
USEMODULE += gnrc_ipv6
USEMODULE += gnrc_sixlowpan_netif
USEMODULE += sixlowpan
endif
@ -297,6 +290,7 @@ endif
ifneq (,$(filter gnrc_ipv6_router,$(USEMODULE)))
USEMODULE += gnrc_ipv6
USEMODULE += gnrc_ipv6_nib_router
endif
ifneq (,$(filter gnrc_ipv6,$(USEMODULE)))
@ -304,7 +298,7 @@ ifneq (,$(filter gnrc_ipv6,$(USEMODULE)))
USEMODULE += ipv6_addr
USEMODULE += gnrc_ipv6_hdr
USEMODULE += gnrc_ipv6_nc
USEMODULE += gnrc_ipv6_netif
USEMODULE += gnrc_netif2
endif
ifneq (,$(filter gnrc_ipv6_hdr,$(USEMODULE)))
@ -350,13 +344,6 @@ ifneq (,$(filter gnrc_ipv6_nib,$(USEMODULE)))
USEMODULE += random
endif
ifneq (,$(filter gnrc_ipv6_netif,$(USEMODULE)))
USEMODULE += ipv6_addr
USEMODULE += gnrc_netif
USEMODULE += bitfield
USEMODULE += xtimer
endif
ifneq (,$(filter gnrc_udp,$(USEMODULE)))
USEMODULE += inet_csum
USEMODULE += udp
@ -373,7 +360,7 @@ endif
ifneq (,$(filter gnrc_nettest,$(USEMODULE)))
USEMODULE += gnrc_netapi
USEMODULE += gnrc_netreg
USEMODULE += gnrc_netif
USEMODULE += gnrc_netif2
USEMODULE += gnrc_pktbuf
USEMODULE += xtimer
endif
@ -534,7 +521,7 @@ endif
ifneq (,$(filter gnrc,$(USEMODULE)))
USEMODULE += gnrc_netapi
USEMODULE += gnrc_netreg
USEMODULE += gnrc_netif
USEMODULE += gnrc_netif2
USEMODULE += gnrc_netif_hdr
USEMODULE += gnrc_pktbuf
endif

View File

@ -1,6 +1,5 @@
ifneq (,$(filter gnrc_netdev_default,$(USEMODULE)))
USEMODULE += netif
USEMODULE += cc2538_rf
USEMODULE += gnrc_netdev
USEMODULE += netdev_ieee802154
endif

View File

@ -1,6 +1,5 @@
ifneq (,$(filter gnrc_netdev_default,$(USEMODULE)))
USEMODULE += netif
USEMODULE += cc2538_rf
USEMODULE += gnrc_netdev
USEMODULE += netdev_ieee802154
endif

View File

@ -1,7 +1,6 @@
ifneq (,$(filter gnrc_netdev_default,$(USEMODULE)))
USEMODULE += netif
USEMODULE += cc2538_rf
USEMODULE += gnrc_netdev
USEMODULE += netdev_ieee802154
endif

View File

@ -20,11 +20,7 @@
#include "net/gnrc.h"
#include "thread.h"
#ifdef MODULE_GNRC_NETIF2
#include "net/gnrc/netif2.h"
#else
#include "net/gnrc/netdev.h"
#endif
#include "nrfmin_gnrc.h"
@ -36,11 +32,7 @@
* @{
*/
#ifndef NRFMIN_GNRC_THREAD_PRIO
#ifdef MODULE_GNRC_NETIF2
#define NRFMIN_GNRC_THREAD_PRIO GNRC_NETIF2_PRIO
#else
#define NRFMIN_GNRC_THREAD_PRIO GNRC_NETDEV_MAC_PRIO
#endif
#endif
#ifndef NRFMIN_GNRC_STACKSIZE
@ -58,14 +50,6 @@
*/
static char stack[NRFMIN_GNRC_STACKSIZE];
#ifndef MODULE_GNRC_NETIF2
/**
* @brief Allocate the GNRC netdev data structure.
*/
static gnrc_netdev_t plug;
#endif
static int hdr_netif_to_nrfmin(nrfmin_hdr_t *nrfmin, gnrc_pktsnip_t *pkt)
{
gnrc_netif_hdr_t *netif = (gnrc_netif_hdr_t *)pkt->data;
@ -92,11 +76,7 @@ static int hdr_netif_to_nrfmin(nrfmin_hdr_t *nrfmin, gnrc_pktsnip_t *pkt)
return 0;
}
#ifdef MODULE_GNRC_NETIF2
static int gnrc_nrfmin_send(gnrc_netif2_t *dev, gnrc_pktsnip_t *pkt)
#else
static int gnrc_nrfmin_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt)
#endif
{
int res;
struct iovec *vec;
@ -139,11 +119,7 @@ static int gnrc_nrfmin_send(gnrc_netdev_t *dev, gnrc_pktsnip_t *pkt)
return res;
}
#ifdef MODULE_GNRC_NETIF2
static gnrc_pktsnip_t *gnrc_nrfmin_recv(gnrc_netif2_t *dev)
#else
static gnrc_pktsnip_t *gnrc_nrfmin_recv(gnrc_netdev_t *dev)
#endif
{
int pktsize;
nrfmin_hdr_t *nrfmin;
@ -204,30 +180,17 @@ static gnrc_pktsnip_t *gnrc_nrfmin_recv(gnrc_netdev_t *dev)
return pkt_snip;
}
#ifdef MODULE_GNRC_NETIF2
static const gnrc_netif2_ops_t gnrc_nrfmin_ops = {
.send = gnrc_nrfmin_send,
.recv = gnrc_nrfmin_recv,
.get = gnrc_netif2_get_from_netdev,
.set = gnrc_netif2_set_from_netdev,
};
#endif
void gnrc_nrfmin_init(void)
{
/* setup the NRFMIN driver */
nrfmin_setup();
#ifdef MODULE_GNRC_NETIF2
gnrc_netif2_create(stack, sizeof(stack), NRFMIN_GNRC_THREAD_PRIO, "nrfmin",
(netdev_t *)&nrfmin_dev, &gnrc_nrfmin_ops);
#else
/* initialize the GNRC plug struct */
plug.send = gnrc_nrfmin_send;
plug.recv = gnrc_nrfmin_recv;
plug.dev = &nrfmin_dev;
gnrc_netdev_init(stack, sizeof(stack),
NRFMIN_GNRC_THREAD_PRIO,
"nrfmin", &plug);
#endif
}

View File

@ -24,7 +24,7 @@
#include "msg.h"
#include "shell.h"
#include "ccn-lite-riot.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/netif2.h"
/* main thread's message queue */
#define MAIN_QUEUE_SIZE (8)
@ -46,10 +46,11 @@ int main(void)
ccnl_start();
/* get the default interface */
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
gnrc_netif2_t *netif;
/* set the relay's PID, configure the interface to use CCN nettype */
if ((gnrc_netif_get(ifs) == 0) || (ccnl_open_netif(ifs[0], GNRC_NETTYPE_CCN) < 0)) {
if (((netif = gnrc_netif2_iter(NULL)) == NULL) ||
(ccnl_open_netif(netif->pid, GNRC_NETTYPE_CCN) < 0)) {
puts("Error registering at network interface!");
return -1;
}

View File

@ -13,7 +13,7 @@ BOARD_INSUFFICIENT_MEMORY := airfy-beacon b-l072z-lrwan1 calliope-mini \
nucleo32-f031 nucleo32-f042 nucleo32-f303 nucleo32-l031 \
nucleo-f030 nucleo-f070 nucleo-f072 nucleo-f103 nucleo-f302 \
nucleo-f334 nucleo-l053 nucleo-l073 opencm904 pca10000 \
pca10005 spark-core stm32f0discovery telosb wsn430-v1_3b \
pca10005 spark-core stm32f0discovery telosb weio wsn430-v1_3b \
wsn430-v1_4 yunjia-nrf51822 z1
BOARD_BLACKLIST += mips-malta pic32-wifire pic32-clicker# No full UART available.
@ -22,7 +22,7 @@ BOARD_BLACKLIST += mips-malta pic32-wifire pic32-clicker# No full UART available
# UART, but not on native, as native has a tap interface towards the host.
ifeq (,$(filter native,$(BOARD)))
GNRC_NETIF_NUMOF := 2
USEMODULE += ethos gnrc_netdev
USEMODULE += ethos
# ethos baudrate can be configured from make command
ETHOS_BAUDRATE ?= 115200

View File

@ -22,25 +22,29 @@
#include "msg.h"
#include "net/ipv6/addr.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/ipv6/netif.h"
#include "net/gnrc.h"
#include "net/gnrc/netif2.h"
int main(void)
{
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
puts("RIOT network stack example application");
/* get the first IPv6 interface and prints its address */
size_t numof = gnrc_netif_get(ifs);
if (numof > 0) {
gnrc_ipv6_netif_t *entry = gnrc_ipv6_netif_get(ifs[0]);
for (int i = 0; i < GNRC_IPV6_NETIF_ADDR_NUMOF; i++) {
if ((ipv6_addr_is_link_local(&entry->addrs[i].addr)) && !(entry->addrs[i].flags & GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST)) {
char ipv6_addr[IPV6_ADDR_MAX_STR_LEN];
ipv6_addr_to_str(ipv6_addr, &entry->addrs[i].addr, IPV6_ADDR_MAX_STR_LEN);
printf("My address is %s\n", ipv6_addr);
}
/* get interfaces and print their addresses */
gnrc_netif2_t *netif = NULL;
while ((netif = gnrc_netif2_iter(netif))) {
ipv6_addr_t ipv6_addrs[GNRC_NETIF2_IPV6_ADDRS_NUMOF];
int res = gnrc_netapi_get(netif->pid, NETOPT_IPV6_ADDR, 0, ipv6_addrs,
sizeof(ipv6_addrs));
if (res < 0) {
continue;
}
for (unsigned i = 0; i < (unsigned)(res / sizeof(ipv6_addr_t)); i++) {
char ipv6_addr[IPV6_ADDR_MAX_STR_LEN];
ipv6_addr_to_str(ipv6_addr, &ipv6_addrs[i], IPV6_ADDR_MAX_STR_LEN);
printf("My address is %s\n", ipv6_addr);
}
}

View File

@ -247,10 +247,6 @@ void auto_init(void)
#endif /* MODULE_AUTO_INIT_GNRC_NETIF */
#ifdef MODULE_GNRC_IPV6_NETIF
gnrc_ipv6_netif_init_by_dev();
#endif
#ifdef MODULE_GNRC_UHCPC
extern void auto_init_gnrc_uhcpc(void);
auto_init_gnrc_uhcpc();

View File

@ -21,12 +21,7 @@
#include "log.h"
#include "board.h"
#ifdef MODULE_GNRC_NETIF2
#include "net/gnrc/netif2/ieee802154.h"
#else
#include "net/gnrc/netdev.h"
#include "net/gnrc/netdev/ieee802154.h"
#endif
#include "net/gnrc/lwmac/lwmac.h"
#include "net/gnrc.h"
@ -39,19 +34,12 @@
*/
#define AT86RF2XX_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#ifndef AT86RF2XX_MAC_PRIO
#ifdef MODULE_GNRC_NETIF2
#define AT86RF2XX_MAC_PRIO (GNRC_NETIF2_PRIO)
#else
#define AT86RF2XX_MAC_PRIO (GNRC_NETDEV_MAC_PRIO)
#endif
#endif
#define AT86RF2XX_NUM (sizeof(at86rf2xx_params) / sizeof(at86rf2xx_params[0]))
static at86rf2xx_t at86rf2xx_devs[AT86RF2XX_NUM];
#ifndef MODULE_GNRC_NETIF2
static gnrc_netdev_t gnrc_adpt[AT86RF2XX_NUM];
#endif
static char _at86rf2xx_stacks[AT86RF2XX_NUM][AT86RF2XX_MAC_STACKSIZE];
void auto_init_at86rf2xx(void)
@ -60,7 +48,6 @@ void auto_init_at86rf2xx(void)
LOG_DEBUG("[auto_init_netif] initializing at86rf2xx #%u\n", i);
at86rf2xx_setup(&at86rf2xx_devs[i], &at86rf2xx_params[i]);
#ifdef MODULE_GNRC_NETIF2
#ifdef MODULE_GNRC_LWMAC
gnrc_netif2_lwmac_create(_at86rf2xx_stacks[i],
AT86RF2XX_MAC_STACKSIZE,
@ -71,21 +58,6 @@ void auto_init_at86rf2xx(void)
AT86RF2XX_MAC_STACKSIZE,
AT86RF2XX_MAC_PRIO, "at86rf2xx",
(netdev_t *)&at86rf2xx_devs[i]);
#endif
#else
int res = gnrc_netdev_ieee802154_init(&gnrc_adpt[i],
(netdev_ieee802154_t *)&at86rf2xx_devs[i]);
if (res < 0) {
LOG_ERROR("[auto_init_netif] error initializing at86rf2xx radio #%u\n", i);
}
else {
gnrc_netdev_init(_at86rf2xx_stacks[i],
AT86RF2XX_MAC_STACKSIZE,
AT86RF2XX_MAC_PRIO,
"at86rf2xx",
&gnrc_adpt[i]);
}
#endif
}
}

View File

@ -23,12 +23,7 @@
#include "log.h"
#include "board.h"
#ifdef MODULE_GNRC_NETIF2
#include "net/gnrc/netif2/ieee802154.h"
#else
#include "net/gnrc/netdev.h"
#include "net/gnrc/netdev/ieee802154.h"
#endif
#include "net/gnrc.h"
#include "cc2420.h"
@ -40,11 +35,7 @@
*/
#define CC2420_MAC_STACKSIZE (THREAD_STACKSIZE_MAIN)
#ifndef CC2420_MAC_PRIO
#ifdef MODULE_GNRC_NETIF2
#define CC2420_MAC_PRIO (GNRC_NETIF2_PRIO)
#else
#define CC2420_MAC_PRIO (GNRC_NETDEV_MAC_PRIO)
#endif
#endif
/** @} */
@ -58,9 +49,6 @@
* @{
*/
static cc2420_t cc2420_devs[CC2420_NUMOF];
#ifndef MODULE_GNRC_NETIF2
static gnrc_netdev_t gnrc_adpt[CC2420_NUMOF];
#endif
static char _cc2420_stacks[CC2420_NUMOF][CC2420_MAC_STACKSIZE];
/** @} */
@ -70,24 +58,9 @@ void auto_init_cc2420(void)
LOG_DEBUG("[auto_init_netif] initializing cc2420 #%u\n", i);
cc2420_setup(&cc2420_devs[i], &cc2420_params[i]);
#ifdef MODULE_GNRC_NETIF2
gnrc_netif2_ieee802154_create(_cc2420_stacks[i], CC2420_MAC_STACKSIZE,
CC2420_MAC_PRIO, "cc2420",
(netdev_t *)&cc2420_devs[i]);
#else
int res = gnrc_netdev_ieee802154_init(&gnrc_adpt[i],
(netdev_ieee802154_t *)&cc2420_devs[i]);
if (res < 0) {
LOG_ERROR("[auto_init_netif] error initializing cc2420 #%u\n", i);
}
else {
gnrc_netdev_init(_cc2420_stacks[i],
CC2420_MAC_STACKSIZE,
CC2420_MAC_PRIO,
"cc2420", &gnrc_adpt[i]);
}
#endif
}
}

View File

@ -20,12 +20,7 @@
#ifdef MODULE_CC2538_RF
#include "log.h"
#ifdef MODULE_GNRC_NETIF2
#include "net/gnrc/netif2/ieee802154.h"
#else
#include "net/gnrc/netdev.h"
#include "net/gnrc/netdev/ieee802154.h"
#endif
#include "cc2538_rf.h"
@ -35,17 +30,10 @@
*/
#define CC2538_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#ifndef CC2538_MAC_PRIO
#ifdef MODULE_GNRC_NETIF2
#define CC2538_MAC_PRIO (GNRC_NETIF2_PRIO)
#else
#define CC2538_MAC_PRIO (GNRC_NETDEV_MAC_PRIO)
#endif
#endif
static cc2538_rf_t cc2538_rf_dev;
#ifndef MODULE_GNRC_NETIF2
static gnrc_netdev_t gnrc_adpt;
#endif
static char _cc2538_rf_stack[CC2538_MAC_STACKSIZE];
void auto_init_cc2538_rf(void)
@ -53,28 +41,10 @@ void auto_init_cc2538_rf(void)
LOG_DEBUG("[auto_init_netif] initializing cc2538 radio\n");
cc2538_setup(&cc2538_rf_dev);
#ifdef MODULE_GNRC_NETIF2
if (!gnrc_netif2_ieee802154_create(_cc2538_rf_stack,
CC2538_MAC_STACKSIZE,
CC2538_MAC_PRIO, "cc2538_rf",
(netdev_t *)&cc2538_rf_dev)) {
LOG_ERROR("[auto_init_netif] error initializing cc2538 radio\n");
}
#else
int res = gnrc_netdev_ieee802154_init(&gnrc_adpt,
(netdev_ieee802154_t *)&cc2538_rf_dev);
if (res < 0) {
LOG_ERROR("[auto_init_netif] error initializing cc2538 radio\n");
}
else {
gnrc_netdev_init(_cc2538_rf_stack,
CC2538_MAC_STACKSIZE,
CC2538_MAC_PRIO,
"cc2538_rf",
&gnrc_adpt);
}
#endif
gnrc_netif2_ieee802154_create(_cc2538_rf_stack,
CC2538_MAC_STACKSIZE,
CC2538_MAC_PRIO, "cc2538_rf",
(netdev_t *)&cc2538_rf_dev);
}
#else

View File

@ -24,12 +24,7 @@
#include "log.h"
#include "enc28j60.h"
#include "enc28j60_params.h"
#ifdef MODULE_GNRC_NETIF2
#include "net/gnrc/netif2/ethernet.h"
#else
#include "net/gnrc/netdev.h"
#include "net/gnrc/netdev/eth.h"
#endif
/**
* @brief Define stack parameters for the MAC layer thread
@ -37,11 +32,7 @@
*/
#define ENC28J60_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#ifndef ENC28J60_MAC_PRIO
#ifdef MODULE_GNRC_NETIF2
#define ENC28J60_MAC_PRIO (GNRC_NETIF2_PRIO)
#else
#define ENC28J60_MAC_PRIO (GNRC_NETDEV_MAC_PRIO)
#endif
#endif
/*** @} */
@ -55,9 +46,6 @@
* @{
*/
static enc28j60_t dev[ENC28J60_NUM];
#ifndef MODULE_GNRC_NETIF2
static gnrc_netdev_t gnrc_adpt[ENC28J60_NUM];
#endif
/** @} */
/**
@ -73,17 +61,9 @@ void auto_init_enc28j60(void)
/* setup netdev device */
enc28j60_setup(&dev[i], &enc28j60_params[i]);
#ifdef MODULE_GNRC_NETIF2
gnrc_netif2_ethernet_create(stack[i], ENC28J60_MAC_STACKSIZE,
ENC28J60_MAC_PRIO, "enc28j60",
(netdev_t *)&dev[i]);
#else
/* initialize netdev <-> gnrc adapter state */
gnrc_netdev_eth_init(&gnrc_adpt[i], (netdev_t *)&dev[i]);
/* start gnrc netdev thread */
gnrc_netdev_init(stack[i], ENC28J60_MAC_STACKSIZE, ENC28J60_MAC_PRIO,
"gnrc_enc28j60", &gnrc_adpt[i]);
#endif
}
}

View File

@ -22,12 +22,7 @@
#include "log.h"
#include "debug.h"
#include "encx24j600.h"
#ifdef MODULE_GNRC_NETIF2
#include "net/gnrc/netif2/ethernet.h"
#else
#include "net/gnrc/netdev.h"
#include "net/gnrc/netdev/eth.h"
#endif
static encx24j600_t encx24j600;
@ -37,20 +32,13 @@ static encx24j600_t encx24j600;
*/
#define ENCX24J600_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE)
#ifndef ENCX24J600_MAC_PRIO
#ifdef MODULE_GNRC_NETIF2
#define ENCX24J600_MAC_PRIO (GNRC_NETIF2_PRIO)
#else
#define ENCX24J600_MAC_PRIO (GNRC_NETDEV_MAC_PRIO)
#endif
#endif
/**
* @brief Stacks for the MAC layer threads
*/
static char _netdev_eth_stack[ENCX24J600_MAC_STACKSIZE];
#ifndef MODULE_GNRC_NETIF2
static gnrc_netdev_t _gnrc_encx24j600;
#endif
void auto_init_encx24j600(void)
{
@ -64,18 +52,9 @@ void auto_init_encx24j600(void)
encx24j600_setup(&encx24j600, &p);
/* initialize netdev<->gnrc adapter state */
#ifdef MODULE_GNRC_NETIF2
gnrc_netif2_ethernet_create(_netdev_eth_stack, ENCX24J600_MAC_STACKSIZE,
ENCX24J600_MAC_PRIO, "encx24j600",
(netdev_t *)&encx24j600);
#else
gnrc_netdev_eth_init(&_gnrc_encx24j600, (netdev_t*)&encx24j600);
/* start gnrc netdev thread */
gnrc_netdev_init(_netdev_eth_stack, ENCX24J600_MAC_STACKSIZE,
ENCX24J600_MAC_PRIO, "gnrc_encx24j600",
&_gnrc_encx24j600);
#endif
}
#else

View File

@ -23,12 +23,7 @@
#include "debug.h"
#include "ethos.h"
#include "periph/uart.h"
#ifdef MODULE_GNRC_NETIF2
#include "net/gnrc/netif2/ethernet.h"
#else
#include "net/gnrc/netdev.h"
#include "net/gnrc/netdev/eth.h"
#endif
/**
* @brief global ethos object, used by uart_stdio
@ -41,20 +36,13 @@ ethos_t ethos;
*/
#define ETHOS_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE)
#ifndef ETHOS_MAC_PRIO
#ifdef MODULE_GNRC_NETIF2
#define ETHOS_MAC_PRIO (GNRC_NETIF2_PRIO)
#else
#define ETHOS_MAC_PRIO (GNRC_NETDEV_MAC_PRIO)
#endif
#endif
/**
* @brief Stacks for the MAC layer threads
*/
static char _netdev_eth_stack[ETHOS_MAC_STACKSIZE];
#ifndef MODULE_GNRC_NETIF2
static gnrc_netdev_t _gnrc_ethos;
#endif
static uint8_t _inbuf[2048];
@ -71,16 +59,8 @@ void auto_init_ethos(void)
ethos_setup(&ethos, &p);
/* initialize netdev<->gnrc adapter state */
#ifdef MODULE_GNRC_NETIF2
gnrc_netif2_ethernet_create(_netdev_eth_stack, ETHOS_MAC_STACKSIZE,
ETHOS_MAC_PRIO, "ethos", (netdev_t *)&ethos);
#else
gnrc_netdev_eth_init(&_gnrc_ethos, (netdev_t*)&ethos);
/* start gnrc netdev thread */
gnrc_netdev_init(_netdev_eth_stack, ETHOS_MAC_STACKSIZE, ETHOS_MAC_PRIO,
"gnrc_ethos", &_gnrc_ethos);
#endif
}
#else

View File

@ -24,12 +24,7 @@
#include "log.h"
#include "board.h"
#ifdef MODULE_GNRC_NETIF2
#include "net/gnrc/netif2/ieee802154.h"
#else
#include "net/gnrc/netdev.h"
#include "net/gnrc/netdev/ieee802154.h"
#endif
#include "net/gnrc.h"
#include "kw2xrf.h"
@ -41,19 +36,12 @@
*/
#define KW2XRF_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#ifndef KW2XRF_MAC_PRIO
#ifdef MODULE_GNRC_NETIF2
#define KW2XRF_MAC_PRIO (GNRC_NETIF2_PRIO)
#else
#define KW2XRF_MAC_PRIO (GNRC_NETDEV_MAC_PRIO)
#endif
#endif
#define KW2XRF_NUM (sizeof(kw2xrf_params)/sizeof(kw2xrf_params[0]))
static kw2xrf_t kw2xrf_devs[KW2XRF_NUM];
#ifndef MODULE_GNRC_NETIF2
static gnrc_netdev_t gnrc_adpt[KW2XRF_NUM];
#endif
static char _kw2xrf_stacks[KW2XRF_NUM][KW2XRF_MAC_STACKSIZE];
void auto_init_kw2xrf(void)
@ -63,19 +51,9 @@ void auto_init_kw2xrf(void)
LOG_DEBUG("[auto_init_netif] initializing kw2xrf #%u\n", i);
kw2xrf_setup(&kw2xrf_devs[i], (kw2xrf_params_t*) p);
#ifdef MODULE_GNRC_NETIF2
gnrc_netif2_ieee802154_create(_kw2xrf_stacks[i], KW2XRF_MAC_STACKSIZE,
KW2XRF_MAC_PRIO, "kw2xrf",
(netdev_t *)&kw2xrf_devs[i]);
#else
if (gnrc_netdev_ieee802154_init(&gnrc_adpt[i], (netdev_ieee802154_t *)&kw2xrf_devs[i]) < 0) {
LOG_ERROR("[auto_init_netif] error, initializing kw2xrf #%u\n", i);
}
else {
gnrc_netdev_init(_kw2xrf_stacks[i], KW2XRF_MAC_STACKSIZE,
KW2XRF_MAC_PRIO, "kw2xrf", &gnrc_adpt[i]);
}
#endif
}
}
#else

View File

@ -21,12 +21,7 @@
#include "log.h"
#include "board.h"
#ifdef MODULE_GNRC_NETIF2
#include "net/gnrc/netif2/ieee802154.h"
#else
#include "net/gnrc/netdev.h"
#include "net/gnrc/netdev/ieee802154.h"
#endif
#include "net/gnrc.h"
#include "mrf24j40.h"
@ -38,19 +33,12 @@
*/
#define MRF24J40_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#ifndef MRF24J40_MAC_PRIO
#ifdef MODULE_GNRC_NETIF2
#define MRF24J40_MAC_PRIO (GNRC_NETIF2_PRIO)
#else
#define MRF24J40_MAC_PRIO (GNRC_NETDEV_MAC_PRIO)
#endif
#endif
#define MRF24J40_NUM (sizeof(mrf24j40_params) / sizeof(mrf24j40_params[0]))
static mrf24j40_t mrf24j40_devs[MRF24J40_NUM];
#ifndef MODULE_GNRC_NETIF2
static gnrc_netdev_t gnrc_adpt[MRF24J40_NUM];
#endif
static char _mrf24j40_stacks[MRF24J40_NUM][MRF24J40_MAC_STACKSIZE];
void auto_init_mrf24j40(void)
@ -59,26 +47,10 @@ void auto_init_mrf24j40(void)
LOG_DEBUG("[auto_init_netif] initializing mrf24j40 #%u\n", i);
mrf24j40_setup(&mrf24j40_devs[i], &mrf24j40_params[i]);
#ifdef MODULE_GNRC_NETIF2
gnrc_netif2_ieee802154_create(_mrf24j40_stacks[i],
MRF24J40_MAC_STACKSIZE, MRF24J40_MAC_PRIO,
"mrf24j40",
(netdev_t *)&mrf24j40_devs[i]);
#else
int res = gnrc_netdev_ieee802154_init(&gnrc_adpt[i],
(netdev_ieee802154_t *)&mrf24j40_devs[i]);
if (res < 0) {
LOG_ERROR("[auto_init_netif] error initializing mrf24j40 #%u\n", i);
}
else {
gnrc_netdev_init(_mrf24j40_stacks[i],
MRF24J40_MAC_STACKSIZE,
MRF24J40_MAC_PRIO,
"mrf24j40",
&gnrc_adpt[i]);
}
#endif
}
}
#else

View File

@ -22,24 +22,13 @@
#include "log.h"
#include "debug.h"
#include "netdev_tap_params.h"
#ifdef MODULE_GNRC_NETIF2
#include "net/gnrc/netif2/ethernet.h"
#else
#include "net/gnrc/netdev/eth.h"
#endif
#define TAP_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE)
#ifdef MODULE_GNRC_NETIF2
#define TAP_MAC_PRIO (GNRC_NETIF2_PRIO)
#else
#define TAP_MAC_PRIO (THREAD_PRIORITY_MAIN - 3)
#endif
static netdev_tap_t netdev_tap[NETDEV_TAP_MAX];
static char _netdev_eth_stack[NETDEV_TAP_MAX][TAP_MAC_STACKSIZE + DEBUG_EXTRA_STACKSIZE];
#ifndef MODULE_GNRC_NETIF2
static gnrc_netdev_t _gnrc_netdev_tap[NETDEV_TAP_MAX];
#endif
void auto_init_netdev_tap(void)
{
@ -50,17 +39,9 @@ void auto_init_netdev_tap(void)
i, *(p->tap_name));
netdev_tap_setup(&netdev_tap[i], p);
#ifdef MODULE_GNRC_NETIF2
gnrc_netif2_ethernet_create(_netdev_eth_stack[i], TAP_MAC_STACKSIZE,
TAP_MAC_PRIO, "gnrc_netdev_tap",
&netdev_tap[i].netdev);
#else
gnrc_netdev_eth_init(&_gnrc_netdev_tap[i], (netdev_t*)&netdev_tap[i]);
gnrc_netdev_init(_netdev_eth_stack[i], TAP_MAC_STACKSIZE,
TAP_MAC_PRIO, "gnrc_netdev_tap",
&_gnrc_netdev_tap[i]);
#endif
}
}

View File

@ -22,23 +22,14 @@
#include "log.h"
#include "w5100.h"
#include "w5100_params.h"
#ifdef MODULE_GNRC_NETIF2
#include "net/gnrc/netif2/ethernet.h"
#else
#include "net/gnrc/netdev.h"
#include "net/gnrc/netdev/eth.h"
#endif
/**
* @brief Define stack parameters for the MAC layer thread
* @{
*/
#define MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#ifdef MODULE_GNRC_NETIF2
#define MAC_PRIO (GNRC_NETIF2_PRIO)
#else
#define MAC_PRIO (THREAD_PRIORITY_MAIN - 4)
#endif
/*** @} */
/**
@ -51,9 +42,6 @@
* @{
*/
static w5100_t dev[W5100_NUM];
#ifndef MODULE_GNRC_NETIF2
static gnrc_netdev_t gnrc_adpt[W5100_NUM];
#endif
/** @} */
/**
@ -70,15 +58,8 @@ void auto_init_w5100(void)
/* setup netdev device */
w5100_setup(&dev[i], &w5100_params[i]);
/* initialize netdev <-> gnrc adapter state */
#ifdef MODULE_GNRC_NETIF2
gnrc_netif2_ethernet_create(stack[i], MAC_STACKSIZE, MAC_PRIO, "w5100",
(netdev_t *)&dev[i]);
#else
gnrc_netdev_eth_init(&gnrc_adpt[i], (netdev_t *)&dev[i]);
/* start gnrc netdev thread */
gnrc_netdev_init(stack[i], MAC_STACKSIZE, MAC_PRIO,
"gnrc_w5100", &gnrc_adpt[i]);
#endif
gnrc_netif2_ethernet_create(stack[i], MAC_STACKSIZE, MAC_PRIO, "w5100",
(netdev_t *)&dev[i]);
}
}

View File

@ -287,7 +287,7 @@
#include "net/gnrc/netapi.h"
#include "net/gnrc/netreg.h"
#include "net/gnrc/nettype.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/netif2.h"
#include "net/gnrc/netif/hdr.h"
#include "net/gnrc/pktbuf.h"
#include "net/gnrc/pkt.h"

View File

@ -39,7 +39,6 @@
#ifndef MODULE_GNRC_IPV6_NIB
#include "net/gnrc/ipv6/nc.h"
#endif
#include "net/gnrc/ipv6/netif.h"
#ifdef MODULE_FIB
#include "net/fib.h"

View File

@ -103,13 +103,11 @@ gnrc_rpl_instance_t *gnrc_rpl_instance_get(uint8_t instance_id);
* @param[in] instance Pointer to the instance to add the DODAG to
* @param[in] dodag_id The DODAG-ID of the new DODAG
* @param[in] iface Interface PID where the DODAG operates
* @param[in] netif_addr netif address for this DODAG
*
* @return true, if DODAG could be created.
* @return false, if DODAG could not be created or exists already.
*/
bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id, kernel_pid_t iface,
gnrc_ipv6_netif_addr_t *netif_addr);
bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id, kernel_pid_t iface);
/**
* @brief Remove all parents from the @p dodag.

View File

@ -268,7 +268,6 @@ typedef struct {
*/
struct gnrc_rpl_dodag {
ipv6_addr_t dodag_id; /**< id of the DODAG */
gnrc_ipv6_netif_addr_t *netif_addr; /**< netif address for this DODAG */
gnrc_rpl_parent_t *parents; /**< pointer to the parents list of this DODAG */
gnrc_rpl_instance_t *instance; /**< pointer to the instance that this dodag is part of */
uint8_t dtsn; /**< DAO Trigger Sequence Number */

View File

@ -22,6 +22,7 @@
#include "net/gnrc/tftp.h"
#include "net/gnrc/netapi.h"
#include "net/gnrc/netif2.h"
#include "net/gnrc/netreg.h"
#include "net/gnrc/udp.h"
#include "net/gnrc/ipv6.h"
@ -253,14 +254,13 @@ static int _tftp_server(tftp_context_t *ctxt);
static uint16_t _tftp_get_maximum_block_size(void)
{
uint16_t tmp;
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
size_t ifnum = gnrc_netif_get(ifs);
gnrc_netif2_t *netif = gnrc_netif2_iter(NULL);
if (ifnum > 0 && gnrc_netapi_get(ifs[0], NETOPT_MAX_PACKET_SIZE, 0, &tmp, sizeof(uint16_t)) >= 0) {
if ((netif != NULL) && gnrc_netapi_get(netif->pid, NETOPT_MAX_PACKET_SIZE,
0, &tmp, sizeof(uint16_t)) >= 0) {
/* TODO calculate proper block size */
return tmp - sizeof(udp_hdr_t) - sizeof(ipv6_hdr_t) - 10;
}
return GNRC_TFTP_MAX_TRANSFER_UNIT;
}

View File

@ -25,20 +25,17 @@ static kernel_pid_t gnrc_wireless_interface;
static void set_interface_roles(void)
{
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
size_t numof = gnrc_netif_get(ifs);
gnrc_netif2_t *netif = NULL;
for (size_t i = 0; i < numof && i < GNRC_NETIF_NUMOF; i++) {
kernel_pid_t dev = ifs[i];
while ((netif = gnrc_netif2_iter(netif))) {
kernel_pid_t dev = netif->pid;
int is_wired = gnrc_netapi_get(dev, NETOPT_IS_WIRED, 0, NULL, 0);
if ((!gnrc_border_interface) && (is_wired == 1)) {
ipv6_addr_t addr, defroute;
gnrc_border_interface = dev;
ipv6_addr_from_str(&addr, "fe80::2");
gnrc_ipv6_netif_add_addr(dev, &addr, 64,
GNRC_IPV6_NETIF_ADDR_FLAGS_UNICAST);
gnrc_netapi_set(dev, NETOPT_IPV6_ADDR, 64 << 8, &addr, sizeof(addr));
ipv6_addr_from_str(&defroute, "::");
ipv6_addr_from_str(&addr, "fe80::1");
fib_add_entry(&gnrc_ipv6_fib_table, dev, defroute.u8, 16,
@ -90,17 +87,17 @@ void uhcp_handle_prefix(uint8_t *prefix, uint8_t prefix_len, uint16_t lifetime,
return;
}
gnrc_ipv6_netif_add_addr(gnrc_wireless_interface, (ipv6_addr_t*)prefix, 64,
GNRC_IPV6_NETIF_ADDR_FLAGS_UNICAST |
GNRC_IPV6_NETIF_ADDR_FLAGS_NDP_AUTO);
gnrc_ipv6_netif_remove_addr(gnrc_wireless_interface, &_prefix);
gnrc_netapi_set(gnrc_wireless_interface, NETOPT_IPV6_ADDR, (64 << 8),
prefix, sizeof(ipv6_addr_t));
gnrc_netapi_set(gnrc_wireless_interface, NETOPT_IPV6_ADDR_REMOVE, 0,
&_prefix, sizeof(_prefix));
print_str("gnrc_uhcpc: uhcp_handle_prefix(): configured new prefix ");
ipv6_addr_print((ipv6_addr_t*)prefix);
puts("/64");
if (!ipv6_addr_is_unspecified(&_prefix)) {
gnrc_ipv6_netif_remove_addr(gnrc_wireless_interface, &_prefix);
gnrc_netapi_set(gnrc_wireless_interface, NETOPT_IPV6_ADDR_REMOVE, 0,
&_prefix, sizeof(_prefix));
print_str("gnrc_uhcpc: uhcp_handle_prefix(): removed old prefix ");
ipv6_addr_print(&_prefix);
puts("/64");

View File

@ -15,7 +15,7 @@
#include <stdio.h>
#include <inttypes.h>
#include "net/gnrc/netif.h"
#include "net/gnrc/netif2.h"
#include "net/gnrc/netif/hdr.h"
void gnrc_netif_hdr_print(gnrc_netif_hdr_t *hdr)
@ -44,9 +44,8 @@ void gnrc_netif_hdr_print(gnrc_netif_hdr_t *hdr)
if (hdr->src_l2addr_len > 0) {
printf("src_l2addr: %s\n",
gnrc_netif_addr_to_str(addr_str, sizeof(addr_str),
gnrc_netif_hdr_get_src_addr(hdr),
(size_t)hdr->src_l2addr_len));
gnrc_netif2_addr_to_str(gnrc_netif_hdr_get_src_addr(hdr),
hdr->src_l2addr_len, addr_str));
}
else {
puts("src_l2addr: (nil)");
@ -54,9 +53,8 @@ void gnrc_netif_hdr_print(gnrc_netif_hdr_t *hdr)
if (hdr->dst_l2addr_len > 0) {
printf("dst_l2addr: %s\n",
gnrc_netif_addr_to_str(addr_str, sizeof(addr_str),
gnrc_netif_hdr_get_dst_addr(hdr),
(size_t)hdr->dst_l2addr_len));
gnrc_netif2_addr_to_str(gnrc_netif_hdr_get_dst_addr(hdr),
hdr->dst_l2addr_len, addr_str));
}
else {
puts("dst_l2addr: (nil)");

View File

@ -34,7 +34,7 @@
#else
#include "net/gnrc/ipv6/nib.h"
#endif
#include "net/gnrc/ipv6/netif.h"
#include "net/gnrc/netif2/internal.h"
#include "net/gnrc/ipv6/whitelist.h"
#include "net/gnrc/ipv6/blacklist.h"
@ -394,24 +394,22 @@ static void *_event_loop(void *args)
return NULL;
}
static void _send_to_iface(kernel_pid_t iface, gnrc_pktsnip_t *pkt)
static void _send_to_iface(gnrc_netif2_t *netif, gnrc_pktsnip_t *pkt)
{
((gnrc_netif_hdr_t *)pkt->data)->if_pid = iface;
gnrc_ipv6_netif_t *if_entry = gnrc_ipv6_netif_get(iface);
assert(if_entry != NULL);
if (gnrc_pkt_len(pkt->next) > if_entry->mtu) {
assert(netif != NULL);
((gnrc_netif_hdr_t *)pkt->data)->if_pid = netif->pid;
if (gnrc_pkt_len(pkt->next) > netif->ipv6.mtu) {
DEBUG("ipv6: packet too big\n");
gnrc_pktbuf_release(pkt);
return;
}
#ifdef MODULE_NETSTATS_IPV6
if_entry->stats.tx_success++;
if_entry->stats.tx_bytes += gnrc_pkt_len(pkt->next);
netif->ipv6.stats.tx_success++;
netif->ipv6.stats.tx_bytes += gnrc_pkt_len(pkt->next);
#endif
#ifdef MODULE_GNRC_SIXLOWPAN
if (if_entry->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN) {
if (gnrc_netif2_is_6ln(netif)) {
DEBUG("ipv6: send to 6LoWPAN instead\n");
if (!gnrc_netapi_dispatch_send(GNRC_NETTYPE_SIXLOWPAN, GNRC_NETREG_DEMUX_CTX_ALL, pkt)) {
DEBUG("ipv6: no 6LoWPAN thread found\n");
@ -420,7 +418,7 @@ static void _send_to_iface(kernel_pid_t iface, gnrc_pktsnip_t *pkt)
return;
}
#endif
if (gnrc_netapi_send(iface, pkt) < 1) {
if (gnrc_netapi_send(netif->pid, pkt) < 1) {
DEBUG("ipv6: unable to send packet\n");
gnrc_pktbuf_release(pkt);
}
@ -430,9 +428,9 @@ static gnrc_pktsnip_t *_create_netif_hdr(uint8_t *dst_l2addr,
uint16_t dst_l2addr_len,
gnrc_pktsnip_t *pkt)
{
gnrc_pktsnip_t *netif = gnrc_netif_hdr_build(NULL, 0, dst_l2addr, dst_l2addr_len);
gnrc_pktsnip_t *netif_hdr = gnrc_netif_hdr_build(NULL, 0, dst_l2addr, dst_l2addr_len);
if (netif == NULL) {
if (netif_hdr == NULL) {
DEBUG("ipv6: error on interface header allocation, dropping packet\n");
gnrc_pktbuf_release(pkt);
return NULL;
@ -443,39 +441,39 @@ static gnrc_pktsnip_t *_create_netif_hdr(uint8_t *dst_l2addr,
* cause to much overhead.
* netif header might have been allocated by some higher layer either
* to set a sending interface or some flags. Interface was already
* copied using iface parameter, so we only need to copy the flags
* copied using netif parameter, so we only need to copy the flags
* (minus the broadcast/multicast flags) */
DEBUG("ipv6: copy old interface header flags\n");
gnrc_netif_hdr_t *netif_new = netif->data, *netif_old = pkt->data;
gnrc_netif_hdr_t *netif_new = netif_hdr->data, *netif_old = pkt->data;
netif_new->flags = netif_old->flags & \
~(GNRC_NETIF_HDR_FLAGS_BROADCAST | GNRC_NETIF_HDR_FLAGS_MULTICAST);
DEBUG("ipv6: removed old interface header\n");
pkt = gnrc_pktbuf_remove_snip(pkt, pkt);
}
/* add netif to front of the pkt list */
LL_PREPEND(pkt, netif);
/* add netif_hdr to front of the pkt list */
LL_PREPEND(pkt, netif_hdr);
return pkt;
}
/* functions for sending */
static void _send_unicast(kernel_pid_t iface, uint8_t *dst_l2addr,
static void _send_unicast(gnrc_netif2_t *netif, uint8_t *dst_l2addr,
uint16_t dst_l2addr_len, gnrc_pktsnip_t *pkt)
{
DEBUG("ipv6: add interface header to packet\n");
if ((pkt = _create_netif_hdr(dst_l2addr, dst_l2addr_len, pkt)) == NULL) {
return;
}
DEBUG("ipv6: send unicast over interface %" PRIkernel_pid "\n", iface);
DEBUG("ipv6: send unicast over interface %" PRIkernel_pid "\n", netif->pid);
/* and send to interface */
#ifdef MODULE_NETSTATS_IPV6
gnrc_ipv6_netif_get_stats(iface)->tx_unicast_count++;
netif->ipv6.stats.tx_unicast_count++;
#endif
_send_to_iface(iface, pkt);
_send_to_iface(netif, pkt);
}
static int _fill_ipv6_hdr(kernel_pid_t iface, gnrc_pktsnip_t *ipv6,
static int _fill_ipv6_hdr(gnrc_netif2_t *netif, gnrc_pktsnip_t *ipv6,
gnrc_pktsnip_t *payload)
{
int res;
@ -498,11 +496,11 @@ static int _fill_ipv6_hdr(kernel_pid_t iface, gnrc_pktsnip_t *ipv6,
DEBUG("ipv6: set next header to %u\n", hdr->nh);
if (hdr->hl == 0) {
if (iface == KERNEL_PID_UNDEF) {
if (netif == NULL) {
hdr->hl = GNRC_IPV6_NETIF_DEFAULT_HL;
}
else {
hdr->hl = gnrc_ipv6_netif_get(iface)->cur_hl;
hdr->hl = netif->cur_hl;
}
}
@ -511,7 +509,8 @@ static int _fill_ipv6_hdr(kernel_pid_t iface, gnrc_pktsnip_t *ipv6,
ipv6_addr_set_loopback(&hdr->src);
}
else {
ipv6_addr_t *src = gnrc_ipv6_netif_find_best_src_addr(iface, &hdr->dst, false);
ipv6_addr_t *src = gnrc_netif2_ipv6_addr_best_src(netif, &hdr->dst,
false);
if (src != NULL) {
DEBUG("ipv6: set packet source to %s\n",
@ -534,29 +533,27 @@ static int _fill_ipv6_hdr(kernel_pid_t iface, gnrc_pktsnip_t *ipv6,
return 0;
}
static inline void _send_multicast_over_iface(kernel_pid_t iface, gnrc_pktsnip_t *pkt)
static inline void _send_multicast_over_iface(gnrc_netif2_t *netif,
gnrc_pktsnip_t *pkt)
{
DEBUG("ipv6: send multicast over interface %" PRIkernel_pid "\n", iface);
DEBUG("ipv6: send multicast over interface %" PRIkernel_pid "\n", netif->pid);
/* mark as multicast */
((gnrc_netif_hdr_t *)pkt->data)->flags |= GNRC_NETIF_HDR_FLAGS_MULTICAST;
#ifdef MODULE_NETSTATS_IPV6
gnrc_ipv6_netif_get_stats(iface)->tx_mcast_count++;
netif->ipv6.stats.tx_mcast_count++;
#endif
/* and send to interface */
_send_to_iface(iface, pkt);
_send_to_iface(netif, pkt);
}
static void _send_multicast(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
static void _send_multicast(gnrc_netif2_t *netif, gnrc_pktsnip_t *pkt,
gnrc_pktsnip_t *ipv6, gnrc_pktsnip_t *payload,
bool prep_hdr)
{
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
size_t ifnum = 0;
if (iface == KERNEL_PID_UNDEF) {
/* get list of interfaces */
ifnum = gnrc_netif_get(ifs);
if (netif == NULL) {
ifnum = gnrc_netif2_numof();
/* throw away packet if no one is interested */
if (ifnum == 0) {
DEBUG("ipv6: no interfaces registered, dropping packet\n");
@ -568,11 +565,11 @@ static void _send_multicast(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
#if GNRC_NETIF_NUMOF > 1
/* interface not given: send over all interfaces */
if (iface == KERNEL_PID_UNDEF) {
if (netif == NULL) {
/* send packet to link layer */
gnrc_pktbuf_hold(pkt, ifnum - 1);
for (size_t i = 0; i < ifnum; i++) {
while ((netif = gnrc_netif2_iter(netif))) {
if (prep_hdr) {
/* need to get second write access (duplication) to fill IPv6
* header interface-local */
@ -582,7 +579,7 @@ static void _send_multicast(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
if (ipv6 == NULL) {
DEBUG("ipv6: unable to get write access to IPv6 header, "
"for interface %" PRIkernel_pid "\n", ifs[i]);
"for interface %" PRIkernel_pid "\n", netif->pid);
gnrc_pktbuf_release(pkt);
return;
}
@ -601,7 +598,7 @@ static void _send_multicast(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
ptr = ptr->next;
}
if (_fill_ipv6_hdr(ifs[i], ipv6, tmp) < 0) {
if (_fill_ipv6_hdr(netif, ipv6, tmp) < 0) {
/* error on filling up header */
gnrc_pktbuf_release(ipv6);
return;
@ -612,24 +609,24 @@ static void _send_multicast(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
return;
}
_send_multicast_over_iface(ifs[i], ipv6);
_send_multicast_over_iface(netif, ipv6);
}
}
else {
if (prep_hdr) {
if (_fill_ipv6_hdr(iface, ipv6, payload) < 0) {
if (_fill_ipv6_hdr(netif, ipv6, payload) < 0) {
/* error on filling up header */
gnrc_pktbuf_release(pkt);
return;
}
}
_send_multicast_over_iface(iface, pkt);
_send_multicast_over_iface(netif, pkt);
}
#else /* GNRC_NETIF_NUMOF */
(void)ifnum; /* not used in this build branch */
if (iface == KERNEL_PID_UNDEF) {
iface = ifs[0];
if (netif == NULL) {
netif = gnrc_netif2_iter(NULL);
/* allocate interface header */
if ((pkt = _create_netif_hdr(NULL, 0, pkt)) == NULL) {
@ -638,14 +635,14 @@ static void _send_multicast(kernel_pid_t iface, gnrc_pktsnip_t *pkt,
}
if (prep_hdr) {
if (_fill_ipv6_hdr(iface, ipv6, payload) < 0) {
if (_fill_ipv6_hdr(netif, ipv6, payload) < 0) {
/* error on filling up header */
gnrc_pktbuf_release(pkt);
return;
}
}
_send_multicast_over_iface(iface, pkt);
_send_multicast_over_iface(netif, pkt);
#endif /* GNRC_NETIF_NUMOF */
}
@ -685,7 +682,6 @@ static void _send(gnrc_pktsnip_t *pkt, bool prep_hdr)
{
kernel_pid_t iface = KERNEL_PID_UNDEF;
gnrc_pktsnip_t *ipv6, *payload;
ipv6_addr_t *tmp;
ipv6_hdr_t *hdr;
/* get IPv6 snip and (if present) generic interface header */
if (pkt->type == GNRC_NETTYPE_NETIF) {
@ -725,19 +721,23 @@ static void _send(gnrc_pktsnip_t *pkt, bool prep_hdr)
hdr = ipv6->data;
payload = ipv6->next;
gnrc_netif2_t *netif = (iface == KERNEL_PID_UNDEF) ?
NULL :
gnrc_netif2_get_by_pid(iface);
if (ipv6_addr_is_multicast(&hdr->dst)) {
_send_multicast(iface, pkt, ipv6, payload, prep_hdr);
_send_multicast(netif, pkt, ipv6, payload, prep_hdr);
}
else if ((ipv6_addr_is_loopback(&hdr->dst)) || /* dst is loopback address */
((iface == KERNEL_PID_UNDEF) && /* or dst registered to any local interface */
((iface = gnrc_ipv6_netif_find_by_addr(&tmp, &hdr->dst)) != KERNEL_PID_UNDEF)) ||
((iface != KERNEL_PID_UNDEF) && /* or dst registered to given interface */
(gnrc_ipv6_netif_find_addr(iface, &hdr->dst) != NULL))) {
((netif = gnrc_netif2_get_by_ipv6_addr(&hdr->dst)) != NULL)
) || ((iface != KERNEL_PID_UNDEF) && /* or dst registered to given interface */
(gnrc_netif2_ipv6_addr_idx(netif, &hdr->dst) > 0)
)) {
uint8_t *rcv_data;
gnrc_pktsnip_t *ptr = ipv6, *rcv_pkt;
if (prep_hdr) {
if (_fill_ipv6_hdr(iface, ipv6, payload) < 0) {
if (_fill_ipv6_hdr(netif, ipv6, payload) < 0) {
/* error on filling up header */
gnrc_pktbuf_release(pkt);
return;
@ -782,16 +782,17 @@ static void _send(gnrc_pktsnip_t *pkt, bool prep_hdr)
gnrc_pktbuf_release(pkt);
return;
}
netif = gnrc_netif2_get_by_pid(iface);
assert(netif != NULL);
if (prep_hdr) {
if (_fill_ipv6_hdr(iface, ipv6, payload) < 0) {
if (_fill_ipv6_hdr(netif, ipv6, payload) < 0) {
/* error on filling up header */
gnrc_pktbuf_release(pkt);
return;
}
}
_send_unicast(iface, l2addr, l2addr_len, pkt);
_send_unicast(netif, l2addr, l2addr_len, pkt);
#else /* MODULE_GNRC_IPV6_NIB */
gnrc_ipv6_nib_nc_t nce;
@ -800,16 +801,18 @@ static void _send(gnrc_pktsnip_t *pkt, bool prep_hdr)
/* packet is released by NIB */
return;
}
iface = gnrc_ipv6_nib_nc_get_iface(&nce);
netif = gnrc_netif2_get_by_pid(iface);
assert(netif != NULL);
if (prep_hdr) {
if (_fill_ipv6_hdr(iface, ipv6, payload) < 0) {
if (_fill_ipv6_hdr(netif, ipv6, payload) < 0) {
/* error on filling up header */
gnrc_pktbuf_release(pkt);
return;
}
}
_send_unicast(gnrc_ipv6_nib_nc_get_iface(&nce), nce.l2addr,
_send_unicast(netif, nce.l2addr,
nce.l2addr_len, pkt);
#endif /* MODULE_GNRC_IPV6_NIB */
}
@ -823,15 +826,15 @@ static inline bool _pkt_not_for_me(kernel_pid_t *iface, ipv6_hdr_t *hdr)
}
else if ((!ipv6_addr_is_link_local(&hdr->dst)) ||
(*iface == KERNEL_PID_UNDEF)) {
kernel_pid_t if_pid = gnrc_ipv6_netif_find_by_addr(NULL, &hdr->dst);
gnrc_netif2_t *netif = gnrc_netif2_get_by_ipv6_addr(&hdr->dst);
if (*iface == KERNEL_PID_UNDEF) {
*iface = if_pid; /* Use original interface for reply if
* existent */
/* Use original interface for reply if existent */
*iface = (netif != NULL) ? netif->pid : KERNEL_PID_UNDEF;
}
return (if_pid == KERNEL_PID_UNDEF);
return (netif == NULL);
}
else {
return (gnrc_ipv6_netif_find_addr(*iface, &hdr->dst) == NULL);
return (gnrc_netif2_get_by_ipv6_addr(&hdr->dst) == NULL);
}
}
@ -850,7 +853,7 @@ static void _receive(gnrc_pktsnip_t *pkt)
#ifdef MODULE_NETSTATS_IPV6
assert(iface);
netstats_t *stats = gnrc_ipv6_netif_get_stats(iface);
netstats_t *stats = &(gnrc_netif2_get_by_pid(iface)->ipv6.stats);
stats->rx_count++;
stats->rx_bytes += (gnrc_pkt_len(pkt) - netif->size);
#endif

View File

@ -21,7 +21,7 @@
#include "net/gnrc/netapi.h"
#include "net/gnrc/netif/hdr.h"
#include "net/gnrc/sixlowpan/frag.h"
#include "net/gnrc/sixlowpan/netif.h"
#include "net/gnrc/netif2.h"
#include "net/sixlowpan.h"
#include "utlist.h"
@ -81,7 +81,7 @@ static gnrc_pktsnip_t *_build_frag_pkt(gnrc_pktsnip_t *pkt, size_t payload_len,
return frag;
}
static uint16_t _send_1st_fragment(gnrc_sixlowpan_netif_t *iface, gnrc_pktsnip_t *pkt,
static uint16_t _send_1st_fragment(gnrc_netif2_t *iface, gnrc_pktsnip_t *pkt,
size_t payload_len, size_t datagram_size)
{
gnrc_pktsnip_t *frag;
@ -91,7 +91,7 @@ static uint16_t _send_1st_fragment(gnrc_sixlowpan_netif_t *iface, gnrc_pktsnip_t
int payload_diff = (datagram_size - payload_len);
/* virtually add payload_diff to flooring to account for offset (must be divisable by 8)
* in uncompressed datagram */
uint16_t max_frag_size = _floor8(iface->max_frag_size + payload_diff -
uint16_t max_frag_size = _floor8(iface->sixlo.max_frag_size + payload_diff -
sizeof(sixlowpan_frag_t)) - payload_diff;
sixlowpan_frag_t *hdr;
uint8_t *data;
@ -138,14 +138,14 @@ static uint16_t _send_1st_fragment(gnrc_sixlowpan_netif_t *iface, gnrc_pktsnip_t
return local_offset;
}
static uint16_t _send_nth_fragment(gnrc_sixlowpan_netif_t *iface, gnrc_pktsnip_t *pkt,
static uint16_t _send_nth_fragment(gnrc_netif2_t *iface, gnrc_pktsnip_t *pkt,
size_t payload_len, size_t datagram_size,
uint16_t offset)
{
gnrc_pktsnip_t *frag;
/* since dispatches aren't supposed to go into subsequent fragments, we need not account
* for payload difference as for the first fragment */
uint16_t max_frag_size = _floor8(iface->max_frag_size - sizeof(sixlowpan_frag_n_t));
uint16_t max_frag_size = _floor8(iface->sixlo.max_frag_size - sizeof(sixlowpan_frag_n_t));
uint16_t local_offset = 0, offset_count = 0;
sixlowpan_frag_n_t *hdr;
uint8_t *data;
@ -218,7 +218,7 @@ static uint16_t _send_nth_fragment(gnrc_sixlowpan_netif_t *iface, gnrc_pktsnip_t
void gnrc_sixlowpan_frag_send(gnrc_sixlowpan_msg_frag_t *fragment_msg)
{
gnrc_sixlowpan_netif_t *iface = gnrc_sixlowpan_netif_get(fragment_msg->pid);
gnrc_netif2_t *iface = gnrc_netif2_get_by_pid(fragment_msg->pid);
uint16_t res;
/* payload_len: actual size of the packet vs
* datagram_size: size of the uncompressed IPv6 packet */

View File

@ -237,10 +237,11 @@ static bool _rbuf_update_ints(rbuf_t *entry, uint16_t offset, size_t frag_size)
new->end = end;
DEBUG("6lo rfrag: add interval (%" PRIu16 ", %" PRIu16 ") to entry (%s, ",
new->start, new->end, gnrc_netif_addr_to_str(l2addr_str,
sizeof(l2addr_str), entry->src, entry->src_len));
DEBUG("%s, %u, %u)\n", gnrc_netif_addr_to_str(l2addr_str,
sizeof(l2addr_str), entry->dst, entry->dst_len),
new->start, new->end, gnrc_netif2_addr_to_str(entry->src,
entry->src_len,
l2addr_str));
DEBUG("%s, %u, %u)\n", gnrc_netif2_addr_to_str(entry->dst, entry->dst_len,
l2addr_str),
(unsigned)entry->pkt->size, entry->tag);
LL_PREPEND(entry->ints, new);
@ -257,11 +258,12 @@ static void _rbuf_gc(void)
/* since pkt occupies pktbuf, aggressivly collect garbage */
if ((rbuf[i].pkt != NULL) &&
((now_usec - rbuf[i].arrival) > RBUF_TIMEOUT)) {
DEBUG("6lo rfrag: entry (%s, ", gnrc_netif_addr_to_str(l2addr_str,
sizeof(l2addr_str), rbuf[i].src, rbuf[i].src_len));
DEBUG("6lo rfrag: entry (%s, ",
gnrc_netif2_addr_to_str(rbuf[i].src, rbuf[i].src_len,
l2addr_str));
DEBUG("%s, %u, %u) timed out\n",
gnrc_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), rbuf[i].dst,
rbuf[i].dst_len),
gnrc_netif2_addr_to_str(rbuf[i].dst, rbuf[i].dst_len,
l2addr_str),
(unsigned)rbuf[i].pkt->size, rbuf[i].tag);
gnrc_pktbuf_release(rbuf[i].pkt);
@ -285,11 +287,11 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
(memcmp(rbuf[i].src, src, src_len) == 0) &&
(memcmp(rbuf[i].dst, dst, dst_len) == 0)) {
DEBUG("6lo rfrag: entry %p (%s, ", (void *)(&rbuf[i]),
gnrc_netif_addr_to_str(l2addr_str, sizeof(l2addr_str),
rbuf[i].src, rbuf[i].src_len));
gnrc_netif2_addr_to_str(rbuf[i].src, rbuf[i].src_len,
l2addr_str));
DEBUG("%s, %u, %u) found\n",
gnrc_netif_addr_to_str(l2addr_str, sizeof(l2addr_str),
rbuf[i].dst, rbuf[i].dst_len),
gnrc_netif2_addr_to_str(rbuf[i].dst, rbuf[i].dst_len,
l2addr_str),
(unsigned)rbuf[i].pkt->size, rbuf[i].tag);
rbuf[i].arrival = now_usec;
return &(rbuf[i]);
@ -336,11 +338,9 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
res->cur_size = 0;
DEBUG("6lo rfrag: entry %p (%s, ", (void *)res,
gnrc_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), res->src,
res->src_len));
gnrc_netif2_addr_to_str(res->src, res->src_len, l2addr_str));
DEBUG("%s, %u, %u) created\n",
gnrc_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), res->dst,
res->dst_len), (unsigned)res->pkt->size,
gnrc_netif2_addr_to_str(res->dst, res->dst_len, l2addr_str), (unsigned)res->pkt->size,
res->tag);
return res;

View File

@ -21,7 +21,7 @@
#include "net/gnrc/sixlowpan.h"
#include "net/gnrc/sixlowpan/frag.h"
#include "net/gnrc/sixlowpan/iphc.h"
#include "net/gnrc/sixlowpan/netif.h"
#include "net/gnrc/netif2.h"
#include "net/sixlowpan.h"
#define ENABLE_DEBUG (0)
@ -192,7 +192,7 @@ static void _send(gnrc_pktsnip_t *pkt)
{
gnrc_netif_hdr_t *hdr;
gnrc_pktsnip_t *pkt2;
gnrc_sixlowpan_netif_t *iface;
gnrc_netif2_t *iface;
/* datagram_size: pure IPv6 packet without 6LoWPAN dispatches or compression */
size_t datagram_size;
@ -217,7 +217,7 @@ static void _send(gnrc_pktsnip_t *pkt)
}
hdr = pkt2->data;
iface = gnrc_sixlowpan_netif_get(hdr->if_pid);
iface = gnrc_netif2_get_by_pid(hdr->if_pid);
datagram_size = gnrc_pkt_len(pkt2->next);
if (iface == NULL) {
@ -227,7 +227,7 @@ static void _send(gnrc_pktsnip_t *pkt)
}
#ifdef MODULE_GNRC_SIXLOWPAN_IPHC
if (iface->iphc_enabled) {
if (iface->flags & GNRC_NETIF2_FLAGS_6LO_HC) {
if (!gnrc_sixlowpan_iphc_encode(pkt2)) {
DEBUG("6lo: error on IPHC encoding\n");
gnrc_pktbuf_release(pkt2);
@ -254,14 +254,14 @@ static void _send(gnrc_pktsnip_t *pkt)
return;
}
#endif
DEBUG("6lo: iface->max_frag_size = %" PRIu16 " for interface %"
PRIkernel_pid "\n", iface->max_frag_size, hdr->if_pid);
DEBUG("6lo: iface->sixlo.max_frag_size = %" PRIu16 " for interface %"
PRIkernel_pid "\n", iface->sixlo.max_frag_size, hdr->if_pid);
/* IP should not send anything here if it is not a 6LoWPAN interface,
* so we don't need to check for NULL pointers.
* Note, that datagram_size cannot be used here, because the header size
* might be changed by IPHC. */
if (gnrc_pkt_len(pkt2->next) <= iface->max_frag_size) {
if (gnrc_pkt_len(pkt2->next) <= iface->sixlo.max_frag_size) {
DEBUG("6lo: Send SND command for %p to %" PRIu16 "\n",
(void *)pkt2, hdr->if_pid);
if (gnrc_netapi_send(hdr->if_pid, pkt2) < 1) {

View File

@ -13,9 +13,9 @@
*/
#include "net/eui64.h"
#include "net/icmpv6.h"
#include "net/gnrc/ipv6.h"
#include "net/gnrc/ndp.h"
#include "net/gnrc/ndp/internal.h"
#include "net/gnrc/ndp2.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/sixlowpan.h"
#include "net/gnrc/sixlowpan/ctx.h"
@ -26,223 +26,10 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
static inline void _rtr_sol_reschedule(gnrc_ipv6_netif_t *iface, uint32_t sec_delay)
{
xtimer_remove(&iface->rtr_sol_timer);
iface->rtr_sol_msg.type = GNRC_SIXLOWPAN_ND_MSG_MC_RTR_SOL;
iface->rtr_sol_msg.content.ptr = iface;
xtimer_set_msg(&iface->rtr_sol_timer, sec_delay * US_PER_SEC, &iface->rtr_sol_msg,
gnrc_ipv6_pid);
}
static inline uint32_t _binary_exp_backoff(uint32_t base_sec, unsigned int exp)
{
return random_uint32_range(0, (1 << exp)) * base_sec;
}
static inline void _revert_iid(uint8_t *iid)
{
iid[0] ^= 0x02;
}
void gnrc_sixlowpan_nd_init(gnrc_ipv6_netif_t *iface)
{
assert(iface->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN);
mutex_lock(&iface->mutex);
iface->rtr_sol_count = 0; /* first will be sent immediately */
DEBUG("6lo nd: retransmit multicast rtr sol in 10 sec\n");
#ifndef MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER
_rtr_sol_reschedule(iface, GNRC_SIXLOWPAN_ND_RTR_SOL_INT);
#endif
mutex_unlock(&iface->mutex);
#ifndef MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER
gnrc_ndp_internal_send_rtr_sol(iface->pid, NULL);
#endif
}
void gnrc_sixlowpan_nd_mc_rtr_sol(gnrc_ipv6_netif_t *iface)
{
uint32_t interval;
assert(iface->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN);
mutex_lock(&iface->mutex);
if (iface->rtr_sol_count < GNRC_NDP_MAX_RTR_SOL_NUMOF) {
DEBUG("6lo nd: retransmit multicast rtr sol in 10 sec\n");
iface->rtr_sol_count++;
interval = GNRC_SIXLOWPAN_ND_RTR_SOL_INT;
}
else {
unsigned int exp = (unsigned int)(iface->rtr_sol_count - GNRC_NDP_MAX_RTR_SOL_NUMOF);
interval = _binary_exp_backoff(1, exp);
if ((1U << exp) < GNRC_SIXLOWPAN_ND_MAX_RTR_SOL_INT) {
/* XXX Not sure if this is the correct interpretation of the truncation described in
* https://tools.ietf.org/html/rfc6775#section-5.3. In every source I've read the
* truncating value was the exponent, not the target value, so I'm very confused
* about this sentencing. Anyway, since 60 sec is a maximum value this should only
* affect the energy consumption of the implementation by sending the next RS too fast
* but not its interoperability. */
iface->rtr_sol_count++;
}
/* RFC6775, section 5.3 (https://tools.ietf.org/html/rfc6775#section-5.3)
* states that router solicitation should be sent slower after the
* initial 3 retransmissions (i.e. >= 10 secondes) and truncate "the
* increase of the retransmission timer at 60 seconds". */
if (interval < GNRC_SIXLOWPAN_ND_RTR_SOL_INT) {
interval = GNRC_SIXLOWPAN_ND_RTR_SOL_INT;
}
else if (interval > GNRC_SIXLOWPAN_ND_MAX_RTR_SOL_INT) {
interval = GNRC_SIXLOWPAN_ND_MAX_RTR_SOL_INT;
}
DEBUG("6lo nd: retransmit multicast rtr sol in %" PRIu32 " sec\n", interval);
}
_rtr_sol_reschedule(iface, interval);
mutex_unlock(&iface->mutex);
gnrc_ndp_internal_send_rtr_sol(iface->pid, NULL);
}
void gnrc_sixlowpan_nd_uc_rtr_sol(gnrc_ipv6_nc_t *nce)
{
assert(gnrc_ipv6_netif_get(nce->iface)->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN);
/* neighbor is not a router anymore */
if (!(nce->flags & GNRC_IPV6_NC_IS_ROUTER) || ipv6_addr_is_unspecified(&nce->ipv6_addr)) {
/* and there are no routers anymore */
if (gnrc_ipv6_nc_get_next_router(NULL) == NULL) {
/* start search for routers */
gnrc_sixlowpan_nd_init(gnrc_ipv6_netif_get(nce->iface));
}
/* otherwise ignore this call */
return;
}
/* next RS is rescheduled by RA handle function */
gnrc_ndp_internal_send_rtr_sol(nce->iface, &nce->ipv6_addr);
}
kernel_pid_t gnrc_sixlowpan_nd_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
kernel_pid_t iface, ipv6_addr_t *dst)
{
ipv6_addr_t *next_hop = NULL;
gnrc_ipv6_nc_t *nc_entry = NULL;
#ifdef MODULE_FIB
kernel_pid_t fib_iface;
ipv6_addr_t next_hop_actual; /* FIB copies address into this variable */
/* don't look-up link local addresses in FIB */
if (!ipv6_addr_is_link_local(dst)) {
size_t next_hop_size = sizeof(ipv6_addr_t);
uint32_t next_hop_flags = 0;
if ((next_hop == NULL) &&
(fib_get_next_hop(&gnrc_ipv6_fib_table, &fib_iface, next_hop_actual.u8, &next_hop_size,
&next_hop_flags, (uint8_t *)dst,
sizeof(ipv6_addr_t), 0) >= 0) &&
(next_hop_size == sizeof(ipv6_addr_t))) {
next_hop = &next_hop_actual;
}
}
#endif
#ifdef MODULE_GNRC_SIXLOWPAN_ND_ROUTER
/* next hop determination: https://tools.ietf.org/html/rfc6775#section-6.5.4 */
/* cppcheck-suppress redundantAssignment
* This path is only present for a certain configuration */
nc_entry = gnrc_ipv6_nc_get(iface, dst);
#ifdef MODULE_FIB
if ((next_hop != NULL) && (nc_entry == NULL)) {
nc_entry = gnrc_ipv6_nc_get(fib_iface, dst);
}
#endif
/* if NCE found */
if (nc_entry != NULL) {
gnrc_ipv6_netif_t *ipv6_if = gnrc_ipv6_netif_get(nc_entry->iface);
/* and interface is not 6LoWPAN */
if (!((ipv6_if == NULL) ||
(ipv6_if->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN)) ||
/* or entry is registered */
(gnrc_ipv6_nc_get_type(nc_entry) == GNRC_IPV6_NC_TYPE_REGISTERED)) {
next_hop = dst;
}
}
#endif
/* next hop determination according to: https://tools.ietf.org/html/rfc6775#section-5.6 */
/* cppcheck-suppress knownConditionTrueFalse
* cppcheck bug: next_hop might be set before */
if ((next_hop == NULL) && ipv6_addr_is_link_local(dst)) { /* prefix is "on-link" */
/* multicast is not handled here anyway so we don't need to check that */
next_hop = dst;
}
else if (next_hop == NULL) { /* prefix is off-link */
next_hop = gnrc_ndp_internal_default_router();
}
/* no routers found */
if (next_hop == NULL) {
return KERNEL_PID_UNDEF;
}
/* address resolution of next_hop: https://tools.ietf.org/html/rfc6775#section-5.7 */
/* cppcheck-suppress knownConditionTrueFalse
* cppcheck bug: nc_entry might be set before */
if ((nc_entry == NULL) || (next_hop != dst)) {
/* get if not gotten from previous check */
nc_entry = gnrc_ipv6_nc_get(iface, next_hop);
}
/* If a (non-tentative) NCE for this destination exist, we can use even for
* link-local addresses. This should be only the case for 6LBRs. */
if ((ipv6_addr_is_link_local(next_hop)) &&
((nc_entry == NULL) ||
(gnrc_ipv6_nc_get_type(nc_entry) == GNRC_IPV6_NC_TYPE_TENTATIVE))) {
/* in case of a border router there is no sensible way for address resolution
* if the interface is not given */
#ifdef MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER
/* if no interface is specified it is impossible to resolve the
* link-layer address for a link-local address on a 6LBR */
if (iface == KERNEL_PID_UNDEF) {
return KERNEL_PID_UNDEF;
}
#endif
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
size_t ifnum = gnrc_netif_get(ifs);
/* we don't need address resolution, the EUI-64 is in next_hop's IID */
*l2addr_len = sizeof(eui64_t);
memcpy(l2addr, &next_hop->u8[8], sizeof(eui64_t));
_revert_iid(l2addr);
if (iface == KERNEL_PID_UNDEF) {
for (unsigned i = 0; i < ifnum; i++) {
gnrc_ipv6_netif_t *ipv6_if = gnrc_ipv6_netif_get(ifs[i]);
if ((ipv6_if != NULL) && (ipv6_if->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN)) {
/* always take the first 6LoWPAN interface we can find */
return ifs[i];
}
}
}
return iface;
}
if ((gnrc_ipv6_nc_get_type(nc_entry) == GNRC_IPV6_NC_TYPE_TENTATIVE)) {
return KERNEL_PID_UNDEF;
}
else {
if (gnrc_ipv6_nc_get_state(nc_entry) == GNRC_IPV6_NC_STATE_STALE) {
gnrc_ndp_internal_set_state(nc_entry, GNRC_IPV6_NC_STATE_DELAY);
}
}
return gnrc_ipv6_nc_get_l2_addr(l2addr, l2addr_len, nc_entry);
}
void gnrc_sixlowpan_nd_rtr_sol_reschedule(gnrc_ipv6_nc_t *nce, uint32_t sec_delay)
{
assert(nce != NULL);
assert(sec_delay != 0U);
gnrc_ipv6_netif_t *iface = gnrc_ipv6_netif_get(nce->iface);
xtimer_remove(&iface->rtr_sol_timer);
iface->rtr_sol_msg.type = GNRC_SIXLOWPAN_ND_MSG_MC_RTR_SOL;
iface->rtr_sol_msg.content.ptr = iface;
xtimer_set_msg(&iface->rtr_sol_timer, sec_delay * US_PER_SEC, &iface->rtr_sol_msg,
gnrc_ipv6_pid);
}
gnrc_pktsnip_t *gnrc_sixlowpan_nd_opt_ar_build(uint8_t status, uint16_t ltime, eui64_t *eui64,
gnrc_pktsnip_t *next)
{
gnrc_pktsnip_t *pkt = gnrc_ndp_opt_build(NDP_OPT_AR, sizeof(sixlowpan_nd_opt_ar_t), next);
gnrc_pktsnip_t *pkt = gnrc_ndp2_opt_build(NDP_OPT_AR, sizeof(sixlowpan_nd_opt_ar_t), next);
if (pkt != NULL) {
sixlowpan_nd_opt_ar_t *ar_opt = pkt->data;
@ -255,157 +42,6 @@ gnrc_pktsnip_t *gnrc_sixlowpan_nd_opt_ar_build(uint8_t status, uint16_t ltime, e
return pkt;
}
uint8_t gnrc_sixlowpan_nd_opt_ar_handle(kernel_pid_t iface, ipv6_hdr_t *ipv6,
uint8_t icmpv6_type, ipv6_addr_t *addr,
sixlowpan_nd_opt_ar_t *ar_opt,
uint8_t *sl2a, size_t sl2a_len)
{
eui64_t eui64;
gnrc_ipv6_netif_t *ipv6_iface;
gnrc_ipv6_nc_t *nc_entry;
uint8_t status = 0;
(void)sl2a;
(void)sl2a_len;
if (ar_opt->len != SIXLOWPAN_ND_OPT_AR_LEN) {
/* discard silently: see https://tools.ietf.org/html/rfc6775#section-5.5.2 */
return 0;
}
if (gnrc_netapi_get(iface, NETOPT_ADDRESS_LONG, 0, &eui64,
sizeof(eui64)) < 0) {
/* discard silently: see https://tools.ietf.org/html/rfc6775#section-5.5.2 */
return 0;
}
ipv6_iface = gnrc_ipv6_netif_get(iface);
nc_entry = gnrc_ipv6_nc_get(iface, addr);
switch (icmpv6_type) {
case ICMPV6_NBR_ADV:
if (!(ipv6_iface->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN)) {
DEBUG("6lo nd: interface not a 6LoWPAN interface\n");
return 0;
}
if (eui64.uint64.u64 != ar_opt->eui64.uint64.u64) {
/* discard silently: see https://tools.ietf.org/html/rfc6775#section-5.5.2 */
return 0;
}
/* we expect the sender to be already in neighbor cache, if not we
* ignore it */
if (nc_entry == NULL) {
DEBUG("6lo nd: sending router not in neighbor cache\n");
return 0;
}
switch (ar_opt->status) {
case SIXLOWPAN_ND_STATUS_SUCCESS:
DEBUG("6lo nd: address registration successful\n");
mutex_lock(&ipv6_iface->mutex);
/* reschedule 1 minute before lifetime expires */
gnrc_ndp_internal_reset_nbr_sol_timer(nc_entry, US_PER_SEC * 60 *
(uint32_t)(byteorder_ntohs(ar_opt->ltime)
-1),
GNRC_NDP_MSG_NBR_SOL_RETRANS,
gnrc_ipv6_pid);
mutex_unlock(&ipv6_iface->mutex);
break;
case SIXLOWPAN_ND_STATUS_DUP:
DEBUG("6lo nd: address registration determined duplicated\n");
/* TODO: handle DAD failed case */
gnrc_ipv6_netif_remove_addr(iface, &ipv6->dst);
/* address should not be used anymore */
break;
case SIXLOWPAN_ND_STATUS_NC_FULL:
DEBUG("6lo nd: neighbor cache on router is full\n");
gnrc_ipv6_nc_remove(iface, &ipv6->src);
/* try to find another router */
gnrc_sixlowpan_nd_init(ipv6_iface);
break;
default:
DEBUG("6lo nd: unknown status for registration received\n");
break;
}
break;
#ifdef MODULE_GNRC_SIXLOWPAN_ND_ROUTER
case ICMPV6_NBR_SOL:
if (!(ipv6_iface->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN) &&
!(ipv6_iface->flags & GNRC_IPV6_NETIF_FLAGS_ROUTER)) {
DEBUG("6lo nd: interface not a 6LoWPAN or forwarding interface\n");
return 0;
}
if ((ar_opt->status != 0) ||
ipv6_addr_is_unspecified(&ipv6->src)) {
/* discard silently */
return 0;
}
/* TODO multihop DAD */
if ((nc_entry != NULL) &&
((gnrc_ipv6_nc_get_type(nc_entry) == GNRC_IPV6_NC_TYPE_REGISTERED) ||
(gnrc_ipv6_nc_get_type(nc_entry) == GNRC_IPV6_NC_TYPE_TENTATIVE)) &&
((nc_entry->eui64.uint64.u64 != 0) &&
(ar_opt->eui64.uint64.u64 != nc_entry->eui64.uint64.u64))) {
/* there is already another node with this address */
DEBUG("6lo nd: duplicate address detected\n");
status = SIXLOWPAN_ND_STATUS_DUP;
}
else if ((nc_entry != NULL) && (ar_opt->ltime.u16 == 0)) {
gnrc_ipv6_nc_remove(iface, &ipv6->src);
/* TODO, notify routing protocol */
}
else if (ar_opt->ltime.u16 != 0) {
/* TODO: multihop DAD behavior */
uint16_t reg_ltime;
if (nc_entry == NULL) {
if ((nc_entry = gnrc_ipv6_nc_add(iface, &ipv6->src, sl2a, sl2a_len,
GNRC_IPV6_NC_STATE_STALE)) == NULL) {
DEBUG("6lo nd: neighbor cache is full\n");
return SIXLOWPAN_ND_STATUS_NC_FULL;
}
nc_entry->eui64 = ar_opt->eui64;
}
nc_entry->flags &= ~GNRC_IPV6_NC_TYPE_MASK;
nc_entry->flags |= GNRC_IPV6_NC_TYPE_REGISTERED;
reg_ltime = byteorder_ntohs(ar_opt->ltime);
/* TODO: notify routing protocol */
xtimer_set_msg(&nc_entry->type_timeout, (reg_ltime * 60 * US_PER_SEC),
&nc_entry->type_timeout_msg, gnrc_ipv6_pid);
}
break;
#endif
default:
break;
}
return status;
}
bool gnrc_sixlowpan_nd_opt_6ctx_handle(uint8_t icmpv6_type, sixlowpan_nd_opt_6ctx_t *ctx_opt)
{
#ifdef MODULE_GNRC_SIXLOWPAN_CTX
if (((ctx_opt->ctx_len <= 64) && (ctx_opt->len != 2)) ||
((ctx_opt->ctx_len > 64) && (ctx_opt->len != 3))) {
DEBUG("6lo nd: invalid 6LoWPAN context option received\n");
return false;
}
if (icmpv6_type != ICMPV6_RTR_ADV) {
/* discard silently */
return true;
}
/* don't care for result */
gnrc_sixlowpan_ctx_update(sixlowpan_nd_opt_6ctx_get_cid(ctx_opt), (ipv6_addr_t *)(ctx_opt + 1),
ctx_opt->ctx_len, byteorder_ntohs(ctx_opt->ltime),
sixlowpan_nd_opt_6ctx_is_comp(ctx_opt));
#endif
return true;
}
void gnrc_sixlowpan_nd_wakeup(void)
{
gnrc_ipv6_nc_t *router = gnrc_ipv6_nc_get_next_router(NULL);
while (router) {
gnrc_sixlowpan_nd_uc_rtr_sol(router);
gnrc_ndp_internal_send_nbr_sol(router->iface, NULL, &router->ipv6_addr, &router->ipv6_addr);
gnrc_ndp_internal_reset_nbr_sol_timer(router, GNRC_NDP_RETRANS_TIMER,
GNRC_NDP_MSG_NBR_SOL_RETRANS, gnrc_ipv6_pid);
}
}
/* gnrc_sixlowpan_nd_opt_abr_handle etc. implemented in gnrc_sixlowpan_nd_router */
/** @} */

View File

@ -13,7 +13,7 @@
*/
#include "net/gnrc/ipv6.h"
#include "net/gnrc/ndp.h"
#include "net/gnrc/ndp2.h"
#include "net/gnrc/sixlowpan/ctx.h"
#include "net/gnrc/sixlowpan/nd.h"
#include "net/icmpv6.h"
@ -22,235 +22,10 @@
#include "net/gnrc/sixlowpan/nd/router.h"
static gnrc_sixlowpan_nd_router_abr_t _abrs[GNRC_SIXLOWPAN_ND_ROUTER_ABR_NUMOF];
static gnrc_sixlowpan_nd_router_prf_t _prefixes[GNRC_SIXLOWPAN_ND_ROUTER_ABR_PRF_NUMOF];
static gnrc_sixlowpan_nd_router_abr_t *_get_abr(ipv6_addr_t *addr)
{
gnrc_sixlowpan_nd_router_abr_t *abr = NULL;
for (int i = 0; i < GNRC_SIXLOWPAN_ND_ROUTER_ABR_NUMOF; i++) {
if (ipv6_addr_equal(&_abrs[i].addr, addr)) {
return &_abrs[i];
}
if ((abr == NULL) && ipv6_addr_is_unspecified(&_abrs[i].addr)) {
abr = &_abrs[i];
}
}
return abr;
}
static gnrc_sixlowpan_nd_router_prf_t *_get_free_prefix(gnrc_ipv6_netif_t *ipv6_iface,
ipv6_addr_t *prefix,
size_t prefix_len)
{
gnrc_sixlowpan_nd_router_prf_t *prf = NULL;
for (int i = 0; i < GNRC_SIXLOWPAN_ND_ROUTER_ABR_PRF_NUMOF; i++) {
if ((ipv6_addr_match_prefix(&_prefixes[i].prefix->addr, prefix) >= prefix_len) &&
(_prefixes[i].prefix->prefix_len == prefix_len) &&
(_prefixes[i].iface == ipv6_iface)) {
return &_prefixes[i];
}
if ((prf == NULL) &&
((_prefixes[i].prefix == NULL) ||
ipv6_addr_is_unspecified(&_prefixes[i].prefix->addr))) {
prf = &_prefixes[i];
}
}
return prf;
}
static void _add_prefix(kernel_pid_t iface, gnrc_sixlowpan_nd_router_abr_t *abr,
ndp_opt_pi_t *pi_opt)
{
gnrc_sixlowpan_nd_router_prf_t *prf_ent;
gnrc_ipv6_netif_t *ipv6_iface = gnrc_ipv6_netif_get(iface);
ipv6_addr_t *prefix;
if ((pi_opt->len != NDP_OPT_PI_LEN) || ipv6_addr_is_link_local(&pi_opt->prefix) ||
(pi_opt->flags & NDP_OPT_PI_FLAGS_A) ||
(pi_opt->flags & NDP_OPT_PI_FLAGS_L) ||
(pi_opt->valid_ltime.u32 == 0)) {
return;
}
prefix = gnrc_ipv6_netif_match_prefix(iface, &pi_opt->prefix);
prf_ent = _get_free_prefix(ipv6_iface, &pi_opt->prefix, pi_opt->prefix_len);
if ((prf_ent != NULL) && (prf_ent->iface == NULL)) {
prf_ent->iface = ipv6_iface;
prf_ent->prefix = container_of(prefix, gnrc_ipv6_netif_addr_t, addr);
LL_PREPEND(abr->prfs, prf_ent);
}
}
static void _add_ctx(gnrc_sixlowpan_nd_router_abr_t *abr, sixlowpan_nd_opt_6ctx_t *ctx_opt)
{
if (((ctx_opt->ctx_len < 64) && (ctx_opt->len != 2)) ||
((ctx_opt->ctx_len >= 64) && (ctx_opt->len != 3))) {
return;
}
bf_set(abr->ctxs, sixlowpan_nd_opt_6ctx_get_cid(ctx_opt));
}
#ifdef MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER
static inline bool _is_me(ipv6_addr_t *addr)
{
ipv6_addr_t *res;
return (gnrc_ipv6_netif_find_by_addr(&res, addr) != KERNEL_PID_UNDEF);
}
#else
#define _is_me(ignore) (false)
#endif
void gnrc_sixlowpan_nd_router_set_rtr_adv(gnrc_ipv6_netif_t *netif, bool enable)
{
if (enable && (gnrc_ipv6_netif_add_addr(netif->pid, &ipv6_addr_all_routers_link_local, 128,
GNRC_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST) != NULL)) {
mutex_lock(&netif->mutex);
netif->flags |= GNRC_IPV6_NETIF_FLAGS_RTR_ADV;
netif->adv_ltime = GNRC_IPV6_NETIF_DEFAULT_ROUTER_LTIME;
#ifdef MODULE_GNRC_NDP_ROUTER
/* for border router these values have to be initialized, too */
netif->max_adv_int = GNRC_IPV6_NETIF_DEFAULT_MAX_ADV_INT;
netif->min_adv_int = GNRC_IPV6_NETIF_DEFAULT_MIN_ADV_INT;
#endif
mutex_unlock(&netif->mutex);
}
else {
netif->flags &= ~GNRC_IPV6_NETIF_FLAGS_RTR_ADV;
gnrc_ipv6_netif_remove_addr(netif->pid, (ipv6_addr_t *)&ipv6_addr_all_routers_link_local);
}
}
gnrc_sixlowpan_nd_router_abr_t *gnrc_sixlowpan_nd_router_abr_get(void)
{
if (ipv6_addr_is_unspecified(&_abrs[0].addr)) {
return NULL;
}
return _abrs;
}
bool gnrc_sixlowpan_nd_router_abr_older(sixlowpan_nd_opt_abr_t *abr_opt)
{
gnrc_sixlowpan_nd_router_abr_t *abr;
uint32_t version;
if (abr_opt->len != SIXLOWPAN_ND_OPT_ABR_LEN) {
/* invalid option received */
return true;
}
if (_is_me(&abr_opt->braddr)) {
return false;
}
abr = _get_abr(&abr_opt->braddr);
if (abr == NULL) {
return false;
}
version = (uint32_t)byteorder_ntohs(abr_opt->vlow);
version |= ((uint32_t)byteorder_ntohs(abr_opt->vhigh)) << 16;
return (version < abr->version);
}
void gnrc_sixlowpan_nd_router_abr_remove(gnrc_sixlowpan_nd_router_abr_t *abr)
{
for (int i = 0; i < GNRC_SIXLOWPAN_CTX_SIZE; i++) {
if (bf_isset(abr->ctxs, i)) {
gnrc_sixlowpan_ctx_remove(i);
bf_unset(abr->ctxs, i);
}
}
while (abr->prfs != NULL) {
gnrc_sixlowpan_nd_router_prf_t *prefix = abr->prfs;
LL_DELETE(abr->prfs, prefix);
gnrc_ipv6_netif_remove_addr(prefix->iface->pid, &prefix->prefix->addr);
prefix->next = NULL;
prefix->iface = NULL;
prefix->prefix = NULL;
}
ipv6_addr_set_unspecified(&abr->addr);
abr->version = 0;
}
/* router-only functions from net/gnrc/sixlowpan/nd.h */
void gnrc_sixlowpan_nd_opt_abr_handle(kernel_pid_t iface, ndp_rtr_adv_t *rtr_adv, int sicmpv6_size,
sixlowpan_nd_opt_abr_t *abr_opt)
{
uint16_t opt_offset = 0;
uint8_t *buf = (uint8_t *)(rtr_adv + 1);
gnrc_sixlowpan_nd_router_abr_t *abr;
uint32_t t = 0;
if (_is_me(&abr_opt->braddr)) {
return;
}
/* validity and version was checked in previously called
* gnrc_sixlowpan_nd_router_abr_older() */
abr = _get_abr(&abr_opt->braddr);
if (abr == NULL) {
return;
}
abr->ltime = byteorder_ntohs(abr_opt->ltime);
if (abr->ltime == 0) {
abr->ltime = GNRC_SIXLOWPAN_ND_BORDER_ROUTER_DEFAULT_LTIME;
return;
}
sicmpv6_size -= sizeof(ndp_rtr_adv_t);
while (sicmpv6_size > 0) {
ndp_opt_t *opt = (ndp_opt_t *)(buf + opt_offset);
switch (opt->type) {
case NDP_OPT_PI:
_add_prefix(iface, abr, (ndp_opt_pi_t *)opt);
case NDP_OPT_6CTX:
_add_ctx(abr, (sixlowpan_nd_opt_6ctx_t *)opt);
default:
break;
}
opt_offset += (opt->len * 8);
sicmpv6_size -= (opt->len * 8);
}
abr->version = (uint32_t)byteorder_ntohs(abr_opt->vlow);
abr->version |= ((uint32_t)byteorder_ntohs(abr_opt->vhigh)) << 16;
abr->addr.u64[0] = abr_opt->braddr.u64[0];
abr->addr.u64[1] = abr_opt->braddr.u64[1];
memset(abr->ctxs, 0, sizeof(abr->ctxs));
abr->prfs = NULL;
t = abr->ltime * 60 * US_PER_SEC;
xtimer_remove(&abr->ltimer);
abr->ltimer_msg.type = GNRC_SIXLOWPAN_ND_MSG_ABR_TIMEOUT;
abr->ltimer_msg.content.ptr = abr;
xtimer_set_msg(&abr->ltimer, t, &abr->ltimer_msg, gnrc_ipv6_pid);
}
gnrc_pktsnip_t *gnrc_sixlowpan_nd_opt_6ctx_build(uint8_t prefix_len, uint8_t flags, uint16_t ltime,
ipv6_addr_t *prefix, gnrc_pktsnip_t *next)
{
gnrc_pktsnip_t *pkt = gnrc_ndp_opt_build(NDP_OPT_6CTX,
gnrc_pktsnip_t *pkt = gnrc_ndp2_opt_build(NDP_OPT_6CTX,
sizeof(sixlowpan_nd_opt_6ctx_t) + (prefix_len / 8),
next);
@ -271,7 +46,7 @@ gnrc_pktsnip_t *gnrc_sixlowpan_nd_opt_6ctx_build(uint8_t prefix_len, uint8_t fla
gnrc_pktsnip_t *gnrc_sixlowpan_nd_opt_abr_build(uint32_t version, uint16_t ltime,
ipv6_addr_t *braddr, gnrc_pktsnip_t *next)
{
gnrc_pktsnip_t *pkt = gnrc_ndp_opt_build(NDP_OPT_ABR, sizeof(sixlowpan_nd_opt_abr_t), next);
gnrc_pktsnip_t *pkt = gnrc_ndp2_opt_build(NDP_OPT_ABR, sizeof(sixlowpan_nd_opt_abr_t), next);
if (pkt != NULL) {
sixlowpan_nd_opt_abr_t *abr_opt = pkt->data;
@ -284,102 +59,4 @@ gnrc_pktsnip_t *gnrc_sixlowpan_nd_opt_abr_build(uint32_t version, uint16_t ltime
return pkt;
}
#ifdef MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER
gnrc_sixlowpan_nd_router_abr_t *gnrc_sixlowpan_nd_router_abr_create(ipv6_addr_t *addr,
unsigned int ltime)
{
assert(addr != NULL);
gnrc_sixlowpan_nd_router_abr_t *abr = _get_abr(addr);
if (abr == NULL) {
return NULL;
}
/* TODO: store and get this somewhere stable */
abr->version = 0;
abr->ltime = (uint16_t)ltime;
abr->addr.u64[0] = addr->u64[0];
abr->addr.u64[1] = addr->u64[1];
memset(abr->ctxs, 0, sizeof(abr->ctxs));
abr->prfs = NULL;
return abr;
}
int gnrc_sixlowpan_nd_router_abr_add_prf(gnrc_sixlowpan_nd_router_abr_t* abr,
gnrc_ipv6_netif_t *iface, gnrc_ipv6_netif_addr_t *prefix)
{
assert((iface != NULL) && (prefix != NULL));
gnrc_sixlowpan_nd_router_prf_t *prf_ent;
if ((abr < _abrs) || (abr > (_abrs + GNRC_SIXLOWPAN_ND_ROUTER_ABR_NUMOF))) {
return -ENOENT;
}
prf_ent = _get_free_prefix(iface, &prefix->addr, prefix->prefix_len);
if (prf_ent == NULL) {
return -ENOMEM;
}
if (prf_ent->iface == NULL) {
prf_ent->iface = iface;
prf_ent->prefix = prefix;
LL_PREPEND(abr->prfs, prf_ent);
abr->version++; /* TODO: store somewhere stable */
}
return 0;
}
void gnrc_sixlowpan_nd_router_abr_rem_prf(gnrc_sixlowpan_nd_router_abr_t *abr,
gnrc_ipv6_netif_t *iface, gnrc_ipv6_netif_addr_t *prefix)
{
assert((iface != NULL) && (prefix != NULL));
gnrc_sixlowpan_nd_router_prf_t *prf_ent = abr->prfs, *prev = NULL;
if ((abr < _abrs) || (abr > (_abrs + GNRC_SIXLOWPAN_ND_ROUTER_ABR_NUMOF))) {
return;
}
while (prf_ent) {
if (prf_ent->prefix == prefix) {
if (prev == NULL) {
abr->prfs = prf_ent->next;
}
else {
prev->next = prf_ent->next;
}
prf_ent->next = NULL;
prf_ent->iface = NULL;
prf_ent->prefix = NULL;
abr->version++; /* TODO: store somewhere stable */
break;
}
prev = prf_ent;
prf_ent = prf_ent->next;
}
}
int gnrc_sixlowpan_nd_router_abr_add_ctx(gnrc_sixlowpan_nd_router_abr_t *abr, uint8_t cid)
{
if ((abr < _abrs) || (abr > (_abrs + GNRC_SIXLOWPAN_ND_ROUTER_ABR_NUMOF))) {
return -ENOENT;
}
if (cid >= GNRC_SIXLOWPAN_CTX_SIZE) {
return -EINVAL;
}
if (bf_isset(abr->ctxs, cid)) {
return -EADDRINUSE;
}
bf_set(abr->ctxs, cid);
abr->version++; /* TODO: store somewhere stable */
return 0;
}
void gnrc_sixlowpan_nd_router_abr_rem_ctx(gnrc_sixlowpan_nd_router_abr_t *abr, uint8_t cid)
{
if ((abr < _abrs) || (abr > (_abrs + GNRC_SIXLOWPAN_ND_ROUTER_ABR_NUMOF))) {
return;
}
if (cid >= GNRC_SIXLOWPAN_CTX_SIZE) {
return;
}
bf_unset(abr->ctxs, cid);
abr->version++; /* TODO: store somewhere stable */
return;
}
#endif
/** @} */

View File

@ -52,7 +52,7 @@ static void _dump_snip(gnrc_pktsnip_t *pkt)
printf("NETTYPE_UNDEF (%i)\n", pkt->type);
od_hex_dump(pkt->data, pkt->size, OD_WIDTH_DEFAULT);
break;
#ifdef MODULE_GNRC_NETIF
#ifdef MODULE_GNRC_NETIF2
case GNRC_NETTYPE_NETIF:
printf("NETTYPE_NETIF (%i)\n", pkt->type);
gnrc_netif_hdr_print(pkt->data);

View File

@ -16,7 +16,7 @@
#include "net/icmpv6.h"
#include "net/ipv6.h"
#include "net/gnrc/ipv6/netif.h"
#include "net/gnrc/netif2/internal.h"
#include "net/gnrc.h"
#include "mutex.h"
@ -81,7 +81,8 @@ kernel_pid_t gnrc_rpl_init(kernel_pid_t if_pid)
}
/* register all_RPL_nodes multicast address */
gnrc_ipv6_netif_add_addr(if_pid, &ipv6_addr_all_rpl_nodes, IPV6_ADDR_BIT_LEN, 0);
gnrc_netif2_ipv6_group_join(gnrc_netif2_get_by_pid(if_pid),
&ipv6_addr_all_rpl_nodes);
gnrc_rpl_send_DIS(NULL, (ipv6_addr_t *) &ipv6_addr_all_rpl_nodes);
return gnrc_rpl_pid;

View File

@ -28,13 +28,14 @@
void auto_init_gnrc_rpl(void)
{
#if (GNRC_NETIF_NUMOF == 1)
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
gnrc_netif_get(ifs);
DEBUG("auto_init_gnrc_rpl: initializing RPL on interface %" PRIkernel_pid "\n", ifs[0]);
gnrc_rpl_init(ifs[0]);
gnrc_netif2_t *netif = gnrc_netif2_iter(NULL);
assert(netif != NULL);
DEBUG("auto_init_gnrc_rpl: initializing RPL on interface %" PRIkernel_pid "\n",
netif->pid);
gnrc_rpl_init(netif->pid);
return;
#elif defined(GNRC_RPL_DEFAULT_NETIF)
if (gnrc_netif_exist(GNRC_RPL_DEFAULT_NETIF)) {
if (gnrc_netif2_get_by_pid(GNRC_RPL_DEFAULT_NETIF) != NULL) {
DEBUG("auto_init_gnrc_rpl: initializing RPL on interface %" PRIkernel_pid "\n",
GNRC_RPL_DEFAULT_NETIF);
gnrc_rpl_init(GNRC_RPL_DEFAULT_NETIF);

View File

@ -20,6 +20,7 @@
#include "net/ipv6/hdr.h"
#include "net/gnrc/icmpv6.h"
#include "net/gnrc/ipv6.h"
#include "net/gnrc/netif2/internal.h"
#include "net/gnrc.h"
#include "net/eui64.h"
@ -53,22 +54,45 @@ static char addr_str[IPV6_ADDR_MAX_STR_LEN];
#define GNRC_RPL_PRF_MASK (0x7)
#define GNRC_RPL_PREFIX_AUTO_ADDRESS_BIT (1 << 6)
static gnrc_netif2_t *_find_interface_with_rpl_mcast(void)
{
gnrc_netif2_t *netif = NULL;
while ((netif = gnrc_netif2_iter(netif))) {
for (unsigned i = 0; i < GNRC_NETIF2_IPV6_GROUPS_NUMOF; i++) {
if (ipv6_addr_equal(&netif->ipv6.groups[i], &ipv6_addr_all_rpl_nodes)) {
return netif;
}
}
}
return NULL;
}
void gnrc_rpl_send(gnrc_pktsnip_t *pkt, kernel_pid_t iface, ipv6_addr_t *src, ipv6_addr_t *dst,
ipv6_addr_t *dodag_id)
{
gnrc_netif2_t *netif;
(void)dodag_id;
gnrc_pktsnip_t *hdr;
if (iface == KERNEL_PID_UNDEF) {
if ((iface = gnrc_ipv6_netif_find_by_addr(NULL, &ipv6_addr_all_rpl_nodes))
== KERNEL_PID_UNDEF) {
netif = _find_interface_with_rpl_mcast();
if (netif == KERNEL_PID_UNDEF) {
DEBUG("RPL: no suitable interface found for this destination address\n");
gnrc_pktbuf_release(pkt);
return;
}
iface = netif->pid;
}
else {
netif = gnrc_netif2_get_by_pid(iface);
}
if (src == NULL) {
src = gnrc_ipv6_netif_match_prefix(iface, &ipv6_addr_link_local_prefix);
int src_idx = gnrc_netif2_ipv6_addr_match(netif, &ipv6_addr_link_local_prefix);
src = &netif->ipv6.addrs[src_idx];
if (src == NULL) {
DEBUG("RPL: no suitable src address found\n");
@ -143,13 +167,15 @@ gnrc_pktsnip_t *_dio_prefix_info_build(gnrc_pktsnip_t *pkt, gnrc_rpl_dodag_t *do
prefix_info->length = GNRC_RPL_OPT_PREFIX_INFO_LEN;
/* auto-address configuration */
prefix_info->LAR_flags = GNRC_RPL_PREFIX_AUTO_ADDRESS_BIT;
prefix_info->valid_lifetime = dodag->netif_addr->valid;
prefix_info->pref_lifetime = dodag->netif_addr->preferred;
prefix_info->prefix_len = dodag->netif_addr->prefix_len;
/* TODO: Get real values from NIB_PL */
prefix_info->valid_lifetime = UINT32_MAX;
prefix_info->pref_lifetime = UINT32_MAX;
prefix_info->prefix_len = 64;
prefix_info->reserved = 0;
memset(&prefix_info->prefix, 0, sizeof(prefix_info->prefix));
ipv6_addr_init_prefix(&prefix_info->prefix, &dodag->dodag_id, dodag->netif_addr->prefix_len);
ipv6_addr_init_prefix(&prefix_info->prefix, &dodag->dodag_id,
prefix_info->prefix_len);
return opt_snip;
}
#endif
@ -315,7 +341,6 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt
gnrc_rpl_dodag_t *dodag = &inst->dodag;
eui64_t iid;
*included_opts = 0;
ipv6_addr_t *me;
#ifndef GNRC_RPL_WITHOUT_VALIDATION
if (!gnrc_rpl_validation_options(msg_type, inst, opt, len)) {
@ -372,15 +397,17 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt
#endif
gnrc_rpl_opt_prefix_info_t *pi = (gnrc_rpl_opt_prefix_info_t *) opt;
/* check for the auto address-configuration flag */
if ((gnrc_netapi_get(dodag->iface, NETOPT_IPV6_IID, 0, &iid, sizeof(eui64_t)) < 0)
gnrc_netif2_t *netif = gnrc_netif2_get_by_pid(dodag->iface);
assert(netif != NULL);
if ((gnrc_netif2_ipv6_get_iid(netif, &iid) < 0)
&& !(pi->LAR_flags & GNRC_RPL_PREFIX_AUTO_ADDRESS_BIT)) {
break;
}
ipv6_addr_set_aiid(&pi->prefix, iid.uint8);
me = gnrc_ipv6_netif_add_addr(dodag->iface, &pi->prefix, pi->prefix_len, 0);
if (me) {
dodag->netif_addr = gnrc_ipv6_netif_addr_get(me);
}
gnrc_netif2_ipv6_addr_add(netif, &pi->prefix, pi->prefix_len,
GNRC_NETIF2_IPV6_ADDRS_FLAGS_STATE_VALID);
/* TODO: add to prefix list */
break;
@ -486,11 +513,13 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
inst->of = gnrc_rpl_get_of_for_ocp(GNRC_RPL_DEFAULT_OCP);
if (iface == KERNEL_PID_UNDEF) {
iface = gnrc_ipv6_netif_find_by_addr(NULL, &ipv6_addr_all_rpl_nodes);
gnrc_netif2_t *netif = _find_interface_with_rpl_mcast();
iface = netif->pid;
assert(iface != KERNEL_PID_UNDEF);
}
gnrc_rpl_dodag_init(inst, &dio->dodag_id, iface, NULL);
gnrc_rpl_dodag_init(inst, &dio->dodag_id, iface);
dodag = &inst->dodag;
@ -531,24 +560,7 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
#endif
}
/* if there was no netif_addr created manually or by a PIO, then leave this DODAG */
if (!dodag->netif_addr) {
ipv6_addr_t *configured_addr;
if (!(configured_addr = gnrc_ipv6_netif_match_prefix(dodag->iface, &dodag->dodag_id))) {
DEBUG("RPL: no IPv6 address configured to match the given dodag id: %s\n",
ipv6_addr_to_str(addr_str, &(dodag->dodag_id), sizeof(addr_str)));
gnrc_rpl_instance_remove(inst);
return;
}
if (!(dodag->netif_addr = gnrc_ipv6_netif_addr_get(configured_addr))) {
DEBUG("RPL: no netif address found for %s\n",
ipv6_addr_to_str(addr_str, configured_addr, sizeof(addr_str)));
gnrc_rpl_instance_remove(inst);
return;
}
}
/* TODO: create prefix list entry */
gnrc_rpl_delay_dao(dodag);
trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_MSG,
@ -732,11 +744,15 @@ void gnrc_rpl_send_DAO(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination, uint
/* find my address */
ipv6_addr_t *me = NULL;
gnrc_ipv6_netif_find_by_prefix(&me, &dodag->dodag_id);
if (me == NULL) {
gnrc_netif2_t *netif = gnrc_netif2_get_by_ipv6_addr(&dodag->dodag_id);
int idx;
if (netif == NULL) {
DEBUG("RPL: no address configured\n");
return;
}
idx = gnrc_netif2_ipv6_addr_idx(netif, &dodag->dodag_id);
me = &netif->ipv6.addrs[idx];
mutex_lock(&(gnrc_ipv6_fib_table.mtx_access));

View File

@ -18,7 +18,7 @@
#include <stdbool.h>
#include "net/af.h"
#include "net/gnrc/ipv6.h"
#include "net/gnrc/ipv6/netif.h"
#include "net/gnrc/netif2/internal.h"
#include "net/gnrc/rpl/dodag.h"
#include "net/gnrc/rpl/structs.h"
#include "utlist.h"
@ -129,8 +129,7 @@ gnrc_rpl_instance_t *gnrc_rpl_instance_get(uint8_t instance_id)
return NULL;
}
bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id, kernel_pid_t iface,
gnrc_ipv6_netif_addr_t *netif_addr)
bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id, kernel_pid_t iface)
{
/* TODO: check if netif_addr belongs to iface */
@ -154,7 +153,6 @@ bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id, k
dodag->dao_counter = 0;
dodag->instance = instance;
dodag->iface = iface;
dodag->netif_addr = netif_addr;
#ifdef MODULE_GNRC_RPL_P2P
if ((instance->mop == GNRC_RPL_P2P_MOP) && (gnrc_rpl_p2p_ext_new(dodag) == NULL)) {
@ -365,8 +363,7 @@ gnrc_rpl_instance_t *gnrc_rpl_root_instance_init(uint8_t instance_id, ipv6_addr_
return NULL;
}
ipv6_addr_t *configured_addr;
gnrc_ipv6_netif_addr_t *netif_addr = NULL;
gnrc_netif2_t *netif;
gnrc_rpl_instance_t *inst = NULL;
gnrc_rpl_dodag_t *dodag = NULL;
kernel_pid_t iface;
@ -377,17 +374,12 @@ gnrc_rpl_instance_t *gnrc_rpl_root_instance_init(uint8_t instance_id, ipv6_addr_
return NULL;
}
if ((iface = gnrc_ipv6_netif_find_by_addr(&configured_addr, dodag_id)) == KERNEL_PID_UNDEF) {
if ((netif = gnrc_netif2_get_by_ipv6_addr(dodag_id)) == NULL) {
DEBUG("RPL: no IPv6 address configured to match the given dodag id: %s\n",
ipv6_addr_to_str(addr_str, dodag_id, sizeof(addr_str)));
return NULL;
}
if ((netif_addr = gnrc_ipv6_netif_addr_get(configured_addr)) == NULL) {
DEBUG("RPL: no netif address found for %s\n",
ipv6_addr_to_str(addr_str, configured_addr, sizeof(addr_str)));
return NULL;
}
iface = netif->pid;
if (gnrc_rpl_instance_add(instance_id, &inst)) {
inst->of = (gnrc_rpl_of_t *) gnrc_rpl_get_of_for_ocp(GNRC_RPL_DEFAULT_OCP);
@ -404,7 +396,7 @@ gnrc_rpl_instance_t *gnrc_rpl_root_instance_init(uint8_t instance_id, ipv6_addr_
return NULL;
}
if (!gnrc_rpl_dodag_init(inst, dodag_id, iface, netif_addr)) {
if (!gnrc_rpl_dodag_init(inst, dodag_id, iface)) {
DEBUG("RPL: could not initialize DODAG\n");
gnrc_rpl_instance_remove(inst);
return NULL;

View File

@ -20,13 +20,13 @@
#include "random.h"
#include "sched.h"
#include "net/gnrc/netif.h"
#include "net/gnrc/netif2.h"
#include "ccn-lite-riot.h"
#include "ccnl-pkt-ndntlv.h"
#define BUF_SIZE (64)
#define MAX_ADDR_LEN (8U)
#define MAX_ADDR_LEN (GNRC_NETIF2_L2ADDR_MAXLEN)
static unsigned char _int_buf[BUF_SIZE];
static unsigned char _cont_buf[BUF_SIZE];
@ -56,7 +56,7 @@ int _ccnl_open(int argc, char **argv)
/* check if given number is a valid netif PID */
int pid = atoi(argv[1]);
if (!gnrc_netif_exist(pid)) {
if (gnrc_netif2_get_by_pid(pid) == NULL) {
printf("%i is not a valid interface!\n", pid);
return -1;
}
@ -142,7 +142,7 @@ static struct ccnl_face_s *_intern_face_get(char *addr_str)
/* initialize address with 0xFF for broadcast */
uint8_t relay_addr[MAX_ADDR_LEN];
memset(relay_addr, UINT8_MAX, MAX_ADDR_LEN);
size_t addr_len = gnrc_netif_addr_from_str(relay_addr, sizeof(relay_addr), addr_str);
size_t addr_len = gnrc_netif2_addr_from_str(addr_str, relay_addr);
if (addr_len == 0) {
printf("Error: %s is not a valid link layer address\n", addr_str);

View File

@ -25,9 +25,7 @@
#include <stdlib.h>
#include "thread.h"
#include "net/af.h"
#ifdef MODULE_GNRC_NETIF
#include "net/gnrc/netif.h"
#endif
#include "net/gnrc/netif2.h"
#include "net/fib.h"
#include "net/gnrc/ipv6.h"
@ -167,7 +165,7 @@ int _fib_route_handler(int argc, char **argv)
if (argc == 3) {
if ((strcmp("flush", argv[1]) == 0)) {
kernel_pid_t iface = atoi(argv[2]);
if (gnrc_netif_exist(iface)) {
if (gnrc_netif2_get_by_pid(iface) != NULL) {
fib_flush(&gnrc_ipv6_fib_table, iface);
printf("successfully flushed all entries for interface %" PRIu16"\n", iface);
}
@ -189,13 +187,13 @@ int _fib_route_handler(int argc, char **argv)
return 0;
}
#ifdef MODULE_GNRC_NETIF
/* e.g. fibroute add <destination> via <next hop> */
if ((argc == 5) && (strcmp("add", argv[1]) == 0) && (strcmp("via", argv[3]) == 0)) {
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
size_t ifnum = gnrc_netif_get(ifs);
size_t ifnum = gnrc_netif2_numof();
if (ifnum == 1) {
_fib_add(argv[2], argv[4], ifs[0], (uint32_t)FIB_LIFETIME_NO_EXPIRE);
gnrc_netif2_t *netif = gnrc_netif2_iter(NULL);
_fib_add(argv[2], argv[4], netif->pid,
(uint32_t)FIB_LIFETIME_NO_EXPIRE);
}
else {
_fib_usage(1);
@ -208,10 +206,11 @@ int _fib_route_handler(int argc, char **argv)
/* e.g. fibroute add <destination> via <next hop> lifetime <lifetime> */
if ((argc == 7) && (strcmp("add", argv[1]) == 0) && (strcmp("via", argv[3]) == 0)
&& (strcmp("lifetime", argv[5]) == 0)) {
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
size_t ifnum = gnrc_netif_get(ifs);
size_t ifnum = gnrc_netif2_numof();
if (ifnum == 1) {
_fib_add(argv[2], argv[4], ifs[0], (uint32_t)atoi(argv[6]));
gnrc_netif2_t *netif = gnrc_netif2_iter(NULL);
_fib_add(argv[2], argv[4], netif->pid,
(uint32_t)atoi(argv[6]));
}
else {
_fib_usage(1);
@ -220,7 +219,6 @@ int _fib_route_handler(int argc, char **argv)
return 0;
}
#endif
/* e.g. fibroute add <destination> via <next hop> dev <device> */
if (argc == 7) {

View File

@ -20,7 +20,6 @@
#include <string.h>
#include "net/ipv6/addr.h"
#include "net/gnrc/ipv6/netif.h"
#include "net/gnrc/ndp/internal.h"
#include "net/gnrc/sixlowpan/ctx.h"
#include "net/gnrc/sixlowpan/nd.h"
@ -28,14 +27,11 @@
#include "xtimer.h"
static xtimer_t del_timer[GNRC_SIXLOWPAN_CTX_SIZE];
static gnrc_sixlowpan_nd_router_abr_t *abr = NULL;
void _del_cb(void *ptr)
{
gnrc_sixlowpan_ctx_t *ctx = ptr;
uint8_t cid = ctx->flags_id & GNRC_SIXLOWPAN_CTX_FLAGS_CID_MASK;
ctx->prefix_len = 0;
gnrc_sixlowpan_nd_router_abr_rem_ctx(abr, cid);
del_timer[cid].callback = NULL;
}
@ -64,6 +60,7 @@ int _gnrc_6ctx_list(void)
static void _adv_ctx(void)
{
/* TODO: update NIB */
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
size_t ifnum = gnrc_netif_get(ifs);
for (size_t i = 0; i < ifnum; i++) {
@ -105,13 +102,6 @@ int _gnrc_6ctx_add(char *cmd_str, char *ctx_str, char *prefix_str, char *ltime_s
puts("ERROR: prefix may not be ::");
return 1;
}
if (abr == NULL) {
abr = gnrc_sixlowpan_nd_router_abr_get();
}
if (gnrc_sixlowpan_nd_router_abr_add_ctx(abr, ctx) < 0) {
puts("ERROR: can not add context");
return 1;
}
ltime = atoi(ltime_str);
if (gnrc_sixlowpan_ctx_update((uint8_t)ctx, &prefix, (uint8_t)prefix_len, ltime,
true) == NULL) {

View File

@ -17,7 +17,7 @@
#include <string.h>
#include <stdio.h>
#include "net/gnrc/ipv6/netif.h"
#include "net/gnrc/netif2.h"
#include "net/gnrc/rpl.h"
#include "net/gnrc/rpl/structs.h"
#include "net/gnrc/rpl/dodag.h"
@ -32,9 +32,7 @@
int _gnrc_rpl_init(char *arg)
{
kernel_pid_t iface_pid = atoi(arg);
gnrc_ipv6_netif_t *entry = gnrc_ipv6_netif_get(iface_pid);
if (entry == NULL) {
if (gnrc_netif2_get_by_pid(iface_pid) == NULL) {
puts("unknown interface specified");
return 1;
}

View File

@ -26,6 +26,7 @@
#include "net/ipv6/addr.h"
#include "net/gnrc/ipv6/nc.h"
#include "net/gnrc/ipv6/hdr.h"
#include "net/gnrc/netif2.h"
#include "net/gnrc.h"
#include "thread.h"
#include "utlist.h"
@ -200,11 +201,11 @@ int _icmpv6_ping(int argc, char **argv)
}
if (ipv6_addr_is_link_local(&addr) || (src_iface != KERNEL_PID_UNDEF)) {
kernel_pid_t ifs[GNRC_NETIF_NUMOF];
size_t ifnum = gnrc_netif_get(ifs);
size_t ifnum = gnrc_netif2_numof();
if (src_iface == KERNEL_PID_UNDEF) {
if (ifnum == 1) {
src_iface = ifs[0];
src_iface = gnrc_netif2_iter(NULL)->pid;
}
else {
puts("error: link local target needs interface parameter (use \"<address>%<ifnum>\")\n");
@ -212,14 +213,7 @@ int _icmpv6_ping(int argc, char **argv)
}
}
else {
int valid = 0;
for (size_t i = 0; i < ifnum && i < GNRC_NETIF_NUMOF; i++) {
if (ifs[i] == src_iface) {
valid = 1;
break;
}
}
if (!valid) {
if (gnrc_netif2_get_by_pid(src_iface) == NULL) {
printf("error: %"PRIkernel_pid" is not a valid interface.\n", src_iface);
return 1;
}

View File

@ -88,11 +88,6 @@ extern int _random_get(int argc, char **argv);
extern int _gnrc_ipv6_nib(int argc, char **argv);
#endif
#ifdef MODULE_GNRC_NETIF
extern int _netif_config(int argc, char **argv);
extern int _netif_send(int argc, char **argv);
#endif
#ifdef MODULE_GNRC_NETIF2
extern int _gnrc_netif2_config(int argc, char **argv);
#ifdef MODULE_GNRC_TXTSND
@ -196,12 +191,6 @@ const shell_command_t _shell_command_list[] = {
#ifdef MODULE_GNRC_IPV6_NIB
{"nib", "Configure neighbor information base", _gnrc_ipv6_nib},
#endif
#if defined(MODULE_GNRC_NETIF) && !defined(MODULE_GNRC_NETIF2)
{"ifconfig", "Configure network interfaces", _netif_config},
#ifdef MODULE_GNRC_TXTSND
{"txtsnd", "Sends a custom string as is over the link layer", _netif_send },
#endif
#endif
#ifdef MODULE_GNRC_NETIF2
{"ifconfig", "Configure network interfaces", _gnrc_netif2_config},
#ifdef MODULE_GNRC_TXTSND