--- C:/Dev/OpenSourceProjects/LwIP/lwip/src/core/ipv4/igmp.c Thu Feb 04 19:01:46 2010 +++ C:/Program Files/Analog Devices/VisualDSP 5.0/Blackfin/lib/src/lwip/src/core/ipv4/igmp.c Thu Feb 04 19:17:22 2010 @@ -159,7 +159,7 @@ LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: igmp_mac_filter(ADD ")); ip_addr_debug_print(IGMP_DEBUG, &allsystems); LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif)); - netif->igmp_mac_filter( netif, &allsystems, IGMP_ADD_MAC_FILTER); + netif->igmp_mac_filter(netif, &allsystems, IGMP_ADD_MAC_FILTER); } return ERR_OK; @@ -218,7 +218,7 @@ * @param netif network interface on which report IGMP memberships */ void -igmp_report_groups( struct netif *netif) +igmp_report_groups(struct netif *netif) { struct igmp_group *group = igmp_group_list; @@ -226,7 +226,7 @@ while (group != NULL) { if (group->netif == netif) { - igmp_delaying_member( group, IGMP_JOIN_DELAYING_MEMBER_TMR); + igmp_delaying_member(group, IGMP_JOIN_DELAYING_MEMBER_TMR); } group = group->next; } @@ -283,7 +283,7 @@ if (group != NULL) { group->netif = ifp; ip_addr_set(&(group->group_address), addr); - group->timer = 0; /* Not running */ + group->timer = -1; /* Not running */ group->group_state = IGMP_GROUP_NON_MEMBER; group->last_reporter_flag = 0; group->use = 0; @@ -347,6 +347,8 @@ struct igmp_group* group; struct igmp_group* groupref; + IGMP_STATS_INC(igmp.recv); + /* Note that the length CAN be greater than 8 but only 8 are used - All are included in the checksum */ iphdr = p->payload; if (pbuf_header(p, -(s16_t)(IPH_HL(iphdr) * 4)) || (p->len < IGMP_MINLEN)) { @@ -372,11 +374,12 @@ } /* Packet is ok so find an existing group */ - group = igmp_lookfor_group(inp, dest); /* use the incoming IP address! */ + group = igmp_lookfor_group(inp, dest); /* use the destination IP address of incoming packet */ /* If group can be found or create... */ if (!group) { pbuf_free(p); + IGMP_STATS_INC(igmp.drop); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP frame not for us\n")); return; } @@ -390,26 +393,28 @@ LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: General IGMP_MEMB_QUERY on \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp))); if (igmp->igmp_maxresp == 0) { - IGMP_STATS_INC(igmp.v1_rxed); + IGMP_STATS_INC(igmp.rx_v1); LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: got an all hosts query with time== 0 - this is V1 and not implemented - treat as v2\n")); igmp->igmp_maxresp = IGMP_V1_DELAYING_MEMBER_TMR; } + else { + IGMP_STATS_INC(igmp.rx_general); + } - IGMP_STATS_INC(igmp.group_query_rxed); groupref = igmp_group_list; while (groupref) { /* Do not send messages on the all systems group address! */ if ((groupref->netif == inp) && (!(ip_addr_cmp(&(groupref->group_address), &allsystems)))) { - igmp_delaying_member( groupref, igmp->igmp_maxresp); + igmp_delaying_member(groupref, igmp->igmp_maxresp); } groupref = groupref->next; } } else { /* IGMP_MEMB_QUERY to a specific group ? */ - if (!ip_addr_isany(&group->group_address) != 0) { + if (!ip_addr_isany(&igmp->igmp_group_address)) { LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP_MEMB_QUERY to a specific group ")); - ip_addr_debug_print(IGMP_DEBUG, &group->group_address); - if (ip_addr_cmp (dest, &allsystems)) { + ip_addr_debug_print(IGMP_DEBUG, &igmp->igmp_group_address.addr); + if (ip_addr_cmp(dest, &allsystems)) { LWIP_DEBUGF(IGMP_DEBUG, (" using \"ALL SYSTEMS\" address (224.0.0.1) [igmp_maxresp=%i]\n", (int)(igmp->igmp_maxresp))); /* we first need to re-lookfor the group since we used dest last time */ group = igmp_lookfor_group(inp, &igmp->igmp_group_address); @@ -418,20 +423,25 @@ } if (group != NULL) { - IGMP_STATS_INC(igmp.unicast_query); - igmp_delaying_member( group, igmp->igmp_maxresp); + IGMP_STATS_INC(igmp.rx_group); + igmp_delaying_member(group, igmp->igmp_maxresp); + } + else { + IGMP_STATS_INC(igmp.drop); } } + else { + IGMP_STATS_INC(igmp.proterr); + } } break; } case IGMP_V2_MEMB_REPORT: { LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: IGMP_V2_MEMB_REPORT\n")); - - IGMP_STATS_INC(igmp.report_rxed); + IGMP_STATS_INC(igmp.rx_report); if (group->group_state == IGMP_GROUP_DELAYING_MEMBER) { /* This is on a specific group we have already looked up */ - group->timer = 0; /* stopped */ + group->timer = -1; /* stopped */ group->group_state = IGMP_GROUP_IDLE_MEMBER; group->last_reporter_flag = 0; } @@ -440,6 +450,7 @@ default: { LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: unexpected msg %d in state %d on group %p on if %p\n", igmp->igmp_msgtype, group->group_state, &group, group->netif)); + IGMP_STATS_INC(igmp.proterr); break; } } @@ -492,7 +503,7 @@ netif->igmp_mac_filter(netif, groupaddr, IGMP_ADD_MAC_FILTER); } - IGMP_STATS_INC(igmp.join_sent); + IGMP_STATS_INC(igmp.tx_join); igmp_send(group, IGMP_V2_MEMB_REPORT); igmp_start_timer(group, IGMP_JOIN_DELAYING_MEMBER_TMR); @@ -555,7 +566,7 @@ /* If we are the last reporter for this group */ if (group->last_reporter_flag) { LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: sending leaving group\n")); - IGMP_STATS_INC(igmp.leave_sent); + IGMP_STATS_INC(igmp.tx_leave); igmp_send(group, IGMP_LEAVE_GROUP); } @@ -601,9 +612,8 @@ struct igmp_group *group = igmp_group_list; while (group != NULL) { - if (group->timer != 0) { - group->timer -= 1; - if (group->timer == 0) { + if (group->timer >= 0) { + if (group->timer-- == 0) { igmp_timeout(group); } } @@ -626,6 +636,7 @@ ip_addr_debug_print(IGMP_DEBUG, &(group->group_address)); LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", group->netif)); + IGMP_STATS_INC(igmp.tx_report); igmp_send(group, IGMP_V2_MEMB_REPORT); } } @@ -651,7 +662,7 @@ void igmp_stop_timer(struct igmp_group *group) { - group->timer = 0; + group->timer = -1; } /** @@ -661,10 +672,10 @@ * @param maxresp query delay */ void -igmp_delaying_member( struct igmp_group *group, u8_t maxresp) +igmp_delaying_member(struct igmp_group *group, u8_t maxresp) { - if ((group->group_state == IGMP_GROUP_IDLE_MEMBER) || - ((group->group_state == IGMP_GROUP_DELAYING_MEMBER) && (maxresp > group->timer))) { + if (group->group_state == IGMP_GROUP_IDLE_MEMBER || + (group->group_state == IGMP_GROUP_DELAYING_MEMBER && (group->timer<0 || maxresptimer)) ) { igmp_start_timer(group, (maxresp)/2); group->group_state = IGMP_GROUP_DELAYING_MEMBER; } @@ -690,14 +701,14 @@ * returns errors returned by netif->output */ err_t -igmp_ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, - u8_t ttl, u8_t proto, struct netif *netif) +igmp_ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, struct netif *netif) { + IGMP_STATS_INC(igmp.xmit); /* This is the "router alert" option */ u16_t ra[2]; - ra[0] = htons (ROUTER_ALERT); + ra[0] = htons(ROUTER_ALERT); ra[1] = 0x0000; /* Router shall examine packet */ - return ip_output_if_opt(p, src, dest, ttl, 0, proto, netif, ra, ROUTER_ALERTLEN); + return ip_output_if_opt(p, src, dest, IGMP_TTL, 0, IP_PROTO_IGMP, netif, ra, ROUTER_ALERTLEN); } /** @@ -725,7 +736,6 @@ if (type == IGMP_V2_MEMB_REPORT) { dest = &(group->group_address); - IGMP_STATS_INC(igmp.report_sent); ip_addr_set(&(igmp->igmp_group_address), &(group->group_address)); group->last_reporter_flag = 1; /* Remember we were the last to report */ } else { @@ -739,14 +749,15 @@ igmp->igmp_msgtype = type; igmp->igmp_maxresp = 0; igmp->igmp_checksum = 0; - igmp->igmp_checksum = inet_chksum( igmp, IGMP_MINLEN); + igmp->igmp_checksum = inet_chksum(igmp, IGMP_MINLEN); - igmp_ip_output_if(p, &src, dest, IGMP_TTL, IP_PROTO_IGMP, group->netif); + igmp_ip_output_if(p, &src, dest, group->netif); } pbuf_free(p); } else { LWIP_DEBUGF(IGMP_DEBUG, ("igmp_send: not enough memory for igmp_send\n")); + IGMP_STATS_INC(igmp.memerr); } }