Internalize another function; use the supplied max_response_time instead of dividing it by 2

This commit is contained in:
goldsimon 2010-02-08 19:50:49 +00:00
parent 630f575017
commit ececc3ca45
2 changed files with 8 additions and 8 deletions

View File

@ -135,6 +135,7 @@ PACK_STRUCT_END
#endif #endif
static struct igmp_group *igmp_lookup_group(struct netif *ifp, ip_addr_t *addr);
static err_t igmp_remove_group(struct igmp_group *group); static err_t igmp_remove_group(struct igmp_group *group);
static void igmp_timeout( struct igmp_group *group); static void igmp_timeout( struct igmp_group *group);
static void igmp_start_timer(struct igmp_group *group, u8_t max_time); static void igmp_start_timer(struct igmp_group *group, u8_t max_time);
@ -698,7 +699,11 @@ igmp_timeout(struct igmp_group *group)
static void static void
igmp_start_timer(struct igmp_group *group, u8_t max_time) igmp_start_timer(struct igmp_group *group, u8_t max_time)
{ {
/* ensure the value is > 0 */ /* ensure the input value is > 0 */
if (max_time == 0) {
max_time = 1;
}
/* ensure the random value is > 0 */
group->timer = (LWIP_RAND() % (max_time - 1)) + 1; group->timer = (LWIP_RAND() % (max_time - 1)) + 1;
} }
@ -722,14 +727,10 @@ igmp_stop_timer(struct igmp_group *group)
static void static void
igmp_delaying_member(struct igmp_group *group, u8_t maxresp) igmp_delaying_member(struct igmp_group *group, u8_t maxresp)
{ {
u8_t maxresphalf = maxresp / 2;
if (maxresphalf == 0) {
maxresphalf = 1;
}
if ((group->group_state == IGMP_GROUP_IDLE_MEMBER) || if ((group->group_state == IGMP_GROUP_IDLE_MEMBER) ||
((group->group_state == IGMP_GROUP_DELAYING_MEMBER) && ((group->group_state == IGMP_GROUP_DELAYING_MEMBER) &&
((group->timer == 0) || (maxresphalf < group->timer)))) { ((group->timer == 0) || (maxresp < group->timer)))) {
igmp_start_timer(group, maxresphalf); igmp_start_timer(group, maxresp);
group->group_state = IGMP_GROUP_DELAYING_MEMBER; group->group_state = IGMP_GROUP_DELAYING_MEMBER;
} }
} }

View File

@ -92,7 +92,6 @@ err_t igmp_start(struct netif *netif);
err_t igmp_stop(struct netif *netif); err_t igmp_stop(struct netif *netif);
void igmp_report_groups(struct netif *netif); void igmp_report_groups(struct netif *netif);
struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr); struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr);
struct igmp_group *igmp_lookup_group(struct netif *ifp, ip_addr_t *addr);
void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest); void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest);
err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr);
err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr);