Clean up IGMP naming

This commit is contained in:
Gregory Nutt 2014-06-25 09:52:36 -06:00
parent 92d3075ae0
commit f57024406a
29 changed files with 340 additions and 160 deletions

View file

@ -124,7 +124,7 @@
* (0x11); in other messages it is set to 0 and ignored by the receiver.
*/
struct uip_igmphdr_s
struct igmp_iphdr_s
{
#ifdef CONFIG_NET_IPv6
@ -224,7 +224,8 @@ struct igmp_group_s
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
extern "C"
{
#else
#define EXTERN extern
#endif
@ -237,7 +238,7 @@ EXTERN uip_ipaddr_t g_allrouters;
****************************************************************************/
/****************************************************************************
* Name: uip_igmpdevinit
* Name: igmp_devinit
*
* Description:
* Called when a new network device is registered to configure that device
@ -245,9 +246,11 @@ EXTERN uip_ipaddr_t g_allrouters;
*
****************************************************************************/
EXTERN void uip_igmpdevinit(struct uip_driver_s *dev);
EXTERN int igmp_joingroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr);
EXTERN int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr);
void igmp_devinit(FAR struct uip_driver_s *dev);
int igmp_joingroup(FAR struct uip_driver_s *dev,
FAR const struct in_addr *grpaddr);
int igmp_leavegroup(FAR struct uip_driver_s *dev,
FAR const struct in_addr *grpaddr);
#undef EXTERN
#if defined(__cplusplus)

View file

@ -44,7 +44,6 @@ NET_CSRCS += arp_inout.c arp_table.c arp_timer.c
DEPPATH += --dep-path arp
VPATH += :arp
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)net$(DELIM)arp}
endif
endif

View file

@ -54,6 +54,5 @@ endif
DEPPATH += --dep-path icmp
VPATH += :icmp
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)net$(DELIM)icmp}
endif

95
net/icmp/icmp.h Normal file
View file

@ -0,0 +1,95 @@
/****************************************************************************
* net/icmp/icmp.h
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 NuttX 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 THE COPYRIGHT HOLDERS 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 THE
* COPYRIGHT OWNER 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.
*
****************************************************************************/
#ifndef __NET_ICMP_ICMP_H
#define __NET_ICMP_ICMP_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#ifdef CONFIG_NET_ICMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Type Definitions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
# define EXTERN extern "C"
extern "C"
{
#else
# define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/* Defined in icmp_input.c **************************************************/
void icmp_input(FAR struct uip_driver_s *dev);
/* Defined in icmp_poll.c ***************************************************/
#ifdef CONFIG_NET_ICMP_PING
void icmp_poll(FAR struct uip_driver_s *dev);
#endif /* CONFIG_NET_ICMP_PING */
/* Defined in icmp_send.c ***************************************************/
#ifdef CONFIG_NET_ICMP_PING
void icmp_send(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *destaddr);
#endif /* CONFIG_NET_ICMP_PING */
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* CONFIG_NET_ICMP */
#endif /* __NET_ICMP_ICMP_H */

View file

@ -39,14 +39,13 @@ ifeq ($(CONFIG_NET),y)
ifeq ($(CONFIG_NET_IGMP),y)
NET_CSRCS += igmp_group.c igmp_init.c igmp_input.c igmp_join.c igmp_leave.c
NET_CSRCS += igmp_group.c igmp_initialize.c igmp_input.c igmp_join.c igmp_leave.c
NET_CSRCS += igmp_mcastmac.c igmp_msg.c igmp_poll.c igmp_send.c igmp_timer.c
# Include igmp build support
DEPPATH += --dep-path igmp
VPATH += :igmp
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)net$(DELIM)uip}
endif
endif

125
net/igmp/igmp.h Normal file
View file

