Browse Source

lwip: add config options for Thread IPv6 border routing

Jiacheng Guo 4 years ago
parent
commit
fd3553b66d

+ 42 - 0
components/lwip/Kconfig

@@ -328,6 +328,28 @@ menu "LWIP"
 
 
             See RFC 4862.
             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
     menuconfig LWIP_NETIF_LOOPBACK
         bool "Support per-interface loopback"
         bool "Support per-interface loopback"
         default y
         default y
@@ -859,6 +881,26 @@ menu "LWIP"
 
 
         endchoice
         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
         choice LWIP_HOOK_NETCONN_EXTERNAL_RESOLVE
             prompt "Netconn external resolve Hook"
             prompt "Netconn external resolve Hook"
             default LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE
             default LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE

+ 10 - 0
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;
     return 0;
 }
 }
 #endif
 #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

+ 6 - 0
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
 #define LWIP_HOOK_IP6_ROUTE lwip_hook_ip6_route
 #endif /* CONFIG_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)
 #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);
 int lwip_hook_netconn_external_resolve(const char *name, ip_addr_t *addr, u8_t addrtype, err_t *err);
 
 

+ 7 - 1
components/lwip/port/esp32/include/lwipopts.h

@@ -453,6 +453,8 @@
  */
  */
 #define LWIP_NETIF_API                      CONFIG_LWIP_NETIF_API
 #define LWIP_NETIF_API                      CONFIG_LWIP_NETIF_API
 
 
+#define LWIP_NETIF_STATUS_CALLBACK      CONFIG_LWIP_NETIF_STATUS_CALLBACK
+
 /*
 /*
    ------------------------------------
    ------------------------------------
    ---------- LOOPIF options ----------
    ---------- LOOPIF options ----------
@@ -688,7 +690,7 @@
  * Some modems do not support IPV6 addressing in local link and
  * Some modems do not support IPV6 addressing in local link and
  * the only option available is to disable IPV6 address negotiation.
  * 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.
  * PPP_NOTIFY_PHASE==1: Support PPP notify phase.
@@ -957,6 +959,10 @@
  */
  */
 #define LWIP_SOCKET_OFFSET              (FD_SETSIZE - CONFIG_LWIP_MAX_SOCKETS)
 #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 */
 /* Enable all Espressif-only options */
 
 
 #define ESP_LWIP                        1
 #define ESP_LWIP                        1