Explorar el Código

Merge branch 'bugfix/tw24694_dns_request_no_reply' into 'master'

lwip: add code for sending gratuitous ARP periodically

See merge request idf/esp-idf!3241
Jiang Jiang Jian hace 7 años
padre
commit
518942ec61

+ 17 - 0
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

+ 1 - 1
components/lwip/lwip

@@ -1 +1 @@
-Subproject commit 18548d1e256f7651fb4da48dbd770556e0eca8ce
+Subproject commit e6bb43349ed859eba4c1e3cae15b932627c45c4b

+ 1 - 0
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

+ 7 - 0
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) {