@ -0,0 +1,125 @@
/****************************************************************************
* net/igmp/igmp.h
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 NuttX 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 THE COPYRIGHT HOLDERS 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 THE
* COPYRIGHT OWNER 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.
*
****************************************************************************/
#ifndef _NET_IGMP_IGMP_H
#define _NET_IGMP_IGMP_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Type Definitions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
# define EXTERN extern "C"
extern "C"
{
#else
# define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/* Defined in igmp_init.c ***************************************************/
void igmp_initialize(void);
/* Defined in igmp_input.c **************************************************/
void igmp_input(struct uip_driver_s *dev);
/* Defined in igmp_group.c **************************************************/
void igmp_grpinit(void);
FAR struct igmp_group_s *igmp_grpalloc(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr);
FAR struct igmp_group_s *igmp_grpfind(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr);
FAR struct igmp_group_s *igmp_grpallocfind(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr);
void igmp_grpfree(FAR struct uip_driver_s *dev,
FAR struct igmp_group_s *group);
/* Defined in igmp_msg.c ****************************************************/
void igmp_schedmsg(FAR struct igmp_group_s *group, uint8_t msgid);
void igmp_waitmsg(FAR struct igmp_group_s *group, uint8_t msgid);
/* Defined in igmp_poll.c ***************************************************/
void igmp_poll(FAR struct uip_driver_s *dev);
/* Defined in igmp_send.c ***************************************************/
void igmp_send(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group,
FAR uip_ipaddr_t *dest);
/* Defined in igmp_timer.c **************************************************/
int igmp_decisec2tick(int decisecs);
void igmp_startticks(FAR struct igmp_group_s *group, int ticks);
void igmp_starttimer(FAR struct igmp_group_s *group, uint8_t decisecs);
bool igmp_cmptimer(FAR struct igmp_group_s *group, int maxticks);
/* Defined in igmp_mcastmac *************************************************/
void igmp_addmcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip);
void igmp_removemcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* CONFIG_NET_IGMP */
#endif /* _NET_IGMP_IGMP_H */

View file

@ -59,6 +59,7 @@
#include <nuttx/net/igmp.h>
#include "uip/uip.h"
#include "igmp/igmp.h"
#ifdef CONFIG_NET_IGMP
@ -133,7 +134,7 @@ static FAR sq_queue_t g_freelist;
****************************************************************************/
/****************************************************************************
* Name: uip_grpheapalloc
* Name: igmp_grpheapalloc
*
* Description:
* Allocate a new group from heap memory.
@ -143,13 +144,13 @@ static FAR sq_queue_t g_freelist;
*
****************************************************************************/
static inline FAR struct igmp_group_s *uip_grpheapalloc(void)
static inline FAR struct igmp_group_s *igmp_grpheapalloc(void)
{
return (FAR struct igmp_group_s *)kzalloc(sizeof(struct igmp_group_s));
}
/****************************************************************************
* Name: uip_grpprealloc
* Name: igmp_grpprealloc
*
* Description:
* Allocate a new group from the pre-allocated groups.
@ -161,7 +162,7 @@ static inline FAR struct igmp_group_s *uip_grpheapalloc(void)
****************************************************************************/
#if CONFIG_PREALLOC_IGMPGROUPS > 0
static inline FAR struct igmp_group_s *uip_grpprealloc(void)
static inline FAR struct igmp_group_s *igmp_grpprealloc(void)
{
FAR struct igmp_group_s *group =
(FAR struct igmp_group_s *)sq_remfirst(&g_freelist);
@ -181,7 +182,7 @@ static inline FAR struct igmp_group_s *uip_grpprealloc(void)
****************************************************************************/
/****************************************************************************
* Name: uip_grpinit
* Name: igmp_grpinit
*
* Description:
* One-time initialization of group data.
@ -191,7 +192,7 @@ static inline FAR struct igmp_group_s *uip_grpprealloc(void)
*
****************************************************************************/
void uip_grpinit(void)
void igmp_grpinit(void)
{
FAR struct igmp_group_s *group;
int i;
@ -208,7 +209,7 @@ void uip_grpinit(void)
}
/****************************************************************************
* Name: uip_grpalloc
* Name: igmp_grpalloc
*
* Description:
* Allocate a new group from heap memory.
@ -218,8 +219,8 @@ void uip_grpinit(void)
*
****************************************************************************/
FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr)
FAR struct igmp_group_s *igmp_grpalloc(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr)
{
FAR struct igmp_group_s *group;
uip_lock_t flags;
@ -229,7 +230,7 @@ FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev,
{
#if CONFIG_PREALLOC_IGMPGROUPS > 0
grplldbg("Use a pre-allocated group entry\n");
group = uip_grpprealloc();
group = igmp_grpprealloc();
#else
grplldbg("Cannot allocate from interrupt handler\n");
group = NULL;
@ -238,7 +239,7 @@ FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev,
else
{
grplldbg("Allocate from the heap\n");
group = uip_grpheapalloc();
group = igmp_grpheapalloc();
}
grplldbg("group: %p\n", group);
@ -271,7 +272,7 @@ FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev,
}
/****************************************************************************
* Name: uip_grpfind
* Name: igmp_grpfind
*
* Description:
* Find an existing group.
@ -281,8 +282,8 @@ FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev,
*
****************************************************************************/
FAR struct igmp_group_s *uip_grpfind(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr)
FAR struct igmp_group_s *igmp_grpfind(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr)
{
FAR struct igmp_group_s *group;
uip_lock_t flags;
@ -311,7 +312,7 @@ FAR struct igmp_group_s *uip_grpfind(FAR struct uip_driver_s *dev,
}
/****************************************************************************
* Name: uip_grpallocfind
* Name: igmp_grpallocfind
*
* Description:
* Find an existing group. If not found, create a new group for the
@ -322,15 +323,15 @@ FAR struct igmp_group_s *uip_grpfind(FAR struct uip_driver_s *dev,
*
****************************************************************************/
FAR struct igmp_group_s *uip_grpallocfind(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr)
FAR struct igmp_group_s *igmp_grpallocfind(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr)
{
FAR struct igmp_group_s *group = uip_grpfind(dev, addr);
FAR struct igmp_group_s *group = igmp_grpfind(dev, addr);
grplldbg("group: %p addr: %08x\n", group, (int)*addr);
if (!group)
{
group = uip_grpalloc(dev, addr);
group = igmp_grpalloc(dev, addr);
}
grplldbg("group: %p\n", group);
@ -338,7 +339,7 @@ FAR struct igmp_group_s *uip_grpallocfind(FAR struct uip_driver_s *dev,
}
/****************************************************************************
* Name: uip_grpfree
* Name: igmp_grpfree
*
* Description:
* Release a previously allocated group.
@ -348,7 +349,7 @@ FAR struct igmp_group_s *uip_grpallocfind(FAR struct uip_driver_s *dev,
*
****************************************************************************/
void uip_grpfree(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group)
void igmp_grpfree(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group)
{
uip_lock_t flags;

View file

@ -2,7 +2,7 @@
* net/igmp/igmp_init.c
* IGMP initialization logic
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Copyright (C) 2010, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* The NuttX implementation of IGMP was inspired by the IGMP add-on for the
@ -51,6 +51,7 @@
#include <nuttx/net/igmp.h>
#include "uip/uip.h"
#include "igmp/igmp.h"
#ifdef CONFIG_NET_IGMP
@ -74,14 +75,14 @@ uip_ipaddr_t g_allrouters;
****************************************************************************/
/****************************************************************************
* Name: uip_igmpinit
* Name: igmp_initialize
*
* Description:
* Perform one-time IGMP initialization.
*
****************************************************************************/
void uip_igmpinit(void)
void igmp_initialize(void)
{
nvdbg("IGMP initializing\n");
@ -90,11 +91,11 @@ void uip_igmpinit(void)
/* Initialize the group allocation logic */
uip_grpinit();
igmp_grpinit();
}
/****************************************************************************
* Name: uip_igmpdevinit
* Name: igmp_devinit
*
* Description:
* Called when a new network device is registered to configure that device
@ -102,19 +103,19 @@ void uip_igmpinit(void)
*
****************************************************************************/
void uip_igmpdevinit(struct uip_driver_s *dev)
void igmp_devinit(struct uip_driver_s *dev)
{
nvdbg("IGMP initializing dev %p\n", dev);
DEBUGASSERT(dev->grplist.head == NULL);
/* Add the all systems address to the group */
(void)uip_grpalloc(dev, &g_allsystems);
(void)igmp_grpalloc(dev, &g_allsystems);
/* Allow the IGMP messages at the MAC level */
uip_addmcastmac(dev, &g_allrouters);
uip_addmcastmac(dev, &g_allsystems);
igmp_addmcastmac(dev, &g_allrouters);
igmp_addmcastmac(dev, &g_allsystems);
}
#endif /* CONFIG_NET_IGMP */

View file

@ -52,6 +52,7 @@
#include <nuttx/net/igmp.h>
#include "uip/uip.h"
#include "igmp/igmp.h"
#ifdef CONFIG_NET_IGMP
@ -59,7 +60,7 @@
* Pre-processor Definitions
****************************************************************************/
#define IGMPBUF ((struct uip_igmphdr_s *)&dev->d_buf[UIP_LLH_LEN])
#define IGMPBUF ((struct igmp_iphdr_s *)&dev->d_buf[UIP_LLH_LEN])
/****************************************************************************
* Private Functions
@ -70,7 +71,7 @@
****************************************************************************/
/****************************************************************************
* Name: uip_igmpinput
* Name: igmp_input
*
* Description:
* An IGMP packet has been received.
@ -111,7 +112,7 @@
*
****************************************************************************/
void uip_igmpinput(struct uip_driver_s *dev)
void igmp_input(struct uip_driver_s *dev)
{
FAR struct igmp_group_s *group;
uip_ipaddr_t destipaddr;
@ -141,7 +142,7 @@ void uip_igmpinput(struct uip_driver_s *dev)
/* Find the group (or create a new one) using the incoming IP address*/
destipaddr = uip_ip4addr_conv(IGMPBUF->destipaddr);
group = uip_grpallocfind(dev, &destipaddr);
group = igmp_grpallocfind(dev, &destipaddr);
if (!group)
{
nlldbg("Failed to allocate/find group: %08x\n", destipaddr);
@ -205,11 +206,11 @@ void uip_igmpinput(struct uip_driver_s *dev)
if (!uip_ipaddr_cmp(member->grpaddr, g_allsystems))
{
ticks = uip_decisec2tick((int)IGMPBUF->maxresp);
ticks = igmp_decisec2tick((int)IGMPBUF->maxresp);
if (IS_IDLEMEMBER(member->flags) ||
uip_igmpcmptimer(member, ticks))
igmp_cmptimer(member, ticks))
{
uip_igmpstartticks(member, ticks);
igmp_startticks(member, ticks);
CLR_IDLEMEMBER(member->flags);
}
}
@ -225,11 +226,11 @@ void uip_igmpinput(struct uip_driver_s *dev)
IGMP_STATINCR(uip_stat.igmp.ucast_query);
grpaddr = uip_ip4addr_conv(IGMPBUF->grpaddr);
group = uip_grpallocfind(dev, &grpaddr);
ticks = uip_decisec2tick((int)IGMPBUF->maxresp);
if (IS_IDLEMEMBER(group->flags) || uip_igmpcmptimer(group, ticks))
group = igmp_grpallocfind(dev, &grpaddr);
ticks = igmp_decisec2tick((int)IGMPBUF->maxresp);
if (IS_IDLEMEMBER(group->flags) || igmp_cmptimer(group, ticks))
{
uip_igmpstartticks(group, ticks);
igmp_startticks(group, ticks);
CLR_IDLEMEMBER(group->flags);
}
}
@ -244,10 +245,10 @@ void uip_igmpinput(struct uip_driver_s *dev)
nlldbg("Query to a specific group with the group address as destination\n");
ticks = uip_decisec2tick((int)IGMPBUF->maxresp);
if (IS_IDLEMEMBER(group->flags) || uip_igmpcmptimer(group, ticks))
ticks = igmp_decisec2tick((int)IGMPBUF->maxresp);
if (IS_IDLEMEMBER(group->flags) || igmp_cmptimer(group, ticks))
{
uip_igmpstartticks(group, ticks);
igmp_startticks(group, ticks);
CLR_IDLEMEMBER(group->flags);
}
}

View file

@ -51,6 +51,7 @@
#include <nuttx/net/igmp.h>
#include "uip/uip.h"
#include "igmp/igmp.h"
#ifdef CONFIG_NET_IGMP
@ -128,27 +129,27 @@ int igmp_joingroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
/* Check if a this address is already in the group */
group = uip_grpfind(dev, &grpaddr->s_addr);
group = igmp_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);
group = igmp_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);
igmp_waitmsg(group, IGMPv2_MEMBERSHIP_REPORT);
/* And start the timer at 10*100 msec */
uip_igmpstarttimer(group, 10);
igmp_starttimer(group, 10);
/* Add the group (MAC) address to the ether drivers MAC filter list */
uip_addmcastmac(dev, (FAR uip_ipaddr_t *)&grpaddr->s_addr);
igmp_addmcastmac(dev, (FAR uip_ipaddr_t *)&grpaddr->s_addr);
return OK;
}

