igmp.h, igmp.c, tcpip.c, init.c, netif.c: change igmp_init and add igmp_start. igmp_start is call inside netif_add. Now, igmp initialization is in the same spirit than the others modules. Modify some IGMP debug traces.

This commit is contained in:
fbernon 2007-08-29 21:12:32 +00:00
parent da7b5135de
commit cd208314e0
6 changed files with 71 additions and 31 deletions

View File

@ -19,6 +19,11 @@ HISTORY
++ New features:
2007-08-29 Frédéric Bernon
* igmp.h, igmp.c, tcpip.c, init.c, netif.c: change igmp_init and add igmp_start.
igmp_start is call inside netif_add. Now, igmp initialization is in the same
spirit than the others modules. Modify some IGMP debug traces.
2007-08-29 Frédéric Bernon
* Add init.h, init.c, Change opt.h, tcpip.c: Task #7213 "Add a lwip_init function"
Add lwip_init function to regroup all modules initializations, and to provide

View File

@ -292,16 +292,14 @@ tcpip_thread(void *arg)
#if LWIP_AUTOIP
sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL);
#endif /* LWIP_AUTOIP */
#if LWIP_IGMP
sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL);
#endif /* LWIP_IGMP */
if (tcpip_init_done != NULL) {
tcpip_init_done(tcpip_init_done_arg);
}
#if LWIP_IGMP
igmp_init();
sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL);
#endif /* LWIP_IGMP */
LOCK_TCPIP_CORE();
while (1) { /* MAIN Loop */
sys_mbox_fetch(mbox, (void *)&msg);

View File

@ -50,6 +50,7 @@
#include "lwip/raw.h"
#include "lwip/udp.h"
#include "lwip/tcp.h"
#include "lwip/igmp.h"
#include "lwip/autoip.h"
void
@ -63,7 +64,7 @@ lwip_init(void)
memp_init();
pbuf_init();
netif_init();
#if LWIP_SOCKET /** @todo Add this option in opt.h, in a first time, add it in lwipopts.h */
#if LWIP_SOCKET
lwip_socket_init();
#endif /* LWIP_SOCKET */
ip_init();
@ -82,4 +83,7 @@ lwip_init(void)
#if LWIP_AUTOIP
autoip_init();
#endif /* LWIP_AUTOIP */
#if LWIP_IGMP
igmp_init();
#endif /* LWIP_IGMP */
}

View File

