From fd3553b66d601bf2e910fd5e727db55ded29ecea Mon Sep 17 00:00:00 2001 From: Jiacheng Guo Date: Thu, 8 Apr 2021 17:58:50 +0800 Subject: [PATCH] lwip: add config options for Thread IPv6 border routing --- components/lwip/Kconfig | 42 +++++++++++++++++++ .../port/esp32/hooks/lwip_default_hooks.c | 10 +++++ .../port/esp32/include/lwip_default_hooks.h | 6 +++ components/lwip/port/esp32/include/lwipopts.h | 8 +++- 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 339d52b673..ca9e695967 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -328,6 +328,28 @@ menu "LWIP" See RFC 4862. + config LWIP_IPV6_NUM_ADDRESSES + int "Number of IPv6 addresses on each network interface" + depends on LWIP_IPV6 + default 3 + help + The maximum number of IPv6 addresses on each interface. Any additional + addresses will be discarded. + + config LWIP_IPV6_FORWARD + bool "Enable IPv6 forwarding between interfaces" + depends on LWIP_IPV6 + default n + help + Forwarding IPv6 packets between interfaces is only required when acting as + a router. + + config LWIP_NETIF_STATUS_CALLBACK + bool "Enable status callback for network interfaces" + default n + help + Enable callbacks when the network interface is up/down and addresses are changed. + menuconfig LWIP_NETIF_LOOPBACK bool "Support per-interface loopback" default y @@ -859,6 +881,26 @@ menu "LWIP" endchoice + choice LWIP_HOOK_ND6_GET_GW + prompt "IPv6 get gateway Hook" + depends on LWIP_IPV6 + default LWIP_HOOK_ND6_GET_GW_NONE + help + Enables custom IPv6 route hook. + Setting this to "default" provides weak implementation + stub that could be overwritten in application code. + Setting this to "custom" provides hook's declaration + only and expects the application to implement it. + + config LWIP_HOOK_ND6_GET_GW_NONE + bool "No hook declared" + config LWIP_HOOK_ND6_GET_GW_DEFAULT + bool "Default (weak) implementation" + config LWIP_HOOK_ND6_GET_GW_CUSTOM + bool "Custom implementation" + + endchoice + choice LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE prompt "Netconn external resolve Hook" default LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE diff --git a/components/lwip/port/esp32/hooks/lwip_default_hooks.c b/components/lwip/port/esp32/hooks/lwip_default_hooks.c index 468f16d5d0..8e317def40 100644 --- a/components/lwip/port/esp32/hooks/lwip_default_hooks.c +++ b/components/lwip/port/esp32/hooks/lwip_default_hooks.c @@ -38,3 +38,13 @@ int __weak lwip_hook_netconn_external_resolve(const char *name, ip_addr_t *addr, return 0; } #endif + +#ifdef CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT +const ip6_addr_t *lwip_hook_nd6_get_gw(struct netif *netif, const ip6_addr_t *dest) +{ + LWIP_UNUSED_ARG(netif); + LWIP_UNUSED_ARG(dest); + + return 0; +} +#endif diff --git a/components/lwip/port/esp32/include/lwip_default_hooks.h b/components/lwip/port/esp32/include/lwip_default_hooks.h index 4af3c6582c..3f3ec0b2ec 100644 --- a/components/lwip/port/esp32/include/lwip_default_hooks.h +++ b/components/lwip/port/esp32/include/lwip_default_hooks.h @@ -42,6 +42,12 @@ lwip_hook_ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest); #define LWIP_HOOK_IP6_ROUTE lwip_hook_ip6_route #endif /* CONFIG_LWIP_HOOK_IP6_ROUTE... */ +#if defined(CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM) || defined(CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT) +const ip6_addr_t *lwip_hook_nd6_get_gw(struct netif *netif, const ip6_addr_t *dest); + +#define LWIP_HOOK_ND6_GET_GW lwip_hook_nd6_get_gw +#endif /* CONFIG_LWIP_HOOK_ND6_GET_GATEWAY... */ + #if defined(CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM) || defined(CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT) int lwip_hook_netconn_external_resolve(const char *name, ip_addr_t *addr, u8_t addrtype, err_t *err); diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h index 52d2d99de4..5b7d9141f0 100644 --- a/components/lwip/port/esp32/include/lwipopts.h +++ b/components/lwip/port/esp32/include/lwipopts.h @@ -453,6 +453,8 @@ */ #define LWIP_NETIF_API CONFIG_LWIP_NETIF_API +#define LWIP_NETIF_STATUS_CALLBACK CONFIG_LWIP_NETIF_STATUS_CALLBACK + /* ------------------------------------ ---------- LOOPIF options ---------- @@ -688,7 +690,7 @@ * Some modems do not support IPV6 addressing in local link and * the only option available is to disable IPV6 address negotiation. */ -#define PPP_IPV6_SUPPORT CONFIG_LWIP_PPP_ENABLE_IPV6 +#define PPP_IPV6_SUPPORT CONFIG_LWIP_PPP_ENABLE_IPV6 /** * PPP_NOTIFY_PHASE==1: Support PPP notify phase. @@ -957,6 +959,10 @@ */ #define LWIP_SOCKET_OFFSET (FD_SETSIZE - CONFIG_LWIP_MAX_SOCKETS) +#define LWIP_IPV6_FORWARD CONFIG_LWIP_IPV6_FORWARD + +#define LWIP_IPV6_NUM_ADDRESSES CONFIG_LWIP_IPV6_NUM_ADDRESSES + /* Enable all Espressif-only options */ #define ESP_LWIP 1