View file

@ -52,6 +52,7 @@
#include <nuttx/net/igmp.h>
#include "uip/uip.h"
#include "igmp/igmp.h"
#ifdef CONFIG_NET_IGMP
@ -136,7 +137,7 @@ int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
/* Find the entry corresponding to the address leaving the group */
group = uip_grpfind(dev, &grpaddr->s_addr);
group = igmp_grpfind(dev, &grpaddr->s_addr);
ndbg("Leaving group: %p\n", group);
if (group)
{
@ -160,16 +161,16 @@ int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr)
{
ndbg("Schedule Leave Group message\n");
IGMP_STATINCR(uip_stat.igmp.leave_sched);
uip_igmpwaitmsg(group, IGMP_LEAVE_GROUP);
igmp_waitmsg(group, IGMP_LEAVE_GROUP);
}
/* Free the group structure (state is now Non-Member */
uip_grpfree(dev, group);
igmp_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);
igmp_removemcastmac(dev, (FAR uip_ipaddr_t *)&grpaddr->s_addr);
return OK;
}

View file

@ -50,6 +50,7 @@
#include <nuttx/net/uip.h>
#include "uip/uip.h"
#include "igmp/igmp.h"
#ifdef CONFIG_NET_IGMP
@ -90,14 +91,14 @@ static void uip_mcastmac(uip_ipaddr_t *ip, FAR uint8_t *mac)
****************************************************************************/
/****************************************************************************
* Name: uip_addmcastmac
* Name: igmp_addmcastmac
*
* Description:
* Add an IGMP MAC address to the device's MAC filter table.
*
****************************************************************************/
void uip_addmcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip)
void igmp_addmcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip)
{
uint8_t mcastmac[6];
@ -110,14 +111,14 @@ void uip_addmcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip)
}
/****************************************************************************
* Name: uip_removemcastmac
* Name: igmp_removemcastmac
*
* Description:
* Remove an IGMP MAC address from the device's MAC filter table.
*
****************************************************************************/
void uip_removemcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip)
void igmp_removemcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip)
{
uint8_t mcastmac[6];

View file

@ -51,6 +51,7 @@
#include <nuttx/net/igmp.h>
#include "uip/uip.h"
#include "igmp/igmp.h"
#ifdef CONFIG_NET_IGMP
@ -67,7 +68,7 @@
****************************************************************************/
/****************************************************************************
* Name: uip_igmpschedmsg
* Name: igmp_schedmsg
*
* Description:
* Schedule a message to be send at the next driver polling interval.
@ -77,7 +78,7 @@
*
****************************************************************************/
void uip_igmpschedmsg(FAR struct igmp_group_s *group, uint8_t msgid)
void igmp_schedmsg(FAR struct igmp_group_s *group, uint8_t msgid)
{
uip_lock_t flags;
@ -91,7 +92,7 @@ void uip_igmpschedmsg(FAR struct igmp_group_s *group, uint8_t msgid)
}
/****************************************************************************
* Name: uip_igmpwaitmsg
* Name: igmp_waitmsg
*
* Description:
* Schedule a message to be send at the next driver polling interval and
@ -103,7 +104,7 @@ void uip_igmpschedmsg(FAR struct igmp_group_s *group, uint8_t msgid)
*
****************************************************************************/
void uip_igmpwaitmsg(FAR struct igmp_group_s *group, uint8_t msgid)
void igmp_waitmsg(FAR struct igmp_group_s *group, uint8_t msgid)
{
uip_lock_t flags;
@ -112,7 +113,7 @@ void uip_igmpwaitmsg(FAR struct igmp_group_s *group, uint8_t msgid)
flags = uip_lock();
DEBUGASSERT(!IS_WAITMSG(group->flags));
SET_WAITMSG(group->flags);
uip_igmpschedmsg(group, msgid);
igmp_schedmsg(group, msgid);
/* Then wait for the message to be sent */

View file

@ -51,6 +51,7 @@
#include <nuttx/net/netdev.h>
#include "uip/uip.h"
#include "igmp/igmp.h"
#ifdef CONFIG_NET_IGMP
@ -104,7 +105,7 @@ static inline void uip_schedsend(FAR struct uip_driver_s *dev, FAR struct igmp_g
/* Send the message */
uip_igmpsend(dev, group, dest);
igmp_send(dev, group, dest);
/* Indicate that the message has been sent */
@ -125,7 +126,7 @@ static inline void uip_schedsend(FAR struct uip_driver_s *dev, FAR struct igmp_g
****************************************************************************/
/****************************************************************************
* Name: uip_igmppoll
* Name: igmp_poll
*
* Description:
* Poll the groups associated with the device to see if any IGMP messages
@ -140,7 +141,7 @@ static inline void uip_schedsend(FAR struct uip_driver_s *dev, FAR struct igmp_g
*
****************************************************************************/
void uip_igmppoll(FAR struct uip_driver_s *dev)
void igmp_poll(FAR struct uip_driver_s *dev)
{
FAR struct igmp_group_s *group;

View file

@ -49,6 +49,7 @@
#include <nuttx/net/igmp.h>
#include "uip/uip.h"
#include "igmp/igmp.h"
#ifdef CONFIG_NET_IGMP
@ -73,7 +74,7 @@
/* Buffer layout */
#define RASIZE (4)
#define IGMPBUF ((struct uip_igmphdr_s *)&dev->d_buf[UIP_LLH_LEN])
#define IGMPBUF ((struct igmp_iphdr_s *)&dev->d_buf[UIP_LLH_LEN])
/****************************************************************************
* Public Variables
@ -87,7 +88,7 @@
* Private Functions
****************************************************************************/
static uint16_t uip_igmpchksum(FAR uint8_t *buffer, int buflen)
static uint16_t igmp_chksum(FAR uint8_t *buffer, int buflen)
{
uint16_t sum = uip_chksum((FAR uint16_t*)buffer, buflen);
return sum ? sum : 0xffff;
@ -98,7 +99,7 @@ static uint16_t uip_igmpchksum(FAR uint8_t *buffer, int buflen)
****************************************************************************/
/****************************************************************************
* Name: uip_igmpsend
* Name: igmp_send
*
* Description:
* Sends an IGMP IP packet on a network interface. This function constructs
@ -118,8 +119,8 @@ static uint16_t uip_igmpchksum(FAR uint8_t *buffer, int buflen)
*
****************************************************************************/
void uip_igmpsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group,
FAR uip_ipaddr_t *destipaddr)
void igmp_send(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group,
FAR uip_ipaddr_t *destipaddr)
{
nllvdbg("msgid: %02x destipaddr: %08x\n", group->msgid, (int)*destipaddr);
@ -158,7 +159,7 @@ void uip_igmpsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group,
/* Calculate IP checksum. */
IGMPBUF->ipchksum = 0;
IGMPBUF->ipchksum = ~uip_igmpchksum((FAR uint8_t *)IGMPBUF, UIP_IPH_LEN + RASIZE);
IGMPBUF->ipchksum = ~igmp_chksum((FAR uint8_t *)IGMPBUF, UIP_IPH_LEN + RASIZE);
/* Set up the IGMP message */
@ -169,7 +170,7 @@ void uip_igmpsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group,
/* Calculate the IGMP checksum. */
IGMPBUF->chksum = 0;
IGMPBUF->chksum = ~uip_igmpchksum(&IGMPBUF->type, UIP_IPIGMPH_LEN);
IGMPBUF->chksum = ~igmp_chksum(&IGMPBUF->type, UIP_IPIGMPH_LEN);
IGMP_STATINCR(uip_stat.igmp.poll_send);
IGMP_STATINCR(uip_stat.ip.sent);

View file

@ -53,6 +53,7 @@
#include <nuttx/net/igmp.h>
#include "uip/uip.h"
#include "igmp/igmp.h"
#ifdef CONFIG_NET_IGMP
@ -99,7 +100,7 @@
****************************************************************************/
/****************************************************************************
* Name: uip_igmptimeout
* Name: igmp_timeout
*
* Description:
* Timeout watchdog handler.
@ -110,7 +111,7 @@
*
****************************************************************************/
static void uip_igmptimeout(int argc, uint32_t arg, ...)
static void igmp_timeout(int argc, uint32_t arg, ...)
{
FAR struct igmp_group_s *group;
@ -134,7 +135,7 @@ static void uip_igmptimeout(int argc, uint32_t arg, ...)
*/
IGMP_STATINCR(uip_stat.igmp.report_sched);
uip_igmpschedmsg(group, IGMPv2_MEMBERSHIP_REPORT);
igmp_schedmsg(group, IGMPv2_MEMBERSHIP_REPORT);
/* Also note: The Membership Report is sent at most two times becasue
* the timer is not reset here. Hmm.. does this mean that the group
@ -151,7 +152,7 @@ static void uip_igmptimeout(int argc, uint32_t arg, ...)
****************************************************************************/
/****************************************************************************
* Name: uip_igmpstarttimer
* Name: igmp_starttimer
*
* Description:
* Start the IGMP timer.
@ -161,7 +162,7 @@ static void uip_igmptimeout(int argc, uint32_t arg, ...)
*
****************************************************************************/
int uip_decisec2tick(int decisecs)
int igmp_decisec2tick(int decisecs)
{
/* Convert the deci-second comparison value to clock ticks. The CLK_TCK
* value is the number of clock ticks per second; decisecs argument is the
@ -173,7 +174,7 @@ int uip_decisec2tick(int decisecs)
}
/****************************************************************************
* Name: uip_igmpstartticks and uip_igmpstarttimer
* Name: igmp_startticks and igmp_starttimer
*
* Description:
* Start the IGMP timer with differing time units (ticks or deciseconds).
@ -183,7 +184,7 @@ int uip_decisec2tick(int decisecs)
*
****************************************************************************/
void uip_igmpstartticks(FAR struct igmp_group_s *group, int ticks)
void igmp_startticks(FAR struct igmp_group_s *group, int ticks)
{
int ret;
@ -191,24 +192,24 @@ void uip_igmpstartticks(FAR struct igmp_group_s *group, int ticks)
gtmrlldbg("ticks: %d\n", ticks);
ret = wd_start(group->wdog, ticks, uip_igmptimeout, 1, (uint32_t)group);
ret = wd_start(group->wdog, ticks, igmp_timeout, 1, (uint32_t)group);
DEBUGASSERT(ret == OK);
UNUSED(ret);
}
void uip_igmpstarttimer(FAR struct igmp_group_s *group, uint8_t decisecs)
void igmp_starttimer(FAR struct igmp_group_s *group, uint8_t decisecs)
{
/* Convert the decisec value to system clock ticks and start the timer.
* Important!! this should be a random timer from 0 to decisecs
*/
gtmrdbg("decisecs: %d\n", decisecs);
uip_igmpstartticks(group, uip_decisec2tick(decisecs));
igmp_startticks(group, igmp_decisec2tick(decisecs));
}
/****************************************************************************
* Name: uip_igmpcmptimer
* Name: igmp_cmptimer
*
* Description:
* Compare the timer remaining on the watching timer to the deci-second
@ -217,11 +218,11 @@ void uip_igmpstarttimer(FAR struct igmp_group_s *group, uint8_t decisecs)
*
* Assumptions:
* This function may be called from most any context. If true is returned
* then the caller must call uip_igmpstartticks() to restart the timer
* then the caller must call igmp_startticks() to restart the timer
*
****************************************************************************/
bool uip_igmpcmptimer(FAR struct igmp_group_s *group, int maxticks)
bool igmp_cmptimer(FAR struct igmp_group_s *group, int maxticks)
{
uip_lock_t flags;
int remaining;

View file

@ -51,6 +51,5 @@ endif
DEPPATH += --dep-path iob
VPATH += :iob
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)net$(DELIM)iob}
endif

View file

@ -128,7 +128,7 @@ int netdev_register(FAR struct uip_driver_s *dev)
/* Configure the device for IGMP support */
#ifdef CONFIG_NET_IGMP
uip_igmpdevinit(dev);
igmp_devinit(dev);
#endif
netdev_semgive();

View file

@ -54,7 +54,6 @@ NET_CSRCS += pkt_poll.c
DEPPATH += --dep-path pkt
VPATH += :pkt
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)net$(DELIM)pkt}
endif # CONFIG_NET_PKT
endif # CONFIG_NET

View file

@ -66,7 +66,6 @@ endif
DEPPATH += --dep-path tcp
VPATH += :tcp
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)net$(DELIM)tcp}
endif # CONFIG_NET_TCP
endif # CONFIG_NET

View file

@ -45,7 +45,6 @@ NET_CSRCS += udp_conn.c udp_poll.c udp_send.c udp_input.c udp_callback.c
DEPPATH += --dep-path udp
VPATH += :udp
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)net$(DELIM)udp}
endif # CONFIG_NET_UDP
endif # CONFIG_NET

View file

@ -68,6 +68,5 @@ endif
DEPPATH += --dep-path uip
VPATH += :uip
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)net$(DELIM)uip}
endif