@ -108,39 +108,45 @@ static struct ip_addr allsystems;
static struct ip_addr allrouters;
/**
* Initialize this module
*
* Only network interfaces registered when this function is called
* are igmp-enabled.
*
* This will enable igmp on all interface. In the current implementation it
* is not possible to have igmp on one interface but not the other.
* Initialize the IGMP module
*/
void
igmp_init(void)
{
struct igmp_group* group;
struct netif* netif;
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_init: initializing\n"));
IP4_ADDR(&allsystems, 224, 0, 0, 1);
IP4_ADDR(&allrouters, 224, 0, 0, 2);
igmp_group_list = NULL;
}
for (netif = netif_list; netif != NULL; netif = netif->next) {
group = igmp_lookup_group(netif, &allsystems);
if (group != NULL) {
group->group_state = IDLE_MEMBER;
/**
* Start IGMP processing on interface
*
* @param netif network interface on which start IGMP processing
*/
err_t
igmp_start(struct netif *netif)
{
struct igmp_group* group;
/* Allow the igmp messages at the MAC level */
if (netif->igmp_mac_filter != NULL) {
netif->igmp_mac_filter(netif, &allsystems, IGMP_ADD_MAC_FILTER);
}
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: starting IGMP processing on if %x\n", (int) netif));
group = igmp_lookup_group(netif, &allsystems);
if (group != NULL) {
group->group_state = IDLE_MEMBER;
/* Allow the igmp messages at the MAC level */
if (netif->igmp_mac_filter != NULL) {
netif->igmp_mac_filter( netif, &allsystems, IGMP_ADD_MAC_FILTER);
}
return ERR_OK;
}
return ERR_MEM;
}
/**
@ -200,10 +206,20 @@ igmp_lookup_group(struct netif *ifp, struct ip_addr *addr)
group->next = igmp_group_list;
igmp_group_list = group;
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_lookup_group: allocated a new group with address %x on if %x \n", (int) addr, (int) ifp));
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_lookup_group: allocated a new group with address %"U16_F".%"U16_F".%"U16_F".%"U16_F" on if %x \n",
(u16_t)(ntohl(addr->addr) >> 24 & 0xff),
(u16_t)(ntohl(addr->addr) >> 16 & 0xff),
(u16_t)(ntohl(addr->addr) >> 8 & 0xff),
(u16_t)(ntohl(addr->addr) & 0xff),
(int) ifp));
} else {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_lookup_group: impossible to allocated a new group with address %x on if %x \n", (int) addr, (int) ifp));
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_lookup_group: impossible to allocated a new group with address %"U16_F".%"U16_F".%"U16_F".%"U16_F" on if %x \n",
(u16_t)(ntohl(addr->addr) >> 24 & 0xff),
(u16_t)(ntohl(addr->addr) >> 16 & 0xff),
(u16_t)(ntohl(addr->addr) >> 8 & 0xff),
(u16_t)(ntohl(addr->addr) & 0xff),
(int) ifp));
}
return group;
@ -233,7 +249,12 @@ igmp_input(struct pbuf *p, struct netif *inp, struct ip_addr *dest)
return;
}
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: message to address %l \n", (long)dest->addr));
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: message to address %"U16_F".%"U16_F".%"U16_F".%"U16_F" on if %x \n",
(u16_t)(ntohl(dest->addr) >> 24 & 0xff),
(u16_t)(ntohl(dest->addr) >> 16 & 0xff),
(u16_t)(ntohl(dest->addr) >> 8 & 0xff),
(u16_t)(ntohl(dest->addr) & 0xff),
(int) inp));
/* Now calculate and check the checksum */
igmp = (struct igmp_msg *)p->payload;
@ -457,9 +478,13 @@ void
igmp_timeout(struct igmp_group *group)
{
/* If the state is DELAYING_MEMBER then we send a report for this group */
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_timeout: got a timeout\n"));
if (group->group_state == DELAYING_MEMBER) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_timeout: report membership for group with address %"U16_F".%"U16_F".%"U16_F".%"U16_F" on if %x \n",
(u16_t)(ntohl(group->group_address.addr) >> 24 & 0xff),
(u16_t)(ntohl(group->group_address.addr) >> 16 & 0xff),
(u16_t)(ntohl(group->group_address.addr) >> 8 & 0xff),
(u16_t)(ntohl(group->group_address.addr) & 0xff),
(int) group->interface));
igmp_send(group, IGMP_V2_MEMB_REPORT);
}
}

View File

@ -43,6 +43,7 @@
#include "lwip/netif.h"
#include "lwip/tcp.h"
#include "lwip/snmp.h"
#include "lwip/igmp.h"
#if LWIP_ARP
#include "netif/etharp.h"
@ -135,6 +136,11 @@ netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
netif_list = netif;
snmp_inc_iflist();
#if LWIP_IGMP
/* start IGMP processing */
igmp_start( netif);
#endif /* LWIP_IGMP */
LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ",
netif->name[0], netif->name[1]));
ip_addr_debug_print(NETIF_DEBUG, ipaddr);

View File

@ -107,6 +107,8 @@ struct igmp_group {
/* Prototypes */
void igmp_init(void);
err_t igmp_start( struct netif *netif);
struct igmp_group *igmp_lookfor_group(struct netif *ifp, struct ip_addr *addr);
struct igmp_group *igmp_lookup_group(struct netif *ifp, struct ip_addr *addr);