More cosmetic clean-up

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2800 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2010-07-14 17:17:39 +00:00
parent 0ddd63d169
commit 1fe85344d7
7 changed files with 1315 additions and 1315 deletions
+121 -121
View File
@@ -1,121 +1,121 @@
/****************************************************************************
* net/uip/uip_igmpinit.c
* IGMP initialization logic
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
* lwIP TCP/IP stack by Steve Reynolds:
*
* Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <debug.h>
#include <net/uip/uip.h>
#include <net/uip/uip-igmp.h>
#include "uip_internal.h"
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_NET_IPv6
# error "IGMP for IPv6 not supported"
#endif
/****************************************************************************
* Public Data
****************************************************************************/
uip_ipaddr_t g_allsystems;
uip_ipaddr_t g_allrouters;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: uip_igmpinit
*
* Description:
* Perform one-time IGMP initialization.
*
****************************************************************************/
void uip_igmpinit(void)
{
nvdbg("IGMP initializing\n");
uip_ipaddr(g_allrouters, 224, 0, 0, 2);
uip_ipaddr(g_allsystems, 224, 0, 0, 1);
/* Initialize the group allocation logic */
uip_grpinit();
}
/****************************************************************************
* Name: uip_igmpdevinit
*
* Description:
* Called when a new network device is registered to configure that device
* for IGMP support.
*
****************************************************************************/
void uip_igmpdevinit(struct uip_driver_s *dev)
{
struct igmp_group_s *group;
nvdbg("IGMP initializing dev %p\n", dev);
DEBUGASSERT(dev->grplist.head == NULL);
/* Add the all systems address to the group */
group = uip_grpalloc(dev, &g_allsystems);
/* Allow the IGMP messages at the MAC level */
uip_addmcastmac(dev, &g_allrouters);
uip_addmcastmac(dev, &g_allsystems);
}
#endif /* CONFIG_NET_IGMP */
/****************************************************************************
* net/uip/uip_igmpinit.c
* IGMP initialization logic
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
* lwIP TCP/IP stack by Steve Reynolds:
*
* Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <debug.h>
#include <net/uip/uip.h>
#include <net/uip/uip-igmp.h>
#include "uip_internal.h"
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_NET_IPv6
# error "IGMP for IPv6 not supported"
#endif
/****************************************************************************
* Public Data
****************************************************************************/
uip_ipaddr_t g_allsystems;
uip_ipaddr_t g_allrouters;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: uip_igmpinit
*
* Description:
* Perform one-time IGMP initialization.
*
****************************************************************************/
void uip_igmpinit(void)
{
nvdbg("IGMP initializing\n");
uip_ipaddr(g_allrouters, 224, 0, 0, 2);
uip_ipaddr(g_allsystems, 224, 0, 0, 1);
/* Initialize the group allocation logic */
uip_grpinit();
}
/****************************************************************************
* Name: uip_igmpdevinit
*
* Description:
* Called when a new network device is registered to configure that device
* for IGMP support.
*
****************************************************************************/
void uip_igmpdevinit(struct uip_driver_s *dev)
{
struct igmp_group_s *group;
nvdbg("IGMP initializing dev %p\n", dev);
DEBUGASSERT(dev->grplist.head == NULL);
/* Add the all systems address to the group */
group = uip_grpalloc(dev, &g_allsystems);
/* Allow the IGMP messages at the MAC level */
uip_addmcastmac(dev, &g_allrouters);
uip_addmcastmac(dev, &g_allsystems);
}
#endif /* CONFIG_NET_IGMP */
+280 -280
View File
File diff suppressed because it is too large Load Diff
+160 -160
View File
@@ -1,160 +1,160 @@
/****************************************************************************
* net/uip/uip_igmpjoin.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
* lwIP TCP/IP stack by Steve Reynolds:
*
* Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <debug.h>
#include <net/uip/uipopt.h>
#include <net/uip/uip.h>
#include <net/uip/uip-igmp.h>
#include "uip_internal.h"
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: igmp_joingroup
*
* Description:
* Add the specified group address to the group.
*
* RFC 2236, 3. Protocol Description:
*
* "When a host joins a multicast group, it should immediately transmit
* an unsolicited Version 2 Membership Report for that group, in case it
* is the first member of that group on the network. To cover the
* possibility of the initial Membership Report being lost or damaged,
* it is recommended that it be repeated once or twice after short
* delays [Unsolicited Report Interval]. (A simple way to accomplish
* this is to send the initial Version 2 Membership Report and then act
* as if a Group-Specific Query was received for that group, and set a
* timer appropriately)."
* ________________
* | |
* | |
* | |
* | |
* +--------->| Non-Member |<---------+
* | | | |
* | | | |
* | | | |
* | |________________| |
* | | |
* | leave group | join group | leave group
* | (stop timer, |(send report, | (send leave
* | send leave if | set flag, | if flag set)
* | flag set) | start timer) |
* ________|________ | ________|________
* | |<---------+ | |
* | | | |
* | |<-------------------| |
* | | query received | |
* | Delaying Member | (start timer) | Idle Member |
* +---->| |------------------->| |
* | | | report received | |
* | | | (stop timer, | |
* | | | clear flag) | |
* | |_________________|------------------->|_________________|
* | query received | timer expired
* | (reset timer if | (send report,
* | Max Resp Time | set flag)
* | < current timer) |
* +-------------------+
*
* Assumptions:
* This function cannot be called from interrupt handling logic!
*
****************************************************************************/
int igmp_joingroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
{
struct igmp_group_s *group;
DEBUGASSERT(dev && grpaddr);
/* Check if a this address is already in the group */
group = uip_grpfind(dev, &grpaddr->s_addr);
if (!group)
{
/* No... allocate a new entry */
nvdbg("Join to new group: %08x\n", grpaddr->s_addr);
group = uip_grpalloc(dev, &grpaddr->s_addr);
IGMP_STATINCR(uip_stat.igmp.joins);
/* Send the Membership Report */
IGMP_STATINCR(uip_stat.igmp.report_sched);
uip_igmpwaitmsg(group, IGMPv2_MEMBERSHIP_REPORT);
/* And start the timer at 10*100 msec */
uip_igmpstarttimer(group, 10);
/* Add the group (MAC) address to the ether drivers MAC filter list */
uip_addmcastmac(dev, (FAR uip_ipaddr_t *)&grpaddr->s_addr);
return OK;
}
/* Return EEXIST if the address is already a member of the group */
return -EEXIST;
}
#endif /* CONFIG_NET_IGMP */
/****************************************************************************
* net/uip/uip_igmpjoin.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
* lwIP TCP/IP stack by Steve Reynolds:
*
* Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <debug.h>
#include <net/uip/uipopt.h>
#include <net/uip/uip.h>
#include <net/uip/uip-igmp.h>
#include "uip_internal.h"
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: igmp_joingroup
*
* Description:
* Add the specified group address to the group.
*
* RFC 2236, 3. Protocol Description:
*
* "When a host joins a multicast group, it should immediately transmit
* an unsolicited Version 2 Membership Report for that group, in case it
* is the first member of that group on the network. To cover the
* possibility of the initial Membership Report being lost or damaged,
* it is recommended that it be repeated once or twice after short
* delays [Unsolicited Report Interval]. (A simple way to accomplish
* this is to send the initial Version 2 Membership Report and then act
* as if a Group-Specific Query was received for that group, and set a
* timer appropriately)."
* ________________
* | |
* | |
* | |
* | |
* +--------->| Non-Member |<---------+
* | | | |
* | | | |
* | | | |
* | |________________| |
* | | |
* | leave group | join group | leave group
* | (stop timer, |(send report, | (send leave
* | send leave if | set flag, | if flag set)
* | flag set) | start timer) |
* ________|________ | ________|________
* | |<---------+ | |
* | | | |
* | |<-------------------| |
* | | query received | |
* | Delaying Member | (start timer) | Idle Member |
* +---->| |------------------->| |
* | | | report received | |
* | | | (stop timer, | |
* | | | clear flag) | |
* | |_________________|------------------->|_________________|
* | query received | timer expired
* | (reset timer if | (send report,
* | Max Resp Time | set flag)
* | < current timer) |
* +-------------------+
*
* Assumptions:
* This function cannot be called from interrupt handling logic!
*
****************************************************************************/
int igmp_joingroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
{
struct igmp_group_s *group;
DEBUGASSERT(dev && grpaddr);
/* Check if a this address is already in the group */
group = uip_grpfind(dev, &grpaddr->s_addr);
if (!group)
{
/* No... allocate a new entry */
nvdbg("Join to new group: %08x\n", grpaddr->s_addr);
group = uip_grpalloc(dev, &grpaddr->s_addr);
IGMP_STATINCR(uip_stat.igmp.joins);
/* Send the Membership Report */
IGMP_STATINCR(uip_stat.igmp.report_sched);
uip_igmpwaitmsg(group, IGMPv2_MEMBERSHIP_REPORT);
/* And start the timer at 10*100 msec */
uip_igmpstarttimer(group, 10);
/* Add the group (MAC) address to the ether drivers MAC filter list */
uip_addmcastmac(dev, (FAR uip_ipaddr_t *)&grpaddr->s_addr);
return OK;
}
/* Return EEXIST if the address is already a member of the group */
return -EEXIST;
}
#endif /* CONFIG_NET_IGMP */
+182 -182
View File
@@ -1,182 +1,182 @@
/****************************************************************************
* net/uip/uip_igmpleave.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
* lwIP TCP/IP stack by Steve Reynolds:
*
* Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <wdog.h>
#include <assert.h>
#include <debug.h>
#include <net/uip/uipopt.h>
#include <net/uip/uip.h>
#include <net/uip/uip-igmp.h>
#include "uip_internal.h"
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: igmp_leavegroup
*
* Description:
* Remove the specified group address to the group.
*
* RFC 2236, 3. Protocol Description:
*
* "When a host leaves a multicast group, if it was the last host to
* reply to a Query with a Membership Report for that group, it SHOULD
* send a Leave Group message to the all-routers multicast group
* (224.0.0.2). If it was not the last host to reply to a Query, it MAY
* send nothing as there must be another member on the subnet. This is
* an optimization to reduce traffic; a host without sufficient storage
* to remember whether or not it was the last host to reply MAY always
* send a Leave Group message when it leaves a group. Routers SHOULD
* accept a Leave Group message addressed to the group being left, in
* order to accommodate implementations of an earlier version of this
* standard. Leave Group messages are addressed to the all-routers
* group because other group members have no need to know that a host
* has left the group, but it does no harm to address the message to the
* group."
*
* ________________
* | |
* | |
* | |
* | |
* +--------->| Non-Member |<---------+
* | | | |
* | | | |
* | | | |
* | |________________| |
* | | |
* | leave group | join group | leave group
* | (stop timer, |(send report, | (send leave
* | send leave if | set flag, | if flag set)
* | flag set) | start timer) |
* ________|________ | ________|________
* | |<---------+ | |
* | | | |
* | |<-------------------| |
* | | query received | |
* | Delaying Member | (start timer) | Idle Member |
* +---->| |------------------->| |
* | | | report received | |
* | | | (stop timer, | |
* | | | clear flag) | |
* | |_________________|------------------->|_________________|
* | query received | timer expired
* | (reset timer if | (send report,
* | Max Resp Time | set flag)
* | < current timer) |
* +-------------------+
*
* Assumptions:
* This function cannot be called from interrupt handling logic!
*
****************************************************************************/
int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
{
struct igmp_group_s *group;
irqstate_t flags;
DEBUGASSERT(dev && grpaddr);
/* Find the entry corresponding to the address leaving the group */
group = uip_grpfind(dev, &grpaddr->s_addr);
ndbg("Leaving group: %p\n", group);
if (group)
{
/* Cancel the timer and discard any queued Membership Reports. Canceling
* the timer will prevent any new Membership Reports from being sent;
* clearing the flags will discard any pending Membership Reports that
* could interfere with the Leave Group.
*/
flags = irqsave();
wd_cancel(group->wdog);
CLR_SCHEDMSG(group->flags);
CLR_WAITMSG(group->flags);
irqrestore(flags);
IGMP_STATINCR(uip_stat.igmp.leaves);
/* Send a leave if the flag is set according to the state diagram */
if (IS_LASTREPORT(group->flags))
{
ndbg("Schedule Leave Group message\n");
IGMP_STATINCR(uip_stat.igmp.leave_sched);
uip_igmpwaitmsg(group, IGMP_LEAVE_GROUP);
}
/* Free the group structure (state is now Non-Member */
uip_grpfree(dev, group);
/* And remove the group address from the ethernet drivers MAC filter set */
uip_removemcastmac(dev, (FAR uip_ipaddr_t *)&grpaddr->s_addr);
return OK;
}
/* Return ENOENT if the address is not a member of the group */
nvdbg("Return -ENOENT\n");
return -ENOENT;
}
#endif /* CONFIG_NET_IGMP */
/****************************************************************************
* net/uip/uip_igmpleave.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
* lwIP TCP/IP stack by Steve Reynolds:
*
* Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <wdog.h>
#include <assert.h>
#include <debug.h>
#include <net/uip/uipopt.h>
#include <net/uip/uip.h>
#include <net/uip/uip-igmp.h>
#include "uip_internal.h"
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: igmp_leavegroup
*
* Description:
* Remove the specified group address to the group.
*
* RFC 2236, 3. Protocol Description:
*
* "When a host leaves a multicast group, if it was the last host to
* reply to a Query with a Membership Report for that group, it SHOULD
* send a Leave Group message to the all-routers multicast group
* (224.0.0.2). If it was not the last host to reply to a Query, it MAY
* send nothing as there must be another member on the subnet. This is
* an optimization to reduce traffic; a host without sufficient storage
* to remember whether or not it was the last host to reply MAY always
* send a Leave Group message when it leaves a group. Routers SHOULD
* accept a Leave Group message addressed to the group being left, in
* order to accommodate implementations of an earlier version of this
* standard. Leave Group messages are addressed to the all-routers
* group because other group members have no need to know that a host
* has left the group, but it does no harm to address the message to the
* group."
*
* ________________
* | |
* | |
* | |
* | |
* +--------->| Non-Member |<---------+
* | | | |
* | | | |
* | | | |
* | |________________| |
* | | |
* | leave group | join group | leave group
* | (stop timer, |(send report, | (send leave
* | send leave if | set flag, | if flag set)
* | flag set) | start timer) |
* ________|________ | ________|________
* | |<---------+ | |
* | | | |
* | |<-------------------| |
* | | query received | |
* | Delaying Member | (start timer) | Idle Member |
* +---->| |------------------->| |
* | | | report received | |
* | | | (stop timer, | |
* | | | clear flag) | |
* | |_________________|------------------->|_________________|
* | query received | timer expired
* | (reset timer if | (send report,
* | Max Resp Time | set flag)
* | < current timer) |
* +-------------------+
*
* Assumptions:
* This function cannot be called from interrupt handling logic!
*
****************************************************************************/
int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
{
struct igmp_group_s *group;
irqstate_t flags;
DEBUGASSERT(dev && grpaddr);
/* Find the entry corresponding to the address leaving the group */
group = uip_grpfind(dev, &grpaddr->s_addr);
ndbg("Leaving group: %p\n", group);
if (group)
{
/* Cancel the timer and discard any queued Membership Reports. Canceling
* the timer will prevent any new Membership Reports from being sent;
* clearing the flags will discard any pending Membership Reports that
* could interfere with the Leave Group.
*/
flags = irqsave();
wd_cancel(group->wdog);
CLR_SCHEDMSG(group->flags);
CLR_WAITMSG(group->flags);
irqrestore(flags);
IGMP_STATINCR(uip_stat.igmp.leaves);
/* Send a leave if the flag is set according to the state diagram */
if (IS_LASTREPORT(group->flags))
{
ndbg("Schedule Leave Group message\n");
IGMP_STATINCR(uip_stat.igmp.leave_sched);
uip_igmpwaitmsg(group, IGMP_LEAVE_GROUP);
}
/* Free the group structure (state is now Non-Member */
uip_grpfree(dev, group);
/* And remove the group address from the ethernet drivers MAC filter set */
uip_removemcastmac(dev, (FAR uip_ipaddr_t *)&grpaddr->s_addr);
return OK;
}
/* Return ENOENT if the address is not a member of the group */
nvdbg("Return -ENOENT\n");
return -ENOENT;
}
#endif /* CONFIG_NET_IGMP */
+139 -139
View File
@@ -1,139 +1,139 @@
/****************************************************************************
* net/uip/uip_igmpmgs.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
* lwIP TCP/IP stack by Steve Reynolds:
*
* Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <debug.h>
#include <net/uip/uipopt.h>
#include <net/uip/uip.h>
#include <net/uip/uip-igmp.h>
#include "uip_internal.h"
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: uip_igmpschedmsg
*
* Description:
* Schedule a message to be send at the next driver polling interval.
*
* Assumptions:
* This function may be called in most any context.
*
****************************************************************************/
void uip_igmpschedmsg(FAR struct igmp_group_s *group, uint8_t msgid)
{
irqstate_t flags = irqsave();
/* The following should be atomic */
flags = irqsave();
DEBUGASSERT(!IS_SCHEDMSG(group->flags));
group->msgid = msgid;
SET_SCHEDMSG(group->flags);
irqrestore(flags);
}
/****************************************************************************
* Name: uip_igmpwaitmsg
*
* Description:
* Schedule a message to be send at the next driver polling interval and
* block, waiting for the message to be sent.
*
* Assumptions:
* This function cannot be called from an interrupt handler (if you try it,
* sem_wait will assert).
*
****************************************************************************/
void uip_igmpwaitmsg(FAR struct igmp_group_s *group, uint8_t msgid)
{
irqstate_t flags;
/* Schedule to send the message */
flags = irqsave();
DEBUGASSERT(!IS_WAITMSG(group->flags));
SET_WAITMSG(group->flags);
uip_igmpschedmsg(group, msgid);
/* Then wait for the message to be sent */
while (IS_SCHEDMSG(group->flags))
{
/* Wait for the semaphore to be posted */
while (sem_wait(&group->sem) != 0)
{
/* The only error that should occur from sem_wait() is if
* the wait is awakened by a signal.
*/
ASSERT(errno == EINTR);
}
}
/* The message has been sent and we are no longer waiting */
CLR_WAITMSG(group->flags);
irqrestore(flags);
}
#endif /* CONFIG_NET_IGMP */
/****************************************************************************
* net/uip/uip_igmpmgs.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
* lwIP TCP/IP stack by Steve Reynolds:
*
* Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <debug.h>
#include <net/uip/uipopt.h>
#include <net/uip/uip.h>
#include <net/uip/uip-igmp.h>
#include "uip_internal.h"
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: uip_igmpschedmsg
*
* Description:
* Schedule a message to be send at the next driver polling interval.
*
* Assumptions:
* This function may be called in most any context.
*
****************************************************************************/
void uip_igmpschedmsg(FAR struct igmp_group_s *group, uint8_t msgid)
{
irqstate_t flags = irqsave();
/* The following should be atomic */
flags = irqsave();
DEBUGASSERT(!IS_SCHEDMSG(group->flags));
group->msgid = msgid;
SET_SCHEDMSG(group->flags);
irqrestore(flags);
}
/****************************************************************************
* Name: uip_igmpwaitmsg
*
* Description:
* Schedule a message to be send at the next driver polling interval and
* block, waiting for the message to be sent.
*
* Assumptions:
* This function cannot be called from an interrupt handler (if you try it,
* sem_wait will assert).
*
****************************************************************************/
void uip_igmpwaitmsg(FAR struct igmp_group_s *group, uint8_t msgid)
{
irqstate_t flags;
/* Schedule to send the message */
flags = irqsave();
DEBUGASSERT(!IS_WAITMSG(group->flags));
SET_WAITMSG(group->flags);
uip_igmpschedmsg(group, msgid);
/* Then wait for the message to be sent */
while (IS_SCHEDMSG(group->flags))
{
/* Wait for the semaphore to be posted */
while (sem_wait(&group->sem) != 0)
{
/* The only error that should occur from sem_wait() is if
* the wait is awakened by a signal.
*/
ASSERT(errno == EINTR);
}
}
/* The message has been sent and we are no longer waiting */
CLR_WAITMSG(group->flags);
irqrestore(flags);
}
#endif /* CONFIG_NET_IGMP */
+176 -176
View File
@@ -1,176 +1,176 @@
/****************************************************************************
* net/uip/uip_igmppoll.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
* lwIP TCP/IP stack by Steve Reynolds:
*
* Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <debug.h>
#include <net/uip/uipopt.h>
#include <net/uip/uip.h>
#include <net/uip/uip-arch.h>
#include "uip_internal.h"
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: uip_schedsend
*
* Description:
* Construct the .
*
* Returned Value:
* Returns a non-zero value if a IGP message is sent.
*
* Assumptions:
* This function is called from the driver polling logic... probably within
* an interrupt handler.
*
****************************************************************************/
static inline void uip_schedsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group)
{
uip_ipaddr_t *dest;
/* Check what kind of messsage we need to send. There are only two
* possibilities:
*/
if (group->msgid == IGMPv2_MEMBERSHIP_REPORT)
{
dest = &group->grpaddr;
nllvdbg("Send IGMPv2_MEMBERSHIP_REPORT, dest=%08x flags=%02x\n",
*dest, group->flags);
IGMP_STATINCR(uip_stat.igmp.report_sched);
SET_LASTREPORT(group->flags); /* Remember we were the last to report */
}
else
{
DEBUGASSERT(group->msgid == IGMP_LEAVE_GROUP);
dest = &g_allrouters;
nllvdbg("Send IGMP_LEAVE_GROUP, dest=%08x flags=%02x\n",
*dest, group->flags);
IGMP_STATINCR(uip_stat.igmp.leave_sched);
}
/* Send the message */
uip_igmpsend(dev, group, dest);
/* Indicate that the message has been sent */
CLR_SCHEDMSG(group->flags);
group->msgid = 0;
/* If there is a thread waiting fore the message to be sent, wake it up */
if (IS_WAITMSG(group->flags))
{
nllvdbg("Awakening waiter\n");
sem_post(&group->sem);
}
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: uip_igmppoll
*
* Description:
* Poll the groups associated with the device to see if any IGMP messages
* are pending transfer.
*
* Returned Value:
* Returns a non-zero value if a IGP message is sent.
*
* Assumptions:
* This function is called from the driver polling logic... probably within
* an interrupt handler.
*
****************************************************************************/
void uip_igmppoll(FAR struct uip_driver_s *dev)
{
FAR struct igmp_group_s *group;
nllvdbg("Entry\n");
/* Setup the poll operation */
dev->d_appdata = &dev->d_buf[UIP_LLH_LEN + UIP_IPIGMPH_LEN];
dev->d_snddata = &dev->d_buf[UIP_LLH_LEN + UIP_IPIGMPH_LEN];
dev->d_len = 0;
dev->d_sndlen = 0;
/* Check each member of the group */
for (group = (FAR struct igmp_group_s *)dev->grplist.head; group; group = group->next)
{
/* Does this member have a pending outgoing message? */
if (IS_SCHEDMSG(group->flags))
{
/* Yes, create the IGMP message in the driver buffer */
uip_schedsend(dev, group);
/* Mark the message as sent and break out */
CLR_SCHEDMSG(group->flags);
break;
}
}
}
#endif /* CONFIG_NET_IGMP */
/****************************************************************************
* net/uip/uip_igmppoll.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
* lwIP TCP/IP stack by Steve Reynolds:
*
* Copyright (c) 2002 CITEL Technologies Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <debug.h>
#include <net/uip/uipopt.h>
#include <net/uip/uip.h>
#include <net/uip/uip-arch.h>
#include "uip_internal.h"
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: uip_schedsend
*
* Description:
* Construct the .
*
* Returned Value:
* Returns a non-zero value if a IGP message is sent.
*
* Assumptions:
* This function is called from the driver polling logic... probably within
* an interrupt handler.
*
****************************************************************************/
static inline void uip_schedsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group)
{
uip_ipaddr_t *dest;
/* Check what kind of messsage we need to send. There are only two
* possibilities:
*/
if (group->msgid == IGMPv2_MEMBERSHIP_REPORT)
{
dest = &group->grpaddr;
nllvdbg("Send IGMPv2_MEMBERSHIP_REPORT, dest=%08x flags=%02x\n",
*dest, group->flags);
IGMP_STATINCR(uip_stat.igmp.report_sched);
SET_LASTREPORT(group->flags); /* Remember we were the last to report */
}
else
{
DEBUGASSERT(group->msgid == IGMP_LEAVE_GROUP);
dest = &g_allrouters;
nllvdbg("Send IGMP_LEAVE_GROUP, dest=%08x flags=%02x\n",
*dest, group->flags);
IGMP_STATINCR(uip_stat.igmp.leave_sched);
}
/* Send the message */
uip_igmpsend(dev, group, dest);
/* Indicate that the message has been sent */
CLR_SCHEDMSG(group->flags);
group->msgid = 0;
/* If there is a thread waiting fore the message to be sent, wake it up */
if (IS_WAITMSG(group->flags))
{
nllvdbg("Awakening waiter\n");
sem_post(&group->sem);
}
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: uip_igmppoll
*
* Description:
* Poll the groups associated with the device to see if any IGMP messages
* are pending transfer.
*
* Returned Value:
* Returns a non-zero value if a IGP message is sent.
*
* Assumptions:
* This function is called from the driver polling logic... probably within
* an interrupt handler.
*
****************************************************************************/
void uip_igmppoll(FAR struct uip_driver_s *dev)
{
FAR struct igmp_group_s *group;
nllvdbg("Entry\n");
/* Setup the poll operation */
dev->d_appdata = &dev->d_buf[UIP_LLH_LEN + UIP_IPIGMPH_LEN];
dev->d_snddata = &dev->d_buf[UIP_LLH_LEN + UIP_IPIGMPH_LEN];
dev->d_len = 0;
dev->d_sndlen = 0;
/* Check each member of the group */
for (group = (FAR struct igmp_group_s *)dev->grplist.head; group; group = group->next)
{
/* Does this member have a pending outgoing message? */
if (IS_SCHEDMSG(group->flags))
{
/* Yes, create the IGMP message in the driver buffer */
uip_schedsend(dev, group);
/* Mark the message as sent and break out */
CLR_SCHEDMSG(group->flags);
break;
}
}
}
#endif /* CONFIG_NET_IGMP */
+257 -257
View File
File diff suppressed because it is too large Load Diff