View file

@ -90,7 +90,8 @@ extern struct uip_callback_s *g_echocallback;
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
extern "C"
{
#else
#define EXTERN extern
#endif
@ -125,55 +126,6 @@ void uip_pktpoll(struct uip_driver_s *dev, struct uip_pkt_conn *conn);
#endif /* CONFIG_NET_PKT */
#ifdef CONFIG_NET_IGMP
/* Defined in igmp_init.c ***************************************************/
void uip_igmpinit(void);
/* Defined in igmp_input.c **************************************************/
void uip_igmpinput(struct uip_driver_s *dev);
/* Defined in igmp_group.c **************************************************/
void uip_grpinit(void);
FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr);
FAR struct igmp_group_s *uip_grpfind(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr);
FAR struct igmp_group_s *uip_grpallocfind(FAR struct uip_driver_s *dev,
FAR const uip_ipaddr_t *addr);
void uip_grpfree(FAR struct uip_driver_s *dev,
FAR struct igmp_group_s *group);
/* Defined in igmp_msg.c ****************************************************/
void uip_igmpschedmsg(FAR struct igmp_group_s *group, uint8_t msgid);
void uip_igmpwaitmsg(FAR struct igmp_group_s *group, uint8_t msgid);
/* Defined in igmp_poll.c ***************************************************/
void uip_igmppoll(FAR struct uip_driver_s *dev);
/* Defined in igmp_send.c ***************************************************/
void uip_igmpsend(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group,
FAR uip_ipaddr_t *dest);
/* Defined in igmp_timer.c **************************************************/
int uip_decisec2tick(int decisecs);
void uip_igmpstartticks(FAR struct igmp_group_s *group, int ticks);
void uip_igmpstarttimer(FAR struct igmp_group_s *group, uint8_t decisecs);
bool uip_igmpcmptimer(FAR struct igmp_group_s *group, int maxticks);
/* Defined in igmp_mcastmac *****************************************************/
void uip_addmcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip);
void uip_removemcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip);
#endif /* CONFIG_NET_IGMP */
#undef EXTERN
#ifdef __cplusplus
}

View file

@ -48,7 +48,7 @@
#include <nuttx/net/uip.h>
#include <nuttx/net/netdev.h>
#include "uip.h"
#include "uip/uip.h"
/****************************************************************************
* Private Data

View file

@ -47,7 +47,7 @@
#include <nuttx/net/uip.h>
#include <nuttx/net/netdev.h>
#include "uip.h"
#include "uip/uip.h"
/****************************************************************************
* Pre-processor Definitions

View file

@ -50,6 +50,7 @@
#include "uip/uip.h"
#include "tcp/tcp.h"
#include "udp/udp.h"
#include "igmp/igmp.h"
/****************************************************************************
* Pre-processor Definitions
@ -156,7 +157,7 @@ void uip_initialize(void)
/* Initialize IGMP support */
#ifdef CONFIG_NET_IGMP
uip_igmpinit();
igmp_initialize();
#endif
}
#endif /* CONFIG_NET */

View file

@ -97,6 +97,7 @@
#include "tcp/tcp.h"
#include "udp/udp.h"
#include "icmp/icmp.h"
#include "igmp/igmp.h"
/****************************************************************************
* Pre-processor Definitions
@ -458,7 +459,7 @@ int uip_input(struct uip_driver_s *dev)
{
#ifdef CONFIG_NET_IGMP
uip_ipaddr_t destip = uip_ip4addr_conv(pbuf->destipaddr);
if (uip_grpfind(dev, &destip) == NULL)
if (igmp_grpfind(dev, &destip) == NULL)
#endif
{
#ifdef CONFIG_NET_STATISTICS
@ -536,7 +537,7 @@ int uip_input(struct uip_driver_s *dev)
#ifdef CONFIG_NET_IGMP
#ifndef CONFIG_NET_IPv6
case UIP_PROTO_IGMP: /* IGMP input */
uip_igmpinput(dev);
igmp_input(dev);
break;
#endif
#endif

View file

@ -50,6 +50,7 @@
#include "tcp/tcp.h"
#include "udp/udp.h"
#include "icmp/icmp.h"
#include "igmp/igmp.h"
/****************************************************************************
* Private Data
@ -125,7 +126,7 @@ static inline int uip_pollicmp(FAR struct uip_driver_s *dev,
* Function: uip_polligmp
*
* Description:
* Poll all UDP connections for available packets to send.
* Poll all IGMP connections for available packets to send.
*
* Assumptions:
* This function is called from the MAC device driver and may be called from
@ -137,9 +138,9 @@ static inline int uip_pollicmp(FAR struct uip_driver_s *dev,
static inline int uip_polligmp(FAR struct uip_driver_s *dev,
uip_poll_callback_t callback)
{
/* Perform the UDP TX poll */
/* Perform the IGMP TX poll */
uip_igmppoll(dev);
igmp_poll(dev);
/* Call back into the driver */

View file

@ -45,7 +45,7 @@
#include <nuttx/net/uip.h>
#include "uip.h"
#include "uip/uip.h"
/****************************************************************************
* Private Data