2015-11-15 20:58:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) Freie Universität Berlin
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "lwip/tcpip.h"
|
2017-02-15 13:07:34 +01:00
|
|
|
#include "lwip/netif/netdev.h"
|
2015-11-15 20:58:39 +01:00
|
|
|
#include "lwip/netif.h"
|
2015-11-13 19:41:11 +01:00
|
|
|
#include "netif/lowpan6.h"
|
2015-11-15 20:58:39 +01:00
|
|
|
|
2017-02-15 13:07:34 +01:00
|
|
|
#ifdef MODULE_NETDEV_TAP
|
|
|
|
#include "netdev_tap.h"
|
|
|
|
#include "netdev_tap_params.h"
|
2015-11-13 19:41:11 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MODULE_AT86RF2XX
|
|
|
|
#include "at86rf2xx.h"
|
|
|
|
#include "at86rf2xx_params.h"
|
|
|
|
#endif
|
2015-11-15 20:58:39 +01:00
|
|
|
|
2016-12-31 12:24:28 +01:00
|
|
|
#ifdef MODULE_MRF24J40
|
|
|
|
#include "mrf24j40.h"
|
|
|
|
#include "mrf24j40_params.h"
|
|
|
|
#endif
|
|
|
|
|
2018-10-05 10:39:38 +02:00
|
|
|
#ifdef MODULE_SOCKET_ZEP
|
|
|
|
#include "socket_zep.h"
|
|
|
|
#include "socket_zep_params.h"
|
|
|
|
#endif
|
|
|
|
|
2015-11-15 20:58:39 +01:00
|
|
|
#include "lwip.h"
|
|
|
|
|
|
|
|
#define ENABLE_DEBUG (0)
|
|
|
|
#include "debug.h"
|
|
|
|
|
2017-02-15 13:07:34 +01:00
|
|
|
#ifdef MODULE_NETDEV_TAP
|
|
|
|
#define LWIP_NETIF_NUMOF (NETDEV_TAP_MAX)
|
2015-11-13 19:41:11 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MODULE_AT86RF2XX /* is mutual exclusive with above ifdef */
|
|
|
|
#define LWIP_NETIF_NUMOF (sizeof(at86rf2xx_params) / sizeof(at86rf2xx_params[0]))
|
|
|
|
#endif
|
|
|
|
|
2016-12-31 12:24:28 +01:00
|
|
|
#ifdef MODULE_MRF24J40 /* is mutual exclusive with above ifdef */
|
|
|
|
#define LWIP_NETIF_NUMOF (sizeof(mrf24j40_params) / sizeof(mrf24j40_params[0]))
|
|
|
|
#endif
|
|
|
|
|
2018-10-05 10:39:38 +02:00
|
|
|
#ifdef MODULE_SOCKET_ZEP /* is mutual exclusive with above ifdef */
|
|
|
|
#define LWIP_NETIF_NUMOF (sizeof(socket_zep_params) / sizeof(socket_zep_params[0]))
|
|
|
|
#endif
|
|
|
|
|
2015-11-13 19:41:11 +01:00
|
|
|
#ifdef LWIP_NETIF_NUMOF
|
|
|
|
static struct netif netif[LWIP_NETIF_NUMOF];
|
|
|
|
#endif
|
|
|
|
|
2017-02-15 13:07:34 +01:00
|
|
|
#ifdef MODULE_NETDEV_TAP
|
|
|
|
static netdev_tap_t netdev_taps[LWIP_NETIF_NUMOF];
|
2016-07-07 21:38:08 +02:00
|
|
|
#endif
|
|
|
|
|
2015-11-13 19:41:11 +01:00
|
|
|
#ifdef MODULE_AT86RF2XX
|
|
|
|
static at86rf2xx_t at86rf2xx_devs[LWIP_NETIF_NUMOF];
|
|
|
|
#endif
|
|
|
|
|
2016-12-31 12:24:28 +01:00
|
|
|
#ifdef MODULE_MRF24J40
|
|
|
|
static mrf24j40_t mrf24j40_devs[LWIP_NETIF_NUMOF];
|
|
|
|
#endif
|
|
|
|
|
2018-10-05 10:39:38 +02:00
|
|
|
#ifdef MODULE_SOCKET_ZEP
|
|
|
|
static socket_zep_t socket_zep_devs[LWIP_NETIF_NUMOF];
|
|
|
|
#endif
|
|
|
|
|
2015-11-15 20:58:39 +01:00
|
|
|
void lwip_bootstrap(void)
|
|
|
|
{
|
2017-02-15 13:07:34 +01:00
|
|
|
/* TODO: do for every eligable netdev */
|
2015-11-13 19:41:11 +01:00
|
|
|
#ifdef LWIP_NETIF_NUMOF
|
2017-02-15 13:07:34 +01:00
|
|
|
#ifdef MODULE_NETDEV_TAP
|
make: fix sign-compare errors
cpu, nrf5x_common: fix sign-compare in periph/flashpage
drivers, periph_common: fix sign-compare in flashpage
cpu, sam0_common: fix sign-compare error in periph/gpio
cpu, cc2538: fix sign-compare in periph/timer
cpu, sam3: fix sign-compare in periph/gpio
cpu, stm32_common: fix sign-compare in periph/pwm
cpu, stm32_common: fix sign-compare in periph/timer
cpu, stm32_common: fix sign-compare in periph/flashpage
cpu, nrf5x_common: fix sign-compare in radio/nrfmin
cpu, samd21: fix sign-compare in periph/pwm
cpu, ezr32wg: fix sign-compare in periph/gpio
cpu, ezr32wg: fix sign-compare in periph/timer
drivers, ethos: fix sign-compare
sys, net: fix sign-compare
cpu, atmega_common: fix sign-compare error
cpu, msp430fxyz: fix sign-compare in periph/gpio
boards, msb-430-common: fix sign-compare in board_init
driver, cc2420: fix sign-compared
sys/net: fix sign-compare in gnrc_tftp
driver, pcd8544: fix sign-compare
driver, pn532: fix sign-compare
driver, sdcard_spi: fix sign-compare
tests: fix sign_compare
sys/net, lwmac: fix sign_compare
pkg, lwip: fix sign-compare
boards, waspmote: make CORECLOCK unsigned long to fix sign_compare error
tests, sock_ip: fix sign compare
tests, msg_avail: fix sign compare
tests, sock_udp: fix sign compare
boards: fix sign-compare for calliope and microbit matrix
2017-10-31 11:57:40 +01:00
|
|
|
for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) {
|
2017-02-15 13:07:34 +01:00
|
|
|
netdev_tap_setup(&netdev_taps[i], &netdev_tap_params[i]);
|
|
|
|
if (netif_add(&netif[i], &netdev_taps[i], lwip_netdev_init,
|
2016-07-07 21:38:08 +02:00
|
|
|
tcpip_input) == NULL) {
|
2017-02-15 13:07:34 +01:00
|
|
|
DEBUG("Could not add netdev_tap device\n");
|
2016-07-07 21:38:08 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-11-13 19:41:11 +01:00
|
|
|
}
|
2016-12-31 12:24:28 +01:00
|
|
|
#elif defined(MODULE_MRF24J40)
|
make: fix sign-compare errors
cpu, nrf5x_common: fix sign-compare in periph/flashpage
drivers, periph_common: fix sign-compare in flashpage
cpu, sam0_common: fix sign-compare error in periph/gpio
cpu, cc2538: fix sign-compare in periph/timer
cpu, sam3: fix sign-compare in periph/gpio
cpu, stm32_common: fix sign-compare in periph/pwm
cpu, stm32_common: fix sign-compare in periph/timer
cpu, stm32_common: fix sign-compare in periph/flashpage
cpu, nrf5x_common: fix sign-compare in radio/nrfmin
cpu, samd21: fix sign-compare in periph/pwm
cpu, ezr32wg: fix sign-compare in periph/gpio
cpu, ezr32wg: fix sign-compare in periph/timer
drivers, ethos: fix sign-compare
sys, net: fix sign-compare
cpu, atmega_common: fix sign-compare error
cpu, msp430fxyz: fix sign-compare in periph/gpio
boards, msb-430-common: fix sign-compare in board_init
driver, cc2420: fix sign-compared
sys/net: fix sign-compare in gnrc_tftp
driver, pcd8544: fix sign-compare
driver, pn532: fix sign-compare
driver, sdcard_spi: fix sign-compare
tests: fix sign_compare
sys/net, lwmac: fix sign_compare
pkg, lwip: fix sign-compare
boards, waspmote: make CORECLOCK unsigned long to fix sign_compare error
tests, sock_ip: fix sign compare
tests, msg_avail: fix sign compare
tests, sock_udp: fix sign compare
boards: fix sign-compare for calliope and microbit matrix
2017-10-31 11:57:40 +01:00
|
|
|
for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) {
|
2016-12-31 12:24:28 +01:00
|
|
|
mrf24j40_setup(&mrf24j40_devs[i], &mrf24j40_params[i]);
|
2017-02-15 13:07:34 +01:00
|
|
|
if (netif_add(&netif[i], &mrf24j40_devs[i], lwip_netdev_init,
|
2016-12-31 12:24:28 +01:00
|
|
|
tcpip_6lowpan_input) == NULL) {
|
|
|
|
DEBUG("Could not add mrf24j40 device\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-11-13 19:41:11 +01:00
|
|
|
#elif defined(MODULE_AT86RF2XX)
|
make: fix sign-compare errors
cpu, nrf5x_common: fix sign-compare in periph/flashpage
drivers, periph_common: fix sign-compare in flashpage
cpu, sam0_common: fix sign-compare error in periph/gpio
cpu, cc2538: fix sign-compare in periph/timer
cpu, sam3: fix sign-compare in periph/gpio
cpu, stm32_common: fix sign-compare in periph/pwm
cpu, stm32_common: fix sign-compare in periph/timer
cpu, stm32_common: fix sign-compare in periph/flashpage
cpu, nrf5x_common: fix sign-compare in radio/nrfmin
cpu, samd21: fix sign-compare in periph/pwm
cpu, ezr32wg: fix sign-compare in periph/gpio
cpu, ezr32wg: fix sign-compare in periph/timer
drivers, ethos: fix sign-compare
sys, net: fix sign-compare
cpu, atmega_common: fix sign-compare error
cpu, msp430fxyz: fix sign-compare in periph/gpio
boards, msb-430-common: fix sign-compare in board_init
driver, cc2420: fix sign-compared
sys/net: fix sign-compare in gnrc_tftp
driver, pcd8544: fix sign-compare
driver, pn532: fix sign-compare
driver, sdcard_spi: fix sign-compare
tests: fix sign_compare
sys/net, lwmac: fix sign_compare
pkg, lwip: fix sign-compare
boards, waspmote: make CORECLOCK unsigned long to fix sign_compare error
tests, sock_ip: fix sign compare
tests, msg_avail: fix sign compare
tests, sock_udp: fix sign compare
boards: fix sign-compare for calliope and microbit matrix
2017-10-31 11:57:40 +01:00
|
|
|
for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) {
|
2015-11-13 19:41:11 +01:00
|
|
|
at86rf2xx_setup(&at86rf2xx_devs[i], &at86rf2xx_params[i]);
|
2017-02-15 13:07:34 +01:00
|
|
|
if (netif_add(&netif[i], &at86rf2xx_devs[i], lwip_netdev_init,
|
2015-11-13 19:41:11 +01:00
|
|
|
tcpip_6lowpan_input) == NULL) {
|
|
|
|
DEBUG("Could not add at86rf2xx device\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2018-10-05 10:39:38 +02:00
|
|
|
#elif defined(MODULE_SOCKET_ZEP)
|
|
|
|
for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) {
|
|
|
|
socket_zep_setup(&socket_zep_devs[i], &socket_zep_params[i]);
|
|
|
|
if (netif_add(&netif[i], &socket_zep_devs[i], lwip_netdev_init,
|
|
|
|
tcpip_6lowpan_input) == NULL) {
|
|
|
|
DEBUG("Could not add socket_zep device\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-11-13 19:41:11 +01:00
|
|
|
#endif
|
|
|
|
if (netif[0].state != NULL) {
|
2017-02-15 13:07:34 +01:00
|
|
|
/* state is set to a netdev_t in the netif_add() functions above */
|
2015-11-13 19:41:11 +01:00
|
|
|
netif_set_default(&netif[0]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/* also allow for external interface definition */
|
2015-11-15 20:58:39 +01:00
|
|
|
tcpip_init(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @} */
|