From 237cc88b9f132a8a442645f5c98c69b11228ace4 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Tue, 11 Sep 2018 14:36:42 +0800 Subject: [PATCH] lwip: add code for sending gratuitous ARP periodically --- components/lwip/Kconfig | 17 +++++++++++++++++ components/lwip/lwip | 2 +- components/lwip/port/esp32/include/lwipopts.h | 1 + components/tcpip_adapter/tcpip_adapter_lwip.c | 7 +++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 55141ffbb3..5dfd3cade1 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -128,6 +128,23 @@ config LWIP_ETHARP_TRUST_IP_MAC So the recommendation is to disable this option. Here the LAN peer means the other side to which the ESP station or soft-AP is connected. +config ESP_GRATUITOUS_ARP + bool "Send gratuitous ARP periodically" + default y + help + Enable this option allows to send gratuitous ARP periodically. + + This option solve the compatibility issues.If the ARP table of the AP is old, and the AP + doesn't send ARP request to update it's ARP table, this will lead to the STA sending IP packet fail. + Thus we send gratuitous ARP periodically to let AP update it's ARP table. + +config GARP_TMR_INTERVAL + int "GARP timer interval(seconds)" + default 60 + depends on ESP_GRATUITOUS_ARP + help + Set the timer interval for gratuitous ARP. The default value is 60s + config TCPIP_RECVMBOX_SIZE int "TCPIP task receive mail box size" default 32 diff --git a/components/lwip/lwip b/components/lwip/lwip index 18548d1e25..e6bb43349e 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit 18548d1e256f7651fb4da48dbd770556e0eca8ce +Subproject commit e6bb43349ed859eba4c1e3cae15b932627c45c4b diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h index 6492003075..db6f982462 100644 --- a/components/lwip/port/esp32/include/lwipopts.h +++ b/components/lwip/port/esp32/include/lwipopts.h @@ -739,6 +739,7 @@ #define ESP_PING 1 #define ESP_HAS_SELECT 1 #define ESP_AUTO_RECV 1 +#define ESP_GRATUITOUS_ARP CONFIG_ESP_GRATUITOUS_ARP #if CONFIG_LWIP_IRAM_OPTIMIZATION #define ESP_IRAM_ATTR IRAM_ATTR diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index a92cfd7c31..e06a2205dc 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -26,6 +26,7 @@ #include "lwip/ip6_addr.h" #include "lwip/nd6.h" #include "lwip/priv/tcpip_priv.h" +#include "lwip/netif.h" #if LWIP_DNS /* don't build if not configured for use in lwipopts.h */ #include "lwip/dns.h" #endif @@ -184,6 +185,12 @@ static esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, netif_init = tcpip_if_to_netif_init_fn(tcpip_if); assert(netif_init != NULL); netif_add(esp_netif[tcpip_if], &ip_info->ip, &ip_info->netmask, &ip_info->gw, NULL, netif_init, tcpip_input); +#if ESP_GRATUITOUS_ARP + if (tcpip_if == TCPIP_ADAPTER_IF_STA || tcpip_if == TCPIP_ADAPTER_IF_ETH) { + netif_set_garp_flag(esp_netif[tcpip_if]); + } +#endif + } if (tcpip_if == TCPIP_ADAPTER_IF_AP) {