mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-08-21 01:10:03 +00:00
igmp/mld6: Add on-demand timers config
2.1.3-esp: 7d3b07fd igmp/mld6: Add on-demand timers config
Signed-off-by: Sachin Parekh <[email protected]>
Co-Authored-By: Axel Lin <[email protected]> (espressif/esp-lwip@b1eec77b)
This commit is contained in:
committed by
David Cermak
parent
52b30c9a7a
commit
112f1255c2
@@ -93,6 +93,7 @@ Steve Reynolds
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/prot/igmp.h"
|
||||
#include "lwip/timeouts.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -107,6 +108,11 @@ static void igmp_send(struct netif *netif, struct igmp_group *group, u8_t type
|
||||
static ip4_addr_t allsystems;
|
||||
static ip4_addr_t allrouters;
|
||||
|
||||
#if ESP_LWIP_IGMP_TIMERS_ONDEMAND
|
||||
#include <stdbool.h>
|
||||
static bool is_tmr_start = false;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialize the IGMP module
|
||||
*/
|
||||
@@ -633,6 +639,17 @@ igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr)
|
||||
}
|
||||
}
|
||||
|
||||
#if ESP_LWIP_IGMP_TIMERS_ONDEMAND
|
||||
/**
|
||||
* Wrapper function with matching prototype which calls the actual callback
|
||||
*/
|
||||
static void igmp_timeout_cb(void *arg)
|
||||
{
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
|
||||
igmp_tmr();
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* The igmp timer function (both for NO_SYS=1 and =0)
|
||||
* Should be called every IGMP_TMR_INTERVAL milliseconds (100 ms is default).
|
||||
@@ -641,6 +658,9 @@ void
|
||||
igmp_tmr(void)
|
||||
{
|
||||
struct netif *netif;
|
||||
#if ESP_LWIP_IGMP_TIMERS_ONDEMAND
|
||||
bool tmr_restart = false;
|
||||
#endif
|
||||
|
||||
NETIF_FOREACH(netif) {
|
||||
struct igmp_group *group = netif_igmp_data(netif);
|
||||
@@ -651,10 +671,23 @@ igmp_tmr(void)
|
||||
if (group->timer == 0) {
|
||||
igmp_timeout(netif, group);
|
||||
}
|
||||
#if ESP_LWIP_IGMP_TIMERS_ONDEMAND
|
||||
else {
|
||||
tmr_restart = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
group = group->next;
|
||||
}
|
||||
}
|
||||
#if ESP_LWIP_IGMP_TIMERS_ONDEMAND
|
||||
if (tmr_restart) {
|
||||
sys_timeout(IGMP_TMR_INTERVAL, igmp_timeout_cb, NULL);
|
||||
} else {
|
||||
sys_untimeout(igmp_timeout_cb, NULL);
|
||||
is_tmr_start = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -701,6 +734,12 @@ igmp_start_timer(struct igmp_group *group, u8_t max_time)
|
||||
if (group->timer == 0) {
|
||||
group->timer = 1;
|
||||
}
|
||||
#if ESP_LWIP_IGMP_TIMERS_ONDEMAND
|
||||
if (!is_tmr_start) {
|
||||
sys_timeout(IGMP_TMR_INTERVAL, igmp_timeout_cb, NULL);
|
||||
is_tmr_start = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/timeouts.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -86,6 +87,10 @@ static err_t mld6_remove_group(struct netif *netif, struct mld_group *group);
|
||||
static void mld6_delayed_report(struct mld_group *group, u16_t maxresp);
|
||||
static void mld6_send(struct netif *netif, struct mld_group *group, u8_t type);
|
||||
|
||||
#if ESP_LWIP_MLD6_TIMERS_ONDEMAND
|
||||
#include <stdbool.h>
|
||||
static bool is_tmr_start = false;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Stop MLD processing on interface
|
||||
@@ -488,6 +493,17 @@ mld6_leavegroup_netif(struct netif *netif, const ip6_addr_t *groupaddr)
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
#if ESP_LWIP_MLD6_TIMERS_ONDEMAND
|
||||
/**
|
||||
* Wrapper function with matching prototype which calls the actual callback
|
||||
*/
|
||||
static void mld6_timeout_cb(void *arg)
|
||||
{
|
||||
LWIP_UNUSED_ARG(arg);
|
||||
|
||||
mld6_tmr();
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Periodic timer for mld processing. Must be called every
|
||||
@@ -499,6 +515,9 @@ void
|
||||
mld6_tmr(void)
|
||||
{
|
||||
struct netif *netif;
|
||||
#if ESP_LWIP_MLD6_TIMERS_ONDEMAND
|
||||
bool tmr_restart = false;
|
||||
#endif
|
||||
|
||||
NETIF_FOREACH(netif) {
|
||||
struct mld_group *group = netif_mld6_data(netif);
|
||||
@@ -514,10 +533,23 @@ mld6_tmr(void)
|
||||
group->group_state = MLD6_GROUP_IDLE_MEMBER;
|
||||
}
|
||||
}
|
||||
#if ESP_LWIP_MLD6_TIMERS_ONDEMAND
|
||||
else {
|
||||
tmr_restart = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
group = group->next;
|
||||
}
|
||||
}
|
||||
#if ESP_LWIP_MLD6_TIMERS_ONDEMAND
|
||||
if (tmr_restart) {
|
||||
sys_timeout(MLD6_TMR_INTERVAL, mld6_timeout_cb, NULL);
|
||||
} else {
|
||||
sys_untimeout(mld6_timeout_cb, NULL);
|
||||
is_tmr_start = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -550,6 +582,12 @@ mld6_delayed_report(struct mld_group *group, u16_t maxresp_in)
|
||||
((group->timer == 0) || (maxresp < group->timer)))) {
|
||||
group->timer = maxresp;
|
||||
group->group_state = MLD6_GROUP_DELAYING_MEMBER;
|
||||
#if ESP_LWIP_MLD6_TIMERS_ONDEMAND
|
||||
if (!is_tmr_start) {
|
||||
sys_timeout(MLD6_TMR_INTERVAL, mld6_timeout_cb, NULL);
|
||||
is_tmr_start = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -94,7 +94,7 @@ const struct lwip_cyclic_timer lwip_cyclic_timers[] = {
|
||||
#if LWIP_ACD
|
||||
{ACD_TMR_INTERVAL, HANDLER(acd_tmr)},
|
||||
#endif /* LWIP_ACD */
|
||||
#if LWIP_IGMP
|
||||
#if LWIP_IGMP && !ESP_LWIP_IGMP_TIMERS_ONDEMAND
|
||||
{IGMP_TMR_INTERVAL, HANDLER(igmp_tmr)},
|
||||
#endif /* LWIP_IGMP */
|
||||
#endif /* LWIP_IPV4 */
|
||||
@@ -106,7 +106,7 @@ const struct lwip_cyclic_timer lwip_cyclic_timers[] = {
|
||||
#if LWIP_IPV6_REASS
|
||||
{IP6_REASS_TMR_INTERVAL, HANDLER(ip6_reass_tmr)},
|
||||
#endif /* LWIP_IPV6_REASS */
|
||||
#if LWIP_IPV6_MLD
|
||||
#if LWIP_IPV6_MLD && !ESP_LWIP_MLD6_TIMERS_ONDEMAND
|
||||
{MLD6_TMR_INTERVAL, HANDLER(mld6_tmr)},
|
||||
#endif /* LWIP_IPV6_MLD */
|
||||
#if LWIP_IPV6_DHCP6
|
||||
|
||||
@@ -498,7 +498,7 @@
|
||||
* The number of sys timeouts used by the core stack (not apps)
|
||||
* The default number of timeouts is calculated here for all enabled modules.
|
||||
*/
|
||||
#define LWIP_NUM_SYS_TIMEOUT_INTERNAL (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_ACD + LWIP_IGMP + LWIP_DNS + PPP_NUM_TIMEOUTS + (LWIP_IPV6 * (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD + LWIP_IPV6_DHCP6)))
|
||||
#define LWIP_NUM_SYS_TIMEOUT_INTERNAL (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_ACD + (ESP_LWIP_IGMP_TIMERS_ONDEMAND ? 0 : LWIP_IGMP) + LWIP_DNS + PPP_NUM_TIMEOUTS + (LWIP_IPV6 * (1 + LWIP_IPV6_REASS + (ESP_LWIP_MLD6_TIMERS_ONDEMAND ? 0 : LWIP_IPV6_MLD) + LWIP_IPV6_DHCP6)))
|
||||
|
||||
/**
|
||||
* MEMP_NUM_SYS_TIMEOUT: the number of simultaneously active timeouts.
|
||||
|
||||
@@ -159,10 +159,14 @@ u32_t esp_random(void);
|
||||
#define UDP_DEBUG LWIP_DBG_ON
|
||||
#define TCP_DEBUG LWIP_DBG_ON
|
||||
#endif /* ESP_TEST_DEBUG */
|
||||
#define ESP_LWIP_IGMP_TIMERS_ONDEMAND 1
|
||||
#define ESP_LWIP_MLD6_TIMERS_ONDEMAND 1
|
||||
|
||||
#else
|
||||
#define ESP_LWIP 0
|
||||
#define ESP_DHCP 0
|
||||
#define ESP_DHCP_DISABLE_VENDOR_CLASS_IDENTIFIER 1
|
||||
#define ESP_LWIP 0
|
||||
#define ESP_LWIP_IGMP_TIMERS_ONDEMAND 0
|
||||
#define ESP_LWIP_MLD6_TIMERS_ONDEMAND 0
|
||||
|
||||
#endif /* ESP_LWIP */
|
||||
|
||||
#endif /* LWIP_HDR_LWIPOPTS_H */
|
||||
|
||||
Reference in New Issue
Block a user