2021-03-06 13:43:14 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) Google LLC
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup sys_auto_init_lwip_netif
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Initializes the supported network interfaces for lwIP
|
|
|
|
* @author Erik Ekman <eekman@google.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "kernel_defines.h"
|
|
|
|
#include "lwip_init_devs.h"
|
2021-08-14 18:46:17 +02:00
|
|
|
#include "lwip/tcpip.h"
|
2021-10-08 18:59:32 +02:00
|
|
|
#include "lwip/netif/compat.h"
|
2021-03-06 13:43:14 +01:00
|
|
|
#include "lwip/netif/netdev.h"
|
2021-08-14 18:46:17 +02:00
|
|
|
#include "netif/lowpan6.h"
|
2021-08-20 14:48:41 +02:00
|
|
|
#include "xfa.h"
|
|
|
|
|
|
|
|
XFA_INIT_CONST(lwip_netif_setup_func_t, lwip_netif_eth_xfa);
|
|
|
|
XFA_INIT_CONST(lwip_netif_setup_func_t, lwip_netif_6lowpan_xfa);
|
2021-03-06 13:43:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Initializes network interfaces
|
|
|
|
*/
|
|
|
|
void lwip_netif_init_devs(void)
|
|
|
|
{
|
2021-08-15 10:36:24 +02:00
|
|
|
/* TODO: do for every eligible netdev */
|
|
|
|
|
2021-08-14 18:46:17 +02:00
|
|
|
/* Ethernet interfaces
|
|
|
|
* ------------------- */
|
|
|
|
|
2021-08-20 14:48:41 +02:00
|
|
|
int i;
|
|
|
|
const int eth_devs = XFA_LEN(lwip_netif_setup_func_t, lwip_netif_eth_xfa);
|
|
|
|
for (i = 0; i < eth_devs; i++) {
|
|
|
|
lwip_netif_eth_xfa[i]();
|
2021-03-06 13:43:14 +01:00
|
|
|
}
|
2021-08-14 18:46:17 +02:00
|
|
|
|
|
|
|
/* 6LoWPAN interfaces
|
|
|
|
* ------------------ */
|
|
|
|
|
2021-08-20 14:48:41 +02:00
|
|
|
const int sixlowpan_devs = XFA_LEN(lwip_netif_setup_func_t, lwip_netif_6lowpan_xfa);
|
|
|
|
for (i = 0; i < sixlowpan_devs; i++) {
|
|
|
|
lwip_netif_6lowpan_xfa[i]();
|
2021-08-15 10:36:24 +02:00
|
|
|
}
|
2021-03-06 13:43:14 +01:00
|
|
|
}
|
|
|
|
|
2021-10-08 18:59:32 +02:00
|
|
|
static struct netif *setup_netif(lwip_netif_t *netif, netdev_t *state,
|
|
|
|
netif_input_fn input_fn)
|
2021-03-06 13:43:14 +01:00
|
|
|
{
|
2021-10-08 18:59:32 +02:00
|
|
|
state->context = netif;
|
|
|
|
struct netif *_if = netif_add_noaddr(&netif->lwip_netif, state, lwip_netdev_init,
|
|
|
|
input_fn);
|
|
|
|
if (_if) {
|
|
|
|
netif_register(&netif->common_netif);
|
|
|
|
}
|
|
|
|
return _if;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct netif *lwip_add_ethernet(lwip_netif_t *netif, netdev_t *state)
|
|
|
|
{
|
|
|
|
struct netif *_if = setup_netif(netif, state, tcpip_input);
|
2021-03-06 14:19:34 +01:00
|
|
|
if (_if && netif_default == NULL) {
|
|
|
|
netif_set_default(_if);
|
|
|
|
}
|
|
|
|
return _if;
|
2021-03-06 13:43:14 +01:00
|
|
|
}
|
|
|
|
|
2021-08-20 17:33:47 +02:00
|
|
|
#if IS_USED(MODULE_LWIP_SIXLOWPAN)
|
2021-10-08 18:59:32 +02:00
|
|
|
struct netif *lwip_add_6lowpan(lwip_netif_t *netif, netdev_t *state)
|
2021-08-14 18:46:17 +02:00
|
|
|
{
|
2021-10-08 18:59:32 +02:00
|
|
|
return setup_netif(netif, state, tcpip_6lowpan_input);
|
2021-08-14 18:46:17 +02:00
|
|
|
}
|
2021-08-20 17:33:47 +02:00
|
|
|
#endif /* MODULE_LWIP_SIXLOWPAN */
|
2021-08-14 18:46:17 +02:00
|
|
|
|
2021-03-06 13:43:14 +01:00
|
|
|
/**@}*/
|