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>
|
2021-03-06 13:43:14 +01:00
|
|
|
* @author Erik Ekman <eekman@google.com>
|
2015-11-15 20:58:39 +01:00
|
|
|
*/
|
|
|
|
|
2020-05-26 20:51:08 +02:00
|
|
|
#include "kernel_defines.h"
|
|
|
|
|
2015-11-15 20:58:39 +01:00
|
|
|
#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"
|
2021-03-24 22:59:26 +01:00
|
|
|
#include "lwip/netifapi.h"
|
2015-11-13 19:41:11 +01:00
|
|
|
#include "netif/lowpan6.h"
|
2015-11-15 20:58:39 +01:00
|
|
|
|
2015-11-13 19:41:11 +01:00
|
|
|
#ifdef MODULE_AT86RF2XX
|
|
|
|
#include "at86rf2xx.h"
|
|
|
|
#include "at86rf2xx_params.h"
|
|
|
|
#endif
|
2015-11-15 20:58:39 +01:00
|
|
|
|
2020-03-31 01:30:21 +02:00
|
|
|
#ifdef MODULE_ATWINC15X0
|
|
|
|
#include "atwinc15x0.h"
|
|
|
|
#include "atwinc15x0_params.h"
|
|
|
|
#endif
|
|
|
|
|
2020-01-11 15:38:05 +01:00
|
|
|
#ifdef MODULE_ENC28J60
|
|
|
|
#include "enc28j60.h"
|
|
|
|
#include "enc28j60_params.h"
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
|
2021-02-26 12:54:40 +01:00
|
|
|
#ifdef MODULE_SAM0_ETH
|
|
|
|
#include "sam0_eth_netdev.h"
|
|
|
|
#endif
|
|
|
|
|
2019-12-06 14:20:32 +01:00
|
|
|
#ifdef MODULE_STM32_ETH
|
|
|
|
#include "stm32_eth.h"
|
|
|
|
#endif
|
|
|
|
|
2020-06-07 21:24:14 +02:00
|
|
|
#ifdef MODULE_NRF802154
|
|
|
|
#include "nrf802154.h"
|
|
|
|
#endif
|
|
|
|
|
2021-06-07 13:35:18 +02:00
|
|
|
#if IS_USED(MODULE_NETDEV_IEEE802154_SUBMAC)
|
|
|
|
#include "net/netdev/ieee802154_submac.h"
|
|
|
|
#endif
|
|
|
|
|
2015-11-15 20:58:39 +01:00
|
|
|
#include "lwip.h"
|
2021-03-06 13:43:14 +01:00
|
|
|
#include "lwip_init_devs.h"
|
2015-11-15 20:58:39 +01:00
|
|
|
|
2020-10-22 11:35:04 +02:00
|
|
|
#define ENABLE_DEBUG 0
|
2015-11-15 20:58:39 +01:00
|
|
|
#include "debug.h"
|
|
|
|
|
2021-03-06 13:43:14 +01:00
|
|
|
#ifdef MODULE_AT86RF2XX
|
2019-07-18 15:20:42 +02:00
|
|
|
#define LWIP_NETIF_NUMOF ARRAY_SIZE(at86rf2xx_params)
|
2015-11-13 19:41:11 +01:00
|
|
|
#endif
|
|
|
|
|
2020-03-31 01:30:21 +02:00
|
|
|
#ifdef MODULE_ATWINC15X0 /* is mutual exclusive with above ifdef */
|
|
|
|
#define LWIP_NETIF_NUMOF ARRAY_SIZE(atwinc15x0_params)
|
|
|
|
#endif
|
|
|
|
|
2020-01-11 15:38:05 +01:00
|
|
|
#ifdef MODULE_ENC28J60 /* is mutual exclusive with above ifdef */
|
|
|
|
#define LWIP_NETIF_NUMOF ARRAY_SIZE(enc28j60_params)
|
|
|
|
#endif
|
|
|
|
|
2016-12-31 12:24:28 +01:00
|
|
|
#ifdef MODULE_MRF24J40 /* is mutual exclusive with above ifdef */
|
2019-07-18 15:20:42 +02:00
|
|
|
#define LWIP_NETIF_NUMOF ARRAY_SIZE(mrf24j40_params)
|
2016-12-31 12:24:28 +01:00
|
|
|
#endif
|
|
|
|
|
2018-10-05 10:39:38 +02:00
|
|
|
#ifdef MODULE_SOCKET_ZEP /* is mutual exclusive with above ifdef */
|
2019-07-18 15:20:42 +02:00
|
|
|
#define LWIP_NETIF_NUMOF ARRAY_SIZE(socket_zep_params)
|
2018-10-05 10:39:38 +02:00
|
|
|
#endif
|
|
|
|
|
2021-02-08 22:38:01 +01:00
|
|
|
/* is mutual exclusive with above ifdef */
|
2021-02-26 12:54:40 +01:00
|
|
|
#ifdef MODULE_SAM0_ETH
|
|
|
|
#define LWIP_NETIF_NUMOF (1)
|
|
|
|
#endif
|
|
|
|
|
2019-12-06 14:20:32 +01:00
|
|
|
#ifdef MODULE_STM32_ETH
|
|
|
|
#define LWIP_NETIF_NUMOF (1)
|
|
|
|
#endif
|
|
|
|
|
2020-06-07 21:24:14 +02:00
|
|
|
#ifdef MODULE_NRF802154
|
|
|
|
#define LWIP_NETIF_NUMOF (1)
|
|
|
|
#endif
|
|
|
|
|
2015-11-13 19:41:11 +01:00
|
|
|
#ifdef LWIP_NETIF_NUMOF
|
|
|
|
static struct netif netif[LWIP_NETIF_NUMOF];
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MODULE_AT86RF2XX
|
|
|
|
static at86rf2xx_t at86rf2xx_devs[LWIP_NETIF_NUMOF];
|
|
|
|
#endif
|
|
|
|
|
2020-03-31 01:30:21 +02:00
|
|
|
#ifdef MODULE_ATWINC15X0
|
|
|
|
static atwinc15x0_t atwinc15x0_devs[LWIP_NETIF_NUMOF];
|
|
|
|
#endif
|
|
|
|
|
2020-01-11 15:38:05 +01:00
|
|
|
#ifdef MODULE_ENC28J60
|
|
|
|
static enc28j60_t enc28j60_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
|
|
|
|
|
2021-02-26 12:54:40 +01:00
|
|
|
#ifdef MODULE_SAM0_ETH
|
|
|
|
static netdev_t sam0_eth;
|
|
|
|
extern void sam0_eth_setup(netdev_t *netdev);
|
|
|
|
#endif
|
|
|
|
|
2019-12-06 14:20:32 +01:00
|
|
|
#ifdef MODULE_STM32_ETH
|
|
|
|
static netdev_t stm32_eth;
|
|
|
|
extern void stm32_eth_netdev_setup(netdev_t *netdev);
|
|
|
|
#endif
|
|
|
|
|
2020-06-07 21:24:14 +02:00
|
|
|
#ifdef MODULE_NRF802154
|
2021-06-07 13:35:18 +02:00
|
|
|
static netdev_ieee802154_submac_t nrf802154_netdev;
|
2020-06-07 21:24:14 +02:00
|
|
|
#endif
|
|
|
|
|
2015-11-15 20:58:39 +01:00
|
|
|
void lwip_bootstrap(void)
|
|
|
|
{
|
2021-03-06 13:43:14 +01:00
|
|
|
lwip_netif_init_devs();
|
2019-09-05 13:29:05 +02:00
|
|
|
/* TODO: do for every eligible netdev */
|
2015-11-13 19:41:11 +01:00
|
|
|
#ifdef LWIP_NETIF_NUMOF
|
2021-03-06 13:43:14 +01:00
|
|
|
#ifdef 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++) {
|
2020-09-04 14:20:38 +02:00
|
|
|
mrf24j40_setup(&mrf24j40_devs[i], &mrf24j40_params[i], i);
|
2021-06-22 11:01:18 +02:00
|
|
|
if (netif_add_noaddr(&netif[i], &mrf24j40_devs[i].netdev.netdev, lwip_netdev_init,
|
2021-03-05 00:14:29 +01:00
|
|
|
tcpip_6lowpan_input) == NULL) {
|
2016-12-31 12:24:28 +01:00
|
|
|
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++) {
|
2020-07-07 20:15:56 +02:00
|
|
|
at86rf2xx_setup(&at86rf2xx_devs[i], &at86rf2xx_params[i], i);
|
2021-06-22 11:01:18 +02:00
|
|
|
if (netif_add_noaddr(&netif[i], &at86rf2xx_devs[i].netdev.netdev, lwip_netdev_init,
|
2021-03-05 00:14:29 +01:00
|
|
|
tcpip_6lowpan_input) == NULL) {
|
2015-11-13 19:41:11 +01:00
|
|
|
DEBUG("Could not add at86rf2xx device\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-03-31 01:30:21 +02:00
|
|
|
#elif defined(MODULE_ATWINC15X0)
|
|
|
|
for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) {
|
|
|
|
atwinc15x0_setup(&atwinc15x0_devs[i], &atwinc15x0_params[i]);
|
2021-06-22 11:01:18 +02:00
|
|
|
if (netif_add_noaddr(&netif[0], &atwinc15x0_devs[i].netdev, lwip_netdev_init,
|
2021-03-05 00:14:29 +01:00
|
|
|
tcpip_input) == NULL) {
|
2020-03-31 01:30:21 +02:00
|
|
|
DEBUG("Could not add atwinc15x0 device\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-01-11 15:38:05 +01:00
|
|
|
#elif defined(MODULE_ENC28J60)
|
|
|
|
for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) {
|
2020-09-24 18:02:47 +02:00
|
|
|
enc28j60_setup(&enc28j60_devs[i], &enc28j60_params[i], i);
|
2021-06-22 11:01:18 +02:00
|
|
|
if (netif_add_noaddr(&netif[0], &enc28j60_devs[i].netdev, lwip_netdev_init,
|
2021-03-05 00:14:29 +01:00
|
|
|
tcpip_input) == NULL) {
|
2020-01-11 15:38:05 +01:00
|
|
|
DEBUG("Could not add enc28j60 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++) {
|
2020-12-04 13:37:22 +01:00
|
|
|
socket_zep_setup(&socket_zep_devs[i], &socket_zep_params[i], i);
|
2021-06-22 11:01:18 +02:00
|
|
|
if (netif_add_noaddr(&netif[i], &socket_zep_devs[i].netdev.netdev, lwip_netdev_init,
|
2021-03-05 00:14:29 +01:00
|
|
|
tcpip_6lowpan_input) == NULL) {
|
2018-10-05 10:39:38 +02:00
|
|
|
DEBUG("Could not add socket_zep device\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-02-26 12:54:40 +01:00
|
|
|
#elif defined(MODULE_SAM0_ETH)
|
|
|
|
sam0_eth_setup(&sam0_eth);
|
2021-03-05 00:14:29 +01:00
|
|
|
if (netif_add_noaddr(&netif[0], &sam0_eth, lwip_netdev_init,
|
|
|
|
tcpip_input) == NULL) {
|
2021-02-26 12:54:40 +01:00
|
|
|
DEBUG("Could not add sam0_eth device\n");
|
|
|
|
return;
|
|
|
|
}
|
2019-12-06 14:20:32 +01:00
|
|
|
#elif defined(MODULE_STM32_ETH)
|
|
|
|
stm32_eth_netdev_setup(&stm32_eth);
|
2021-03-05 00:14:29 +01:00
|
|
|
if (netif_add_noaddr(&netif[0], &stm32_eth, lwip_netdev_init,
|
|
|
|
tcpip_input) == NULL) {
|
2019-12-06 14:20:32 +01:00
|
|
|
DEBUG("Could not add stm32_eth device\n");
|
|
|
|
return;
|
|
|
|
}
|
2020-06-07 21:24:14 +02:00
|
|
|
#elif defined(MODULE_NRF802154)
|
2021-06-07 13:35:18 +02:00
|
|
|
netdev_register(&nrf802154_netdev.dev.netdev, NETDEV_NRF802154, 0);
|
|
|
|
netdev_ieee802154_submac_init(&nrf802154_netdev);
|
|
|
|
|
|
|
|
nrf802154_hal_setup(&nrf802154_netdev.submac.dev);
|
|
|
|
nrf802154_init();
|
|
|
|
if (netif_add_noaddr(&netif[0], &nrf802154_netdev.dev.netdev, lwip_netdev_init,
|
2021-03-05 00:14:29 +01:00
|
|
|
tcpip_6lowpan_input) == NULL) {
|
2020-06-07 21:24:14 +02:00
|
|
|
DEBUG("Could not add nrf802154 device\n");
|
|
|
|
return;
|
|
|
|
}
|
2015-11-13 19:41:11 +01:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/* also allow for external interface definition */
|
2015-11-15 20:58:39 +01:00
|
|
|
tcpip_init(NULL, NULL);
|
2021-03-24 22:59:26 +01:00
|
|
|
#if IS_USED(MODULE_LWIP_DHCP_AUTO)
|
|
|
|
{
|
|
|
|
/* Start DHCP on all supported netifs. Interfaces that support
|
|
|
|
* link status events will reset DHCP retries when link comes up. */
|
|
|
|
struct netif *n = NULL;
|
|
|
|
NETIF_FOREACH(n) {
|
|
|
|
if (netif_is_flag_set(n, NETIF_FLAG_ETHERNET)) {
|
2021-07-13 13:45:16 +02:00
|
|
|
netifapi_dhcp_start(n);
|
2021-03-24 22:59:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-26 20:51:08 +02:00
|
|
|
#endif
|
2015-11-15 20:58:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @} */
|