feat(lwip): send arp request every 10s

This commit is contained in:
Zhang Jun Hao
2018-08-17 11:26:44 +08:00
parent 610b763210
commit f296ae76a0
3 changed files with 39 additions and 0 deletions

View File

@ -35,6 +35,8 @@
#define LWIP_ESP8266
#define SOCKETS_MT
#define ESP_GRATUITOUS_ARP 1
#define GARP_TMR_INTERVAL 10000
//#define SOCKETS_TCP_TRACE
/*

View File

@ -228,6 +228,19 @@ dns_timer(void *arg)
}
#endif /* LWIP_DNS */
#if ESP_GRATUITOUS_ARP
extern void garp_tmr(void);
static void garp_timer(void *arg)
{
LWIP_UNUSED_ARG(arg);
LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: garp_tmr()\n"));
garp_tmr();
sys_timeout(GARP_TMR_INTERVAL, garp_timer, NULL);
}
#endif
#if LWIP_IPV6
/**
* Timer callback function that calls nd6_tmr() and reschedules itself.
@ -310,6 +323,10 @@ sys_timeouts_init(void)
#endif /* LWIP_IPV6_MLD */
#endif /* LWIP_IPV6 */
#if ESP_GRATUITOUS_ARP
sys_timeout(GARP_TMR_INTERVAL, garp_timer, NULL);
#endif
#if NO_SYS
/* Initialise timestamp for sys_check_timeouts */
timeouts_last_time = GET_SYS_TIME_NOW;

View File

@ -56,6 +56,9 @@
#include "lwip/autoip.h"
#include "netif/etharp.h"
#include "lwip/ip6.h"
#include "lwip/netif.h"
#include "esp_wifi.h"
#include "esp_sta.h"
#if PPPOE_SUPPORT
#include "netif/ppp_oe.h"
@ -149,6 +152,23 @@ static u8_t etharp_cached_entry;
#error "ARP_TABLE_SIZE must fit in an s8_t, you have to reduce it in your lwipopts.h"
#endif
#if ESP_GRATUITOUS_ARP
void garp_tmr(void)
{
uint8 status = wifi_station_get_connect_status();
struct netif* garp_netif = (struct netif *)eagle_lwip_getif(STATION_IF);
struct ip_info sta_info;
if (garp_netif != NULL && status == STATION_GOT_IP) {
wifi_get_ip_info(STATION_IF, &sta_info);
if (netif_is_up(garp_netif) && netif_is_link_up(garp_netif) && !ip_addr_isany(&(sta_info.ip))) {
if (garp_netif->flags & NETIF_FLAG_ETHARP) {
etharp_gratuitous(garp_netif);
}
}
}
}
#endif
#if ARP_QUEUEING
/**