summaryrefslogtreecommitdiff
path: root/nuttx/net
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-07-10 01:20:34 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-07-10 01:20:34 +0000
commita87d861c4e0a60e1dc163f58c1b51eec13ababf3 (patch)
tree1af27a7970d534e9f1ea8eda093db55d33b4e5a8 /nuttx/net
parenta69ce203b81d4903167141ee1c60a643b10fcce4 (diff)
downloadpx4-nuttx-a87d861c4e0a60e1dc163f58c1b51eec13ababf3.tar.gz
px4-nuttx-a87d861c4e0a60e1dc163f58c1b51eec13ababf3.tar.bz2
px4-nuttx-a87d861c4e0a60e1dc163f58c1b51eec13ababf3.zip
More IGMP logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2780 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net')
-rw-r--r--nuttx/net/uip/Make.defs2
-rw-r--r--nuttx/net/uip/uip_chksum.c3
-rw-r--r--nuttx/net/uip/uip_icmpping.c2
-rwxr-xr-xnuttx/net/uip/uip_igmpgroup.c3
-rwxr-xr-xnuttx/net/uip/uip_igmpinit.c3
-rwxr-xr-xnuttx/net/uip/uip_igmppoll.c161
-rw-r--r--nuttx/net/uip/uip_internal.h10
-rw-r--r--nuttx/net/uip/uip_poll.c83
8 files changed, 239 insertions, 28 deletions
diff --git a/nuttx/net/uip/Make.defs b/nuttx/net/uip/Make.defs
index 4f94b4eab..422107318 100644
--- a/nuttx/net/uip/Make.defs
+++ b/nuttx/net/uip/Make.defs
@@ -70,7 +70,7 @@ endif
ifeq ($(CONFIG_NET_ICMP),y)
-UIP_CSRCS += uip_icmpinput.c
+UIP_CSRCS += uip_icmpinput.c uip_igmppoll.c
ifeq ($(CONFIG_NET_ICMP_PING),y)
ifneq ($(CONFIG_DISABLE_CLOCK),y)
diff --git a/nuttx/net/uip/uip_chksum.c b/nuttx/net/uip/uip_chksum.c
index 538e56a04..4bddf3fbc 100644
--- a/nuttx/net/uip/uip_chksum.c
+++ b/nuttx/net/uip/uip_chksum.c
@@ -1,10 +1,9 @@
/****************************************************************************
* net/uip/uip_chksum.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
- *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
diff --git a/nuttx/net/uip/uip_icmpping.c b/nuttx/net/uip/uip_icmpping.c
index b235edf09..b83b8b106 100644
--- a/nuttx/net/uip/uip_icmpping.c
+++ b/nuttx/net/uip/uip_icmpping.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/uip/uip_icmpping.c
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
diff --git a/nuttx/net/uip/uip_igmpgroup.c b/nuttx/net/uip/uip_igmpgroup.c
index 295800941..f51b8d542 100755
--- a/nuttx/net/uip/uip_igmpgroup.c
+++ b/nuttx/net/uip/uip_igmpgroup.c
@@ -51,6 +51,7 @@
#include <arch/irq.h>
#include <nuttx/arch.h>
+#include <nuttx/kmalloc.h>
#include <net/uip/uip.h>
#include <net/uip/uip-igmp.h>
@@ -284,7 +285,7 @@ void uip_grpfree(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group)
else
{
irqrestore(flags);
- free(group);
+ sched_free(group);
}
}
diff --git a/nuttx/net/uip/uip_igmpinit.c b/nuttx/net/uip/uip_igmpinit.c
index 9dceb0134..87c0d4e78 100755
--- a/nuttx/net/uip/uip_igmpinit.c
+++ b/nuttx/net/uip/uip_igmpinit.c
@@ -44,6 +44,8 @@
#include <nuttx/config.h>
+#include <wdog.h>
+#include <assert.h>
#include <debug.h>
#include <net/uip/uip.h>
@@ -110,7 +112,6 @@ void uip_igmpdevinit(struct uip_driver_s *dev)
/* Add the all systems address to the group */
group = uip_grpalloc(dev, &g_allsystems);
- group->state = IGMP_IDLE_MEMBER;
/* Initialize the group timer (but don't start it yet) */
diff --git a/nuttx/net/uip/uip_igmppoll.c b/nuttx/net/uip/uip_igmppoll.c
new file mode 100755
index 000000000..7ba4b50a0
--- /dev/null
+++ b/nuttx/net/uip/uip_igmppoll.c
@@ -0,0 +1,161 @@
+/****************************************************************************
+ * net/uip/uip-igmp.h
+ * The definitions in this header file are intended only for internal use
+ * by the NuttX port of the uIP stack.
+ *
+ * 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
+ ****************************************************************************/
+
+#define IGMPBUF ((struct uip_igmphdr_s *)&dev->d_buf[UIP_LLH_LEN])
+
+/****************************************************************************
+ * 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;
+
+ /* IGMP header + IP header + 8 bytes of data */
+
+ if (group->msgid == IGMPv2_MEMBERSHIP_REPORT)
+ {
+ nllvdbg("Send IGMPv2_MEMBERSHIP_REPORT\n");
+ dest = &group->grpaddr;
+ IGMP_STATINCR(uip_stat.igmp.report_sched);
+ uiphdr_ipaddr_copy(IGMPBUF->grpaddr, &group->grpaddr);
+ SET_LASTREPORT(group->flags); /* Remember we were the last to report */
+ }
+ else
+ {
+ nllvdbg("Send IGMP_LEAVE_GROUP\n");
+ DEBUGASSERT(group->msgid == IGMP_LEAVE_GROUP);
+ dest = &g_allrouters;
+ IGMP_STATINCR(uip_stat.igmp.leave_sched);
+ uiphdr_ipaddr_copy(IGMPBUF->grpaddr, &group->grpaddr);
+ }
+
+ uip_igmpsend(dev, dest);
+}
+
+/****************************************************************************
+ * 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;
+
+ /* 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 */
diff --git a/nuttx/net/uip/uip_internal.h b/nuttx/net/uip/uip_internal.h
index 8570fba5b..43f1771b1 100644
--- a/nuttx/net/uip/uip_internal.h
+++ b/nuttx/net/uip/uip_internal.h
@@ -230,7 +230,15 @@ EXTERN FAR struct igmp_group_s *uip_grpallocfind(FAR struct uip_driver_s *dev,
EXTERN void uip_grpfree(FAR struct uip_driver_s *dev,
FAR struct igmp_group_s *group);
-/* Defined in TBD */
+/* Defined in uip_igmppoll.c *************************************************/
+
+EXTERN void uip_igmppoll(FAR struct uip_driver_s *dev);
+
+/* Defined in up_igmpsend.c **************************************************/
+
+EXTERN void uip_igmpsend(FAR struct uip_driver_s *dev, uip_ipaddr_t *dest);
+
+/* Defined in TBD ************************************************************/
EXTERN void uip_igmpmac(struct uip_driver_s *dev, uip_ipaddr_t *ip, bool on);
diff --git a/nuttx/net/uip/uip_poll.c b/nuttx/net/uip/uip_poll.c
index 21b8a0df0..bb45cb943 100644
--- a/nuttx/net/uip/uip_poll.c
+++ b/nuttx/net/uip/uip_poll.c
@@ -1,7 +1,7 @@
/****************************************************************************
* net/uip/uip_poll.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -57,7 +57,7 @@
****************************************************************************/
/****************************************************************************
- * Function: uip_polludpconnections
+ * Function: uip_pollicmp
*
* Description:
* Poll all UDP connections for available packets to send.
@@ -79,7 +79,32 @@ static inline int uip_pollicmp(struct uip_driver_s *dev, uip_poll_callback_t cal
return callback(dev);
}
-#endif /* CONFIG_NET_UDP */
+#endif /* CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING */
+
+/****************************************************************************
+ * Function: uip_polligmp
+ *
+ * Description:
+ * Poll all UDP connections for available packets to send.
+ *
+ * Assumptions:
+ * This function is called from the CAN device driver and may be called from
+ * the timer interrupt/watchdog handle level.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_IGMP
+static inline int uip_polligmp(struct uip_driver_s *dev, uip_poll_callback_t callback)
+{
+ /* Perform the UDP TX poll */
+
+ uip_igmppoll(dev);
+
+ /* Call back into the driver */
+
+ return callback(dev);
+}
+#endif /* CONFIG_NET_IGMP */
/****************************************************************************
* Function: uip_polludpconnections
@@ -226,25 +251,33 @@ int uip_poll(struct uip_driver_s *dev, uip_poll_callback_t callback)
{
int bstop;
- /* Traverse all of the active TCP connections and perform the poll action */
+ /* Check for pendig IGMP messages */
- bstop = uip_polltcpconnections(dev, callback);
+#ifdef CONFIG_NET_IGMP
+ bstop = uip_polligmp(dev, callback);
if (!bstop)
+#endif
{
-#ifdef CONFIG_NET_UDP
- /* Traverse all of the allocated UDP connections and perform the poll action */
+ /* Traverse all of the active TCP connections and perform the poll action */
- bstop = uip_polludpconnections(dev, callback);
+ bstop = uip_polltcpconnections(dev, callback);
if (!bstop)
-#endif
{
+#ifdef CONFIG_NET_UDP
+ /* Traverse all of the allocated UDP connections and perform the poll action */
+
+ bstop = uip_polludpconnections(dev, callback);
+ if (!bstop)
+#endif
+ {
#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING)
- /* Traverse all of the tasks waiting to send an ICMP ECHO request */
+ /* Traverse all of the tasks waiting to send an ICMP ECHO request */
- bstop = uip_pollicmp(dev, callback);
+ bstop = uip_pollicmp(dev, callback);
#endif
+ }
}
- }
+ }
return bstop;
}
@@ -254,7 +287,7 @@ int uip_poll(struct uip_driver_s *dev, uip_poll_callback_t callback)
*
* Description:
* These function will traverse each active uIP connection structure and
- * perform TCP timer operations (and UDP polling operations). The CAN
+ * perform TCP timer operations (and UDP polling operations). The Ethernet
* driver MUST implement logic to periodically call uip_timer().
*
* This function will call the provided callback function for every active
@@ -286,23 +319,31 @@ int uip_timer(struct uip_driver_s *dev, uip_poll_callback_t callback, int hsec)
}
#endif /* UIP_REASSEMBLY */
- /* Traverse all of the active TCP connections and perform the timer action */
+ /* Check for pendig IGMP messages */
- bstop = uip_polltcptimer(dev, callback, hsec);
+#ifdef CONFIG_NET_IGMP
+ bstop = uip_polligmp(dev, callback);
if (!bstop)
+#endif
{
- /* Traverse all of the allocated UDP connections and perform the poll action */
+ /* Traverse all of the active TCP connections and perform the timer action */
-#ifdef CONFIG_NET_UDP
- bstop = uip_polludpconnections(dev, callback);
+ bstop = uip_polltcptimer(dev, callback, hsec);
if (!bstop)
-#endif
{
+ /* Traverse all of the allocated UDP connections and perform the poll action */
+
+#ifdef CONFIG_NET_UDP
+ bstop = uip_polludpconnections(dev, callback);
+ if (!bstop)
+#endif
+ {
#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING)
- /* Traverse all of the tasks waiting to send an ICMP ECHO request */
+ /* Traverse all of the tasks waiting to send an ICMP ECHO request */
- bstop = uip_pollicmp(dev, callback);
+ bstop = uip_pollicmp(dev, callback);
#endif
+ }
}
}