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

pkg/lwip: Move socket_zep to netif auto init

This commit is contained in:
Erik Ekman 2021-08-15 10:36:24 +02:00
parent 9002da3d80
commit 06dfcdd3fa
3 changed files with 50 additions and 30 deletions

View File

@ -22,45 +22,15 @@
#include "lwip/netifapi.h"
#include "netif/lowpan6.h"
#ifdef MODULE_SOCKET_ZEP
#include "socket_zep.h"
#include "socket_zep_params.h"
#endif
#include "lwip.h"
#include "lwip_init_devs.h"
#define ENABLE_DEBUG 0
#include "debug.h"
#ifdef MODULE_SOCKET_ZEP
#define LWIP_NETIF_NUMOF ARRAY_SIZE(socket_zep_params)
#endif
#ifdef LWIP_NETIF_NUMOF
static struct netif netif[LWIP_NETIF_NUMOF];
#endif
#ifdef MODULE_SOCKET_ZEP
static socket_zep_t socket_zep_devs[LWIP_NETIF_NUMOF];
#endif
void lwip_bootstrap(void)
{
lwip_netif_init_devs();
/* TODO: do for every eligible netdev */
#ifdef LWIP_NETIF_NUMOF
#if defined(MODULE_SOCKET_ZEP)
for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) {
socket_zep_setup(&socket_zep_devs[i], &socket_zep_params[i], i);
if (netif_add_noaddr(&netif[i], &socket_zep_devs[i].netdev.netdev, lwip_netdev_init,
tcpip_6lowpan_input) == NULL) {
DEBUG("Could not add socket_zep device\n");
return;
}
}
#endif
#endif
/* also allow for external interface definition */
tcpip_init(NULL, NULL);
#if IS_USED(MODULE_LWIP_DHCP_AUTO)

View File

@ -0,0 +1,43 @@
/*
* 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.
*/
/**
* @ingroup sys_auto_init_lwip_netif
* @{
*
* @file
* @brief Auto initialization for socket_zep network interfaces
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
* @author Erik Ekman <eekman@google.com>
*/
#include "socket_zep.h"
#include "socket_zep_params.h"
#include "lwip_init_devs.h"
#define ENABLE_DEBUG 0
#include "debug.h"
#define NETIF_SOCKET_ZEP_NUMOF ARRAY_SIZE(socket_zep_params)
static struct netif netif[NETIF_SOCKET_ZEP_NUMOF];
static socket_zep_t socket_zep_devs[NETIF_SOCKET_ZEP_NUMOF];
void auto_init_socket_zep(void)
{
for (unsigned i = 0; i < NETIF_SOCKET_ZEP_NUMOF; i++) {
socket_zep_setup(&socket_zep_devs[i], &socket_zep_params[i], i);
if (lwip_add_6lowpan(&netif[i], &socket_zep_devs[i].netdev.netdev) == NULL) {
DEBUG("Could not add socket_zep device\n");
return;
}
}
}
/** @} */

View File

@ -26,6 +26,8 @@
*/
void lwip_netif_init_devs(void)
{
/* TODO: do for every eligible netdev */
/* Ethernet interfaces
* ------------------- */
@ -81,6 +83,11 @@ void lwip_netif_init_devs(void)
extern void auto_init_nrf802154(void);
auto_init_nrf802154();
}
if (IS_USED(MODULE_SOCKET_ZEP)) {
extern void auto_init_socket_zep(void);
auto_init_socket_zep();
}
}
struct netif *lwip_add_ethernet(struct netif *netif, netdev_t *state)