mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-08-16 06:58:01 +00:00
add code for sending gratuitous ARP periodically
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
#include "lwip/autoip.h"
|
||||
#include "lwip/prot/iana.h"
|
||||
#include "netif/ethernet.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -137,6 +138,21 @@ 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
|
||||
|
||||
@@ -727,6 +727,17 @@ 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.
|
||||
|
||||
@@ -90,6 +90,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,16 @@ struct etharp_q_entry {
|
||||
};
|
||||
#endif /* ARP_QUEUEING */
|
||||
|
||||
#if ESP_GRATUITOUS_ARP
|
||||
#ifdef CONFIG_GARP_TMR_INTERVAL
|
||||
#define GARP_TMR_INTERVAL (CONFIG_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);
|
||||
ssize_t etharp_find_addr(struct netif *netif, const ip4_addr_t *ipaddr,
|
||||
|
||||
@@ -106,6 +106,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
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -438,6 +443,11 @@ void netif_set_addr(struct netif *netif, const ip4_addr_t *ipaddr, const ip4_add
|
||||
#else /* LWIP_IPV4 */
|
||||
struct netif *netif_add(struct netif *netif, void *state, netif_init_fn init, netif_input_fn input);
|
||||
#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
|
||||
|
||||
@@ -505,8 +505,9 @@
|
||||
* The number of sys timeouts used by the core stack (not apps)
|
||||
* The default number of timeouts is calculated here for all enabled modules.
|
||||
*/
|
||||
#if !defined LWIP_NUM_SYS_TIMEOUT_INTERNAL || defined __DOXYGEN__
|
||||
#define LWIP_NUM_SYS_TIMEOUT_INTERNAL (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_NUM_TIMEOUTS + (LWIP_IPV6 * (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD)))
|
||||
|
||||
#endif
|
||||
/**
|
||||
* MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active timeouts.
|
||||
* The default number of timeouts is calculated here for all enabled modules.
|
||||
|
||||
@@ -98,5 +98,7 @@
|
||||
#define ESP_PPP 1
|
||||
#define ESP_LWIP_IGMP_TIMERS_ONDEMAND 1
|
||||
#define ESP_LWIP_MLD6_TIMERS_ONDEMAND 1
|
||||
#define ESP_GRATUITOUS_ARP 1
|
||||
|
||||
|
||||
#endif /* LWIP_HDR_LWIPOPTS_H */
|
||||
|
||||
Reference in New Issue
Block a user