diff --git a/pkg/lwip/contrib/_netif.c b/pkg/lwip/contrib/_netif.c index 069693f22c..ec0d8b14aa 100644 --- a/pkg/lwip/contrib/_netif.c +++ b/pkg/lwip/contrib/_netif.c @@ -16,12 +16,13 @@ */ #include "fmt.h" -#include "lwip/netif.h" +#include "lwip/netif/compat.h" #include "net/netif.h" int netif_get_name(netif_t *iface, char *name) { - struct netif *netif = (struct netif *)iface; + lwip_netif_t *lwip_netif = (lwip_netif_t*) iface; + struct netif *netif = &lwip_netif->lwip_netif; int res = 2; name[0] = netif->name[0]; diff --git a/pkg/lwip/contrib/netdev/lwip_netdev.c b/pkg/lwip/contrib/netdev/lwip_netdev.c index e70e4eacee..c256d3ddbe 100644 --- a/pkg/lwip/contrib/netdev/lwip_netdev.c +++ b/pkg/lwip/contrib/netdev/lwip_netdev.c @@ -21,6 +21,7 @@ #include "lwip/ethip6.h" #include "lwip/netif.h" #include "lwip/netifapi.h" +#include "lwip/netif/compat.h" #include "lwip/netif/netdev.h" #include "lwip/opt.h" #include "lwip/pbuf.h" @@ -192,7 +193,6 @@ err_t lwip_netdev_init(struct netif *netif) } netif->flags |= NETIF_FLAG_IGMP; netif->flags |= NETIF_FLAG_MLD6; - netdev->context = netif; #if LWIP_IPV6_AUTOCONFIG netif->ip6_autoconfig_enabled = 1; #endif @@ -279,7 +279,8 @@ static void _event_cb(netdev_t *dev, netdev_event_t event) } } else { - struct netif *netif = dev->context; + lwip_netif_t *compat_netif = dev->context; + struct netif *netif = &compat_netif->lwip_netif; switch (event) { case NETDEV_EVENT_RX_COMPLETE: { struct pbuf *p = _get_recv_pkt(dev); diff --git a/pkg/lwip/include/lwip/netif/compat.h b/pkg/lwip/include/lwip/netif/compat.h new file mode 100644 index 0000000000..0a3c97f9e4 --- /dev/null +++ b/pkg/lwip/include/lwip/netif/compat.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2021 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 pkg_lwip + * + * @{ + * + * @file + * @brief lwIP definition based on common netif_t struct for network + * stack-independent API. + * + * @author Erik Ekman + */ +#ifndef LWIP_NETIF_COMPAT_H +#define LWIP_NETIF_COMPAT_H + +#include "lwip/netif.h" +#include "net/netif.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Representation of a network interface + */ +typedef struct { + netif_t common_netif; /**< network interface descriptor */ + struct netif lwip_netif; /**< lwIP interface data */ +} lwip_netif_t; + +#ifdef __cplusplus +} +#endif + +#endif /* LWIP_NETIF_COMPAT_H */ +/** @} */ diff --git a/pkg/lwip/include/lwip/netif/netdev.h b/pkg/lwip/include/lwip/netif/netdev.h index c3b1ec77cf..2163021a9f 100644 --- a/pkg/lwip/include/lwip/netif/netdev.h +++ b/pkg/lwip/include/lwip/netif/netdev.h @@ -46,6 +46,7 @@ extern "C" { * to an existing netdev_t instance * * @pre netif->state is set to an existing netdev_t instance. + * netif->state->context pointing to the lwip_netif_t containing this netif. * * @param[in] netif The network interface intended to be initialized. * diff --git a/pkg/lwip/include/lwip_init_devs.h b/pkg/lwip/include/lwip_init_devs.h index 3e65453ba3..d0344f4fb4 100644 --- a/pkg/lwip/include/lwip_init_devs.h +++ b/pkg/lwip/include/lwip_init_devs.h @@ -24,7 +24,7 @@ extern "C" { #endif -#include "lwip/netif.h" +#include "lwip/netif/compat.h" #include "net/netdev.h" #include "xfa.h" @@ -39,7 +39,7 @@ void lwip_netif_init_devs(void); * The netif will be set up using the `lwip_netdev_init` helper. * The first netif added will be marked as the default route. */ -struct netif *lwip_add_ethernet(struct netif *netif, netdev_t *state); +struct netif *lwip_add_ethernet(lwip_netif_t *netif, netdev_t *state); #if IS_USED(MODULE_LWIP_SIXLOWPAN) /** @@ -50,7 +50,7 @@ struct netif *lwip_add_ethernet(struct netif *netif, netdev_t *state); * * The netif will be set up using the `lwip_netdev_init` helper. */ -struct netif *lwip_add_6lowpan(struct netif *netif, netdev_t *state); +struct netif *lwip_add_6lowpan(lwip_netif_t *netif, netdev_t *state); #endif /* MODULE_LWIP_SIXLOWPAN */ typedef void (*lwip_netif_setup_func_t)(void); diff --git a/pkg/lwip/init_devs/auto_init_at86rf215.c b/pkg/lwip/init_devs/auto_init_at86rf215.c index 6932026581..6e2b2cd9fc 100644 --- a/pkg/lwip/init_devs/auto_init_at86rf215.c +++ b/pkg/lwip/init_devs/auto_init_at86rf215.c @@ -28,7 +28,7 @@ #define USED_BANDS (IS_USED(MODULE_AT86RF215_SUBGHZ) + IS_USED(MODULE_AT86RF215_24GHZ)) #define NETIF_AT86RF215_NUMOF ARRAY_SIZE(at86rf215_params) -static struct netif netif[NETIF_AT86RF215_NUMOF * USED_BANDS]; +static lwip_netif_t netif[NETIF_AT86RF215_NUMOF * USED_BANDS]; static at86rf215_t at86rf215_devs[NETIF_AT86RF215_NUMOF * USED_BANDS]; static void auto_init_at86rf215(void) @@ -38,8 +38,8 @@ static void auto_init_at86rf215(void) at86rf215_t *dev_09 = NULL; at86rf215_t *dev_24 = NULL; - struct netif *netif_09 = NULL; - struct netif *netif_24 = NULL; + lwip_netif_t *netif_09 = NULL; + lwip_netif_t *netif_24 = NULL; if (IS_USED(MODULE_AT86RF215_SUBGHZ)) { dev_09 = &at86rf215_devs[i]; diff --git a/pkg/lwip/init_devs/auto_init_at86rf2xx.c b/pkg/lwip/init_devs/auto_init_at86rf2xx.c index 6063471264..b017120a66 100644 --- a/pkg/lwip/init_devs/auto_init_at86rf2xx.c +++ b/pkg/lwip/init_devs/auto_init_at86rf2xx.c @@ -27,7 +27,7 @@ #define NETIF_AT86RF2XX_NUMOF ARRAY_SIZE(at86rf2xx_params) -static struct netif netif[NETIF_AT86RF2XX_NUMOF]; +static lwip_netif_t netif[NETIF_AT86RF2XX_NUMOF]; static at86rf2xx_t at86rf2xx_devs[NETIF_AT86RF2XX_NUMOF]; static void auto_init_at86rf2xx(void) diff --git a/pkg/lwip/init_devs/auto_init_atwinc15x0.c b/pkg/lwip/init_devs/auto_init_atwinc15x0.c index 66342c571a..827a1a209f 100644 --- a/pkg/lwip/init_devs/auto_init_atwinc15x0.c +++ b/pkg/lwip/init_devs/auto_init_atwinc15x0.c @@ -27,7 +27,7 @@ #define NETIF_ATWINC_NUMOF ARRAY_SIZE(atwinc15x0_params) -static struct netif netif[NETIF_ATWINC_NUMOF]; +static lwip_netif_t netif[NETIF_ATWINC_NUMOF]; static atwinc15x0_t atwinc15x0_devs[NETIF_ATWINC_NUMOF]; static void auto_init_atwinc15x0(void) diff --git a/pkg/lwip/init_devs/auto_init_cc2538_rf.c b/pkg/lwip/init_devs/auto_init_cc2538_rf.c index 24539fd4fa..afbd4189b0 100644 --- a/pkg/lwip/init_devs/auto_init_cc2538_rf.c +++ b/pkg/lwip/init_devs/auto_init_cc2538_rf.c @@ -25,7 +25,7 @@ #define ENABLE_DEBUG 0 #include "debug.h" -static struct netif netif; +static lwip_netif_t netif; static netdev_ieee802154_submac_t cc2538_rf_netdev; static void auto_init_cc2538_rf(void) diff --git a/pkg/lwip/init_devs/auto_init_dose.c b/pkg/lwip/init_devs/auto_init_dose.c index 604d67b81b..09abe2c851 100644 --- a/pkg/lwip/init_devs/auto_init_dose.c +++ b/pkg/lwip/init_devs/auto_init_dose.c @@ -27,7 +27,7 @@ #define NETIF_DOSE_NUMOF ARRAY_SIZE(dose_params) -static struct netif netif[NETIF_DOSE_NUMOF]; +static lwip_netif_t netif[NETIF_DOSE_NUMOF]; static dose_t dose_devs[NETIF_DOSE_NUMOF]; static void auto_init_dose(void) diff --git a/pkg/lwip/init_devs/auto_init_enc28j60.c b/pkg/lwip/init_devs/auto_init_enc28j60.c index 932036d30a..42c18d9880 100644 --- a/pkg/lwip/init_devs/auto_init_enc28j60.c +++ b/pkg/lwip/init_devs/auto_init_enc28j60.c @@ -27,7 +27,7 @@ #define NETIF_ENC28J60_NUMOF ARRAY_SIZE(enc28j60_params) -static struct netif netif[NETIF_ENC28J60_NUMOF]; +static lwip_netif_t netif[NETIF_ENC28J60_NUMOF]; static enc28j60_t enc28j60_devs[NETIF_ENC28J60_NUMOF]; static void auto_init_enc28j60(void) diff --git a/pkg/lwip/init_devs/auto_init_esp_eth.c b/pkg/lwip/init_devs/auto_init_esp_eth.c index 319ea23114..4212420c94 100644 --- a/pkg/lwip/init_devs/auto_init_esp_eth.c +++ b/pkg/lwip/init_devs/auto_init_esp_eth.c @@ -27,7 +27,7 @@ extern esp_eth_netdev_t _esp_eth_dev; extern void esp_eth_setup(esp_eth_netdev_t* dev); -static struct netif netif; +static lwip_netif_t netif; static void auto_init_esp_eth(void) { diff --git a/pkg/lwip/init_devs/auto_init_esp_wifi.c b/pkg/lwip/init_devs/auto_init_esp_wifi.c index 8b2c187928..9256b88d3a 100644 --- a/pkg/lwip/init_devs/auto_init_esp_wifi.c +++ b/pkg/lwip/init_devs/auto_init_esp_wifi.c @@ -27,7 +27,7 @@ extern esp_wifi_netdev_t _esp_wifi_dev; extern void esp_wifi_setup(esp_wifi_netdev_t *dev); -static struct netif netif; +static lwip_netif_t netif; static void auto_init_esp_wifi(void) { diff --git a/pkg/lwip/init_devs/auto_init_ethos.c b/pkg/lwip/init_devs/auto_init_ethos.c index 96270ced65..c3058b40ac 100644 --- a/pkg/lwip/init_devs/auto_init_ethos.c +++ b/pkg/lwip/init_devs/auto_init_ethos.c @@ -27,7 +27,7 @@ #define NETIF_ETHOS_NUMOF ARRAY_SIZE(ethos_params) -static struct netif netif[NETIF_ETHOS_NUMOF]; +static lwip_netif_t netif[NETIF_ETHOS_NUMOF]; static ethos_t ethos_devs[NETIF_ETHOS_NUMOF]; static uint8_t _inbuf[NETIF_ETHOS_NUMOF][2048]; diff --git a/pkg/lwip/init_devs/auto_init_mrf24j40.c b/pkg/lwip/init_devs/auto_init_mrf24j40.c index 3926db819f..1fb59decad 100644 --- a/pkg/lwip/init_devs/auto_init_mrf24j40.c +++ b/pkg/lwip/init_devs/auto_init_mrf24j40.c @@ -28,7 +28,7 @@ #define NETIF_MRF24J40_NUMOF ARRAY_SIZE(mrf24j40_params) -static struct netif netif[NETIF_MRF24J40_NUMOF]; +static lwip_netif_t netif[NETIF_MRF24J40_NUMOF]; static mrf24j40_t mrf24j40_devs[NETIF_MRF24J40_NUMOF]; static void auto_init_mrf24j40(void) diff --git a/pkg/lwip/init_devs/auto_init_netdev_tap.c b/pkg/lwip/init_devs/auto_init_netdev_tap.c index effebbf637..034523ec34 100644 --- a/pkg/lwip/init_devs/auto_init_netdev_tap.c +++ b/pkg/lwip/init_devs/auto_init_netdev_tap.c @@ -27,7 +27,7 @@ #define NETIF_TAP_NUMOF (NETDEV_TAP_MAX) -static struct netif netif[NETIF_TAP_NUMOF]; +static lwip_netif_t netif[NETIF_TAP_NUMOF]; static netdev_tap_t netdev_taps[NETIF_TAP_NUMOF]; static void auto_init_netdev_tap(void) diff --git a/pkg/lwip/init_devs/auto_init_nrf802154.c b/pkg/lwip/init_devs/auto_init_nrf802154.c index 829137add2..59aae8ad44 100644 --- a/pkg/lwip/init_devs/auto_init_nrf802154.c +++ b/pkg/lwip/init_devs/auto_init_nrf802154.c @@ -25,7 +25,7 @@ #define ENABLE_DEBUG 0 #include "debug.h" -static struct netif netif; +static lwip_netif_t netif; static netdev_ieee802154_submac_t nrf802154_netdev; static void auto_init_nrf802154(void) diff --git a/pkg/lwip/init_devs/auto_init_sam0_eth.c b/pkg/lwip/init_devs/auto_init_sam0_eth.c index e3068d16b4..822f5e35c1 100644 --- a/pkg/lwip/init_devs/auto_init_sam0_eth.c +++ b/pkg/lwip/init_devs/auto_init_sam0_eth.c @@ -27,7 +27,7 @@ static netdev_t sam0_eth; extern void sam0_eth_setup(netdev_t *netdev); -static struct netif netif; +static lwip_netif_t netif; static void auto_init_sam0_eth(void) { diff --git a/pkg/lwip/init_devs/auto_init_socket_zep.c b/pkg/lwip/init_devs/auto_init_socket_zep.c index ebd5b028c6..571265b476 100644 --- a/pkg/lwip/init_devs/auto_init_socket_zep.c +++ b/pkg/lwip/init_devs/auto_init_socket_zep.c @@ -28,7 +28,7 @@ #define NETIF_SOCKET_ZEP_NUMOF ARRAY_SIZE(socket_zep_params) -static struct netif netif[NETIF_SOCKET_ZEP_NUMOF]; +static lwip_netif_t netif[NETIF_SOCKET_ZEP_NUMOF]; static socket_zep_t socket_zep_devs[NETIF_SOCKET_ZEP_NUMOF]; static netdev_ieee802154_submac_t socket_zep_netdev[SOCKET_ZEP_MAX]; diff --git a/pkg/lwip/init_devs/auto_init_stm32_eth.c b/pkg/lwip/init_devs/auto_init_stm32_eth.c index 864059d620..d1d48e1ade 100644 --- a/pkg/lwip/init_devs/auto_init_stm32_eth.c +++ b/pkg/lwip/init_devs/auto_init_stm32_eth.c @@ -27,7 +27,7 @@ static netdev_t stm32_eth; extern void stm32_eth_netdev_setup(netdev_t *netdev); -static struct netif netif; +static lwip_netif_t netif; static void auto_init_stm32_eth(void) { diff --git a/pkg/lwip/init_devs/init.c b/pkg/lwip/init_devs/init.c index c5ea854e96..fbc25351a7 100644 --- a/pkg/lwip/init_devs/init.c +++ b/pkg/lwip/init_devs/init.c @@ -18,6 +18,7 @@ #include "kernel_defines.h" #include "lwip_init_devs.h" #include "lwip/tcpip.h" +#include "lwip/netif/compat.h" #include "lwip/netif/netdev.h" #include "netif/lowpan6.h" #include "xfa.h" @@ -50,10 +51,21 @@ void lwip_netif_init_devs(void) } } -struct netif *lwip_add_ethernet(struct netif *netif, netdev_t *state) +static struct netif *setup_netif(lwip_netif_t *netif, netdev_t *state, + netif_input_fn input_fn) { - struct netif *_if = netif_add_noaddr(netif, state, lwip_netdev_init, - tcpip_input); + 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); if (_if && netif_default == NULL) { netif_set_default(_if); } @@ -61,9 +73,9 @@ struct netif *lwip_add_ethernet(struct netif *netif, netdev_t *state) } #if IS_USED(MODULE_LWIP_SIXLOWPAN) -struct netif *lwip_add_6lowpan(struct netif *netif, netdev_t *state) +struct netif *lwip_add_6lowpan(lwip_netif_t *netif, netdev_t *state) { - return netif_add_noaddr(netif, state, lwip_netdev_init, tcpip_6lowpan_input); + return setup_netif(netif, state, tcpip_6lowpan_input); } #endif /* MODULE_LWIP_SIXLOWPAN */ diff --git a/sys/shell/commands/sc_lwip_netif.c b/sys/shell/commands/sc_lwip_netif.c index ee2d572b32..d86a78c8eb 100644 --- a/sys/shell/commands/sc_lwip_netif.c +++ b/sys/shell/commands/sc_lwip_netif.c @@ -18,8 +18,9 @@ * @} */ +#include #include -#include "lwip/netif.h" +#include "lwip/netif/compat.h" #include "net/netdev.h" #include "net/netopt.h" @@ -43,9 +44,10 @@ static void _netif_list_ipv6(struct netif *netif, int addr_index) { static void _netif_list(struct netif *netif) { int i; - char name[8]; + char name[CONFIG_NETIF_NAMELENMAX]; struct netdev *dev = netif->state; - netif_get_name((netif_t *)netif, name); + lwip_netif_t *compat = container_of(netif, lwip_netif_t, lwip_netif); + netif_get_name(&compat->common_netif, name); printf("Iface %s HWaddr: ", name); for (i = 0; i < netif->hwaddr_len; i++) { printf("%02x", netif->hwaddr[i]); diff --git a/tests/lwip_sock_ip/stack.c b/tests/lwip_sock_ip/stack.c index b8758cc525..123f135b42 100644 --- a/tests/lwip_sock_ip/stack.c +++ b/tests/lwip_sock_ip/stack.c @@ -31,7 +31,7 @@ #include "lwip/inet_chksum.h" #include "lwip/nd6.h" #include "lwip/priv/nd6_priv.h" -#include "lwip/netif.h" +#include "lwip/netif/compat.h" #include "lwip/netif/netdev.h" #include "lwip/tcpip.h" #include "netif/etharp.h" @@ -46,7 +46,7 @@ static msg_t _msg_queue[_MSG_QUEUE_SIZE]; static uint8_t _netdev_buffer[_NETDEV_BUFFER_SIZE]; netdev_test_t netdev; -static struct netif netif; +static lwip_netif_t lwip_netif; static kernel_pid_t _check_pid = KERNEL_PID_UNDEF; static mutex_t _netdev_buffer_mutex = MUTEX_INIT; static uint8_t _netdev_buffer_size; @@ -138,6 +138,7 @@ static int _netdev_send(netdev_t *dev, const iolist_t *iolist) void _net_init(void) { + struct netif *netif = &lwip_netif.lwip_netif; msg_init_queue(_msg_queue, _MSG_QUEUE_SIZE); _check_pid = thread_getpid(); @@ -156,14 +157,15 @@ void _net_init(void) netdev_test_set_isr_cb(&netdev, _netdev_isr); /* netdev needs to be set-up */ expect(netdev.netdev.netdev.driver); + netdev.netdev.netdev.context = &lwip_netif; #if LWIP_IPV4 ip4_addr_t local4, mask4, gw4; local4.addr = _TEST_ADDR4_LOCAL; mask4.addr = _TEST_ADDR4_MASK; gw4.addr = _TEST_ADDR4_GW; - netif_add(&netif, &local4, &mask4, &gw4, &netdev, lwip_netdev_init, tcpip_input); + netif_add(netif, &local4, &mask4, &gw4, &netdev, lwip_netdev_init, tcpip_input); #else - netif_add(&netif, &netdev, lwip_netdev_init, tcpip_input); + netif_add(netif, &netdev, lwip_netdev_init, tcpip_input); #endif #if LWIP_IPV6 static const uint8_t local6_a[] = _TEST_ADDR6_LOCAL; @@ -175,12 +177,12 @@ void _net_init(void) memcpy(&local6.addr, local6_a, sizeof(local6_a)); ip6_addr_clear_zone(&local6); - netif_add_ip6_address(&netif, &local6, &idx); + netif_add_ip6_address(netif, &local6, &idx); for (int i = 0; i <= idx; i++) { - netif.ip6_addr_state[i] |= IP6_ADDR_VALID; + netif->ip6_addr_state[i] |= IP6_ADDR_VALID; } #endif - netif_set_default(&netif); + netif_set_default(netif); lwip_bootstrap(); ztimer_sleep(ZTIMER_MSEC, 3 * MS_PER_SEC); /* Let the auto-configuration run warm */ } @@ -210,13 +212,14 @@ void _prepare_send_checks(void) LWIP_ND6_NUM_NEIGHBORS * sizeof(struct nd6_neighbor_cache_entry)); for (int i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { struct nd6_neighbor_cache_entry *nc = &neighbor_cache[i]; + struct netif *netif = &lwip_netif.lwip_netif; if (nc->state == ND6_NO_ENTRY) { nc->state = ND6_REACHABLE; memcpy(&nc->next_hop_address, remote6, sizeof(remote6)); ip6_addr_assign_zone(&nc->next_hop_address, - IP6_UNICAST, &netif); + IP6_UNICAST, netif); memcpy(&nc->lladdr, mac, 6); - nc->netif = &netif; + nc->netif = netif; nc->counter.reachable_time = UINT32_MAX; break; } diff --git a/tests/lwip_sock_udp/stack.c b/tests/lwip_sock_udp/stack.c index d80588e73f..231915d4f3 100644 --- a/tests/lwip_sock_udp/stack.c +++ b/tests/lwip_sock_udp/stack.c @@ -32,7 +32,7 @@ #include "lwip/inet_chksum.h" #include "lwip/nd6.h" #include "lwip/priv/nd6_priv.h" -#include "lwip/netif.h" +#include "lwip/netif/compat.h" #include "lwip/netif/netdev.h" #include "lwip/opt.h" #include "lwip/tcpip.h" @@ -48,7 +48,7 @@ static msg_t _msg_queue[_MSG_QUEUE_SIZE]; static uint8_t _netdev_buffer[_NETDEV_BUFFER_SIZE]; netdev_test_t netdev; -static struct netif netif; +static lwip_netif_t lwip_netif; static kernel_pid_t _check_pid = KERNEL_PID_UNDEF; static mutex_t _netdev_buffer_mutex = MUTEX_INIT; static uint8_t _netdev_buffer_size; @@ -141,6 +141,7 @@ static int _netdev_send(netdev_t *dev, const iolist_t *iolist) void _net_init(void) { + struct netif *netif = &lwip_netif.lwip_netif; msg_init_queue(_msg_queue, _MSG_QUEUE_SIZE); _check_pid = thread_getpid(); @@ -159,14 +160,15 @@ void _net_init(void) netdev_test_set_isr_cb(&netdev, _netdev_isr); /* netdev needs to be set-up */ expect(netdev.netdev.netdev.driver); + netdev.netdev.netdev.context = &lwip_netif; #if LWIP_IPV4 ip4_addr_t local4, mask4, gw4; local4.addr = _TEST_ADDR4_LOCAL; mask4.addr = _TEST_ADDR4_MASK; gw4.addr = _TEST_ADDR4_GW; - netif_add(&netif, &local4, &mask4, &gw4, &netdev, lwip_netdev_init, tcpip_input); + netif_add(netif, &local4, &mask4, &gw4, &netdev, lwip_netdev_init, tcpip_input); #else - netif_add(&netif, &netdev, lwip_netdev_init, tcpip_input); + netif_add(netif, &netdev, lwip_netdev_init, tcpip_input); #endif #if LWIP_IPV6 static const uint8_t local6_a[] = _TEST_ADDR6_LOCAL; @@ -178,12 +180,12 @@ void _net_init(void) memcpy(&local6.addr, local6_a, sizeof(local6.addr)); ip6_addr_clear_zone(&local6); - netif_add_ip6_address(&netif, &local6, &idx); + netif_add_ip6_address(netif, &local6, &idx); for (int i = 0; i <= idx; i++) { - netif.ip6_addr_state[i] |= IP6_ADDR_VALID; + netif->ip6_addr_state[i] |= IP6_ADDR_VALID; } #endif - netif_set_default(&netif); + netif_set_default(netif); lwip_bootstrap(); ztimer_sleep(ZTIMER_MSEC, 3 * MS_PER_SEC); /* Let the auto-configuration run warm */ } @@ -213,13 +215,14 @@ void _prepare_send_checks(void) LWIP_ND6_NUM_NEIGHBORS * sizeof(struct nd6_neighbor_cache_entry)); for (int i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { struct nd6_neighbor_cache_entry *nc = &neighbor_cache[i]; + struct netif *netif = &lwip_netif.lwip_netif; if (nc->state == ND6_NO_ENTRY) { nc->state = ND6_REACHABLE; memcpy(&nc->next_hop_address.addr, remote6, sizeof(nc->next_hop_address.addr)); ip6_addr_assign_zone(&nc->next_hop_address, - IP6_UNICAST, &netif); + IP6_UNICAST, netif); memcpy(&nc->lladdr, mac, 6); - nc->netif = &netif; + nc->netif = netif; nc->counter.reachable_time = UINT32_MAX; break; }