mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pkg/lwip: Add lwip_netif_t struct
Extending netif_t struct from sys/net/netif to support the stack-independent API.
This commit is contained in:
parent
83c2f2d367
commit
efeaac51ca
@ -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);
|
||||
|
43
pkg/lwip/include/lwip/netif/compat.h
Normal file
43
pkg/lwip/include/lwip/netif/compat.h
Normal file
@ -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 <eekman@google.com>
|
||||
*/
|
||||
#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 */
|
||||
/** @} */
|
@ -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.
|
||||
*
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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];
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -27,7 +27,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 void auto_init_socket_zep(void)
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user