mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-07-15 08:32:42 +08:00
Merge branch 'feature/add_gratuitous_arp' into 'master'
feat(lwip): add gratuitous arp See merge request sdk/ESP8266_RTOS_SDK!1041
This commit is contained in:
@ -46,6 +46,23 @@ config LWIP_ARP_MAXAGE
|
||||
range 100 65535
|
||||
default 300
|
||||
|
||||
config LWIP_ESP_GRATUITOUS_ARP
|
||||
bool "Send gratuitous ARP periodically"
|
||||
default n
|
||||
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 LWIP_GARP_TMR_INTERVAL
|
||||
int "GARP timer interval(seconds)"
|
||||
default 60
|
||||
depends on LWIP_ESP_GRATUITOUS_ARP
|
||||
help
|
||||
Set the timer interval for gratuitous ARP. The default value is 60s
|
||||
|
||||
endmenu # LWIP ARP
|
||||
|
||||
menu "SOCKET"
|
||||
|
@ -138,6 +138,20 @@ static err_t etharp_raw(struct netif *netif,
|
||||
const struct eth_addr *hwdst_addr, const ip4_addr_t *ipdst_addr,
|
||||
const u16_t opcode);
|
||||
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
void garp_tmr(void)
|
||||
{
|
||||
struct netif* garp_netif = NULL;
|
||||
for (garp_netif = netif_list; garp_netif != NULL; garp_netif = garp_netif->next) {
|
||||
if (netif_is_up(garp_netif) && netif_is_link_up(garp_netif) && !ip4_addr_isany_val(*netif_ip4_addr(garp_netif))) {
|
||||
if ((garp_netif->flags & NETIF_FLAG_ETHARP) && (garp_netif->flags & NETIF_FLAG_GARP)) {
|
||||
etharp_gratuitous(garp_netif);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ARP_QUEUEING
|
||||
/**
|
||||
* Free a complete queue of etharp entries
|
||||
|
@ -367,6 +367,16 @@ netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *
|
||||
}
|
||||
#endif /* LWIP_IPV4*/
|
||||
|
||||
/**
|
||||
* Set the netif flags for GARP
|
||||
*/
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
void netif_set_garp_flag(struct netif *netif)
|
||||
{
|
||||
netif->flags |= NETIF_FLAG_GARP;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @ingroup netif
|
||||
* Remove a network interface from the list of lwIP netifs.
|
||||
|
@ -80,6 +80,9 @@ const struct lwip_cyclic_timer lwip_cyclic_timers[] = {
|
||||
#endif /* IP_REASSEMBLY */
|
||||
#if LWIP_ARP
|
||||
{ARP_TMR_INTERVAL, HANDLER(etharp_tmr)},
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
{GARP_TMR_INTERVAL, HANDLER(garp_tmr)},
|
||||
#endif /* ESP_GRATUITOUS_ARP */
|
||||
#endif /* LWIP_ARP */
|
||||
#if LWIP_DHCP
|
||||
{DHCP_COARSE_TIMER_MSECS, HANDLER(dhcp_coarse_tmr)},
|
||||
|
@ -73,6 +73,15 @@ struct etharp_q_entry {
|
||||
};
|
||||
#endif /* ARP_QUEUEING */
|
||||
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
#ifdef CONFIG_LWIP_GARP_TMR_INTERVAL
|
||||
#define GARP_TMR_INTERVAL (CONFIG_LWIP_GARP_TMR_INTERVAL*1000UL)
|
||||
#else
|
||||
#define GARP_TMR_INTERVAL 60000
|
||||
#endif
|
||||
void garp_tmr(void);
|
||||
#endif
|
||||
|
||||
#define etharp_init() /* Compatibility define, no init needed. */
|
||||
void etharp_tmr(void);
|
||||
s8_t etharp_find_addr(struct netif *netif, const ip4_addr_t *ipaddr,
|
||||
|
@ -100,6 +100,11 @@ extern "C" {
|
||||
* Set by the netif driver in its init function. */
|
||||
#define NETIF_FLAG_MLD6 0x40U
|
||||
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
/** If set, the netif will send gratuitous ARP periodically */
|
||||
#define NETIF_FLAG_GARP 0x80U
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -369,6 +374,11 @@ struct netif *netif_add(struct netif *netif,
|
||||
void netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask,
|
||||
const ip4_addr_t *gw);
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
void netif_set_garp_flag(struct netif *netif);
|
||||
#endif
|
||||
|
||||
void netif_remove(struct netif * netif);
|
||||
|
||||
/* Returns a network interface given its name. The name is of the form
|
||||
|
@ -435,8 +435,12 @@
|
||||
* The formula expects settings to be either '0' or '1'.
|
||||
*/
|
||||
#if !defined MEMP_NUM_SYS_TIMEOUT || defined __DOXYGEN__
|
||||
#if ESP_LWIP
|
||||
#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + (PPP_SUPPORT*6*MEMP_NUM_PPP_PCB) + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)) + (ESP_GRATUITOUS_ARP ? 1 : 0)
|
||||
#else
|
||||
#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + (PPP_SUPPORT*6*MEMP_NUM_PPP_PCB) + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_NETBUF: the number of struct netbufs.
|
||||
|
@ -372,7 +372,11 @@ size_t memp_malloc_get_size(size_t type);
|
||||
* The default number of timeouts is calculated here for all enabled modules.
|
||||
* The formula expects settings to be either '0' or '1'.
|
||||
*/
|
||||
#if ESP_LWIP
|
||||
#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + (PPP_SUPPORT*6*MEMP_NUM_PPP_PCB) + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)) + (ESP_GRATUITOUS_ARP ? 1 : 0)
|
||||
#else
|
||||
#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + (PPP_SUPPORT*6*MEMP_NUM_PPP_PCB) + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_NETBUF: the number of struct netbufs.
|
||||
@ -2281,6 +2285,7 @@ size_t memp_malloc_get_size(size_t type);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define ESP_GRATUITOUS_ARP CONFIG_LWIP_ESP_GRATUITOUS_ARP
|
||||
#define ESP_PING 1
|
||||
|
||||
#endif /* __LWIP_HDR_LWIPOPTS_H__ */
|
||||
|
@ -374,6 +374,11 @@ esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_a
|
||||
}
|
||||
}
|
||||
netif_add(esp_netif[tcpip_if], &ip_info->ip, &ip_info->netmask, &ip_info->gw, (void *)tcpip_if, ethernetif_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) {
|
||||
|
Reference in New Issue
Block a user