summaryrefslogtreecommitdiff
path: root/nuttx/net/uip
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-03 23:18:34 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-03 23:18:34 +0000
commit8e1975393114d786b3699f926a416c3945ec3dfd (patch)
tree836687c8a01c9ab067c477767811699a0584323f /nuttx/net/uip
parentf885003829cabac6e8a2db65b318f897f25ff933 (diff)
downloadpx4-nuttx-8e1975393114d786b3699f926a416c3945ec3dfd.tar.gz
px4-nuttx-8e1975393114d786b3699f926a416c3945ec3dfd.tar.bz2
px4-nuttx-8e1975393114d786b3699f926a416c3945ec3dfd.zip
Move all non-standard, NuttX header files into include/nuttx/net
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4450 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/uip')
-rw-r--r--nuttx/net/uip/uip_arp.c6
-rw-r--r--nuttx/net/uip/uip_arptab.c6
-rw-r--r--nuttx/net/uip/uip_callback.c6
-rw-r--r--nuttx/net/uip/uip_chksum.c6
-rw-r--r--nuttx/net/uip/uip_icmpinput.c6
-rw-r--r--nuttx/net/uip/uip_icmpping.c6
-rw-r--r--nuttx/net/uip/uip_icmppoll.c6
-rw-r--r--nuttx/net/uip/uip_icmpsend.c6
-rwxr-xr-xnuttx/net/uip/uip_igmpgroup.c782
-rwxr-xr-xnuttx/net/uip/uip_igmpinit.c4
-rwxr-xr-xnuttx/net/uip/uip_igmpinput.c6
-rwxr-xr-xnuttx/net/uip/uip_igmpjoin.c6
-rwxr-xr-xnuttx/net/uip/uip_igmpleave.c6
-rwxr-xr-xnuttx/net/uip/uip_igmpmsg.c6
-rwxr-xr-xnuttx/net/uip/uip_igmppoll.c6
-rwxr-xr-xnuttx/net/uip/uip_igmpsend.c10
-rwxr-xr-xnuttx/net/uip/uip_igmptimer.c6
-rw-r--r--nuttx/net/uip/uip_initialize.c2
-rw-r--r--nuttx/net/uip/uip_input.c8
-rw-r--r--nuttx/net/uip/uip_internal.h2
-rw-r--r--nuttx/net/uip/uip_listen.c2
-rw-r--r--nuttx/net/uip/uip_lock.c2
-rwxr-xr-xnuttx/net/uip/uip_mcastmac.c264
-rw-r--r--nuttx/net/uip/uip_neighbor.h2
-rw-r--r--nuttx/net/uip/uip_poll.c6
-rw-r--r--nuttx/net/uip/uip_send.c4
-rw-r--r--nuttx/net/uip/uip_setipid.c2
-rw-r--r--nuttx/net/uip/uip_tcpappsend.c6
-rw-r--r--nuttx/net/uip/uip_tcpbacklog.c10
-rw-r--r--nuttx/net/uip/uip_tcpcallback.c6
-rw-r--r--nuttx/net/uip/uip_tcpconn.c6
-rw-r--r--nuttx/net/uip/uip_tcpinput.c6
-rw-r--r--nuttx/net/uip/uip_tcppoll.c6
-rw-r--r--nuttx/net/uip/uip_tcpreadahead.c4
-rw-r--r--nuttx/net/uip/uip_tcpsend.c6
-rwxr-xr-xnuttx/net/uip/uip_tcpseqno.c6
-rw-r--r--nuttx/net/uip/uip_tcptimer.c6
-rw-r--r--nuttx/net/uip/uip_udpcallback.c6
-rw-r--r--nuttx/net/uip/uip_udpconn.c6
-rw-r--r--nuttx/net/uip/uip_udpinput.c6
-rw-r--r--nuttx/net/uip/uip_udppoll.c6
-rw-r--r--nuttx/net/uip/uip_udpsend.c6
42 files changed, 633 insertions, 633 deletions
diff --git a/nuttx/net/uip/uip_arp.c b/nuttx/net/uip/uip_arp.c
index 2428ba128..c731ff0de 100644
--- a/nuttx/net/uip/uip_arp.c
+++ b/nuttx/net/uip/uip_arp.c
@@ -63,9 +63,9 @@
#include <netinet/in.h>
#include <net/ethernet.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip-arch.h>
-#include <net/uip/uip-arp.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip-arch.h>
+#include <nuttx/net/uip/uip-arp.h>
#ifdef CONFIG_NET_ARP
diff --git a/nuttx/net/uip/uip_arptab.c b/nuttx/net/uip/uip_arptab.c
index b93ea761a..1a29f25df 100644
--- a/nuttx/net/uip/uip_arptab.c
+++ b/nuttx/net/uip/uip_arptab.c
@@ -53,9 +53,9 @@
#include <netinet/in.h>
#include <net/ethernet.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip-arch.h>
-#include <net/uip/uip-arp.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip-arch.h>
+#include <nuttx/net/uip/uip-arp.h>
#ifdef CONFIG_NET_ARP
diff --git a/nuttx/net/uip/uip_callback.c b/nuttx/net/uip/uip_callback.c
index 1270fd567..730aa7758 100644
--- a/nuttx/net/uip/uip_callback.c
+++ b/nuttx/net/uip/uip_callback.c
@@ -44,9 +44,9 @@
#include <string.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_chksum.c b/nuttx/net/uip/uip_chksum.c
index 65b9e5889..7a4eee790 100644
--- a/nuttx/net/uip/uip_chksum.c
+++ b/nuttx/net/uip/uip_chksum.c
@@ -43,9 +43,9 @@
#include <stdint.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_icmpinput.c b/nuttx/net/uip/uip_icmpinput.c
index 8a37dd75c..60ff75ea8 100644
--- a/nuttx/net/uip/uip_icmpinput.c
+++ b/nuttx/net/uip/uip_icmpinput.c
@@ -49,9 +49,9 @@
#include <debug.h>
#include <net/if.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_icmpping.c b/nuttx/net/uip/uip_icmpping.c
index 2832a4a83..5627b148a 100644
--- a/nuttx/net/uip/uip_icmpping.c
+++ b/nuttx/net/uip/uip_icmpping.c
@@ -49,9 +49,9 @@
#include <net/if.h>
#include <nuttx/clock.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
#include "../net_internal.h" /* Should not include this! */
diff --git a/nuttx/net/uip/uip_icmppoll.c b/nuttx/net/uip/uip_icmppoll.c
index 8648b509a..ca1d684c0 100644
--- a/nuttx/net/uip/uip_icmppoll.c
+++ b/nuttx/net/uip/uip_icmppoll.c
@@ -42,9 +42,9 @@
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_icmpsend.c b/nuttx/net/uip/uip_icmpsend.c
index f24d78008..0167ee9c4 100644
--- a/nuttx/net/uip/uip_icmpsend.c
+++ b/nuttx/net/uip/uip_icmpsend.c
@@ -42,9 +42,9 @@
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_igmpgroup.c b/nuttx/net/uip/uip_igmpgroup.c
index 076e990f9..220de047e 100755
--- a/nuttx/net/uip/uip_igmpgroup.c
+++ b/nuttx/net/uip/uip_igmpgroup.c
@@ -1,391 +1,391 @@
-/****************************************************************************
- * net/uip/uip_igmpgroup.c
- * IGMP group data structure management 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 <nuttx/compiler.h>
-
-#include <stdlib.h>
-#include <string.h>
-#include <wdog.h>
-#include <queue.h>
-#include <debug.h>
-
-#include <arch/irq.h>
-#include <nuttx/arch.h>
-#include <nuttx/kmalloc.h>
-
-#include <net/uip/uip.h>
-#include <net/uip/uip-igmp.h>
-
-#include "uip_internal.h"
-
-#ifdef CONFIG_NET_IGMP
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/* Configuration ************************************************************/
-
-#ifdef CONFIG_NET_IPv6
-# error "IGMP for IPv6 not supported"
-#endif
-
-#ifndef CONFIG_PREALLOC_IGMPGROUPS
-# define CONFIG_PREALLOC_IGMPGROUPS 4
-#endif
-
-/* Debug ********************************************************************/
-
-#undef IGMP_GRPDEBUG /* Define to enable detailed IGMP group debug */
-
-#ifndef CONFIG_NET_IGMP
-# undef IGMP_GRPDEBUG
-#endif
-
-#ifdef CONFIG_CPP_HAVE_VARARGS
-# ifdef IGMP_GRPDEBUG
-# define grpdbg(format, arg...) ndbg(format, ##arg)
-# define grplldbg(format, arg...) nlldbg(format, ##arg)
-# define grpvdbg(format, arg...) nvdbg(format, ##arg)
-# define grpllvdbg(format, arg...) nllvdbg(format, ##arg)
-# else
-# define grpdbg(x...)
-# define grplldbg(x...)
-# define grpvdbg(x...)
-# define grpllvdbg(x...)
-# endif
-#else
-# ifdef IGMP_GRPDEBUG
-# define grpdbg ndbg
-# define grplldbg nlldbg
-# define grpvdbg nvdbg
-# define grpllvdbg nllvdbg
-# else
-# define grpdbg (void)
-# define grplldbg (void)
-# define grpvdbg (void)
-# define grpllvdbg (void)
-# endif
-#endif
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/* malloc() cannot be called from an interrupt handler. To work around this,
- * a small number of IGMP groups are preallocated just for use in interrupt
- * handling logic.
- */
-
-#if CONFIG_PREALLOC_IGMPGROUPS > 0
-static struct igmp_group_s g_preallocgrps[CONFIG_PREALLOC_IGMPGROUPS];
-static FAR sq_queue_t g_freelist;
-#endif
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: uip_grpalloc
- *
- * Description:
- * Allocate a new group from heap memory.
- *
- * Assumptions:
- * Calls malloc and so cannot be called from an interrupt handler.
- *
- ****************************************************************************/
-
-static inline FAR struct igmp_group_s *uip_grpheapalloc(void)
-{
- return (FAR struct igmp_group_s *)zalloc(sizeof(struct igmp_group_s));
-}
-
-/****************************************************************************
- * Name: uip_grpprealloc
- *
- * Description:
- * Allocate a new group from the pre-allocated groups.
- *
- * Assumptions:
- * This function should only be called from an interrupt handler (or with
- * interrupts disabled).
- *
- ****************************************************************************/
-
-#if CONFIG_PREALLOC_IGMPGROUPS > 0
-static inline FAR struct igmp_group_s *uip_grpprealloc(void)
-{
- FAR struct igmp_group_s *group = (FAR struct igmp_group_s *)sq_remfirst(&g_freelist);
- if (group)
- {
- memset(group, 0, sizeof(struct igmp_group_s));
- group->flags = IGMP_PREALLOCATED;
- }
- return group;
-}
-#endif
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: uip_grpinit
- *
- * Description:
- * One-time initialization of group data.
- *
- * Assumptions:
- * Called only during early boot phases (pre-multitasking).
- *
- ****************************************************************************/
-
-void uip_grpinit(void)
-{
- FAR struct igmp_group_s *group;
- int i;
-
- grplldbg("Initializing\n");
-
-#if CONFIG_PREALLOC_IGMPGROUPS > 0
- for (i = 0; i < CONFIG_PREALLOC_IGMPGROUPS; i++)
- {
- group = &g_preallocgrps[i];
- sq_addfirst((FAR sq_entry_t *)group, &g_freelist);
- }
-#endif
-}
-
-/****************************************************************************
- * Name: uip_grpalloc
- *
- * Description:
- * Allocate a new group from heap memory.
- *
- * Assumptions:
- * May be called from either user or interrupt level processing.
- *
- ****************************************************************************/
-
-FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev,
- FAR const uip_ipaddr_t *addr)
-{
- FAR struct igmp_group_s *group;
- uip_lock_t flags;
-
- nllvdbg("addr: %08x dev: %p\n", *addr, dev);
- if (up_interrupt_context())
- {
-#if CONFIG_PREALLOC_IGMPGROUPS > 0
- grplldbg("Use a pre-allocated group entry\n");
- group = uip_grpprealloc();
-#else
- grplldbg("Cannot allocate from interrupt handler\n");
- group = NULL;
-#endif
- }
- else
- {
- grplldbg("Allocate from the heap\n");
- group = uip_grpheapalloc();
- }
- grplldbg("group: %p\n", group);
-
- /* Check if we succesfully allocated a group structure */
-
- if (group)
- {
- /* Initialize the non-zero elements of the group structure */
-
- uip_ipaddr_copy(group->grpaddr, *addr);
- sem_init(&group->sem, 0, 0);
-
- /* Initialize the group timer (but don't start it yet) */
-
- group->wdog = wd_create();
- DEBUGASSERT(group->wdog);
-
- /* Interrupts must be disabled in order to modify the group list */
-
- flags = uip_lock();
-
- /* Add the group structure to the list in the device structure */
-
- sq_addfirst((FAR sq_entry_t*)group, &dev->grplist);
- uip_unlock(flags);
- }
- return group;
-}
-
-/****************************************************************************
- * Name: uip_grpfind
- *
- * Description:
- * Find an existing group.
- *
- * Assumptions:
- * May be called from either user or interrupt level processing.
- *
- ****************************************************************************/
-
-FAR struct igmp_group_s *uip_grpfind(FAR struct uip_driver_s *dev,
- FAR const uip_ipaddr_t *addr)
-{
- FAR struct igmp_group_s *group;
- uip_lock_t flags;
-
- grplldbg("Searching for addr %08x\n", (int)*addr);
-
- /* We must disable interrupts because we don't which context we were
- * called from.
- */
-
- flags = uip_lock();
- for (group = (FAR struct igmp_group_s *)dev->grplist.head;
- group;
- group = group->next)
- {
- grplldbg("Compare: %08x vs. %08x\n", group->grpaddr, *addr);
- if (uip_ipaddr_cmp(group->grpaddr, *addr))
- {
- grplldbg("Match!\n");
- break;
- }
- }
- uip_unlock(flags);
- return group;
-}
-
-/****************************************************************************
- * Name: uip_grpallocfind
- *
- * Description:
- * Find an existing group. If not found, create a new group for the
- * address.
- *
- * Assumptions:
- * May be called from either user or interrupt level processing.
- *
- ****************************************************************************/
-
-FAR struct igmp_group_s *uip_grpallocfind(FAR struct uip_driver_s *dev,
- FAR const uip_ipaddr_t *addr)
-{
- FAR struct igmp_group_s *group = uip_grpfind(dev, addr);
-
- grplldbg("group: %p addr: %08x\n", group, (int)*addr);
- if (!group)
- {
- group = uip_grpalloc(dev, addr);
- }
- grplldbg("group: %p\n", group);
- return group;
-}
-
-/****************************************************************************
- * Name: uip_grpfree
- *
- * Description:
- * Release a previously allocated group.
- *
- * Assumptions:
- * May be called from either user or interrupt level processing.
- *
- ****************************************************************************/
-
-void uip_grpfree(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group)
-{
- uip_lock_t flags;
-
- grplldbg("Free: %p flags: %02x\n", group, group->flags);
-
- /* Cancel the wdog */
-
- flags = uip_lock();
- wd_cancel(group->wdog);
-
- /* Remove the group structure from the group list in the device structure */
-
- sq_rem((FAR sq_entry_t*)group, &dev->grplist);
-
- /* Destroy the wait semapore */
-
- (void)sem_destroy(&group->sem);
-
- /* Destroy the wdog */
-
- wd_delete(group->wdog);
-
- /* Then release the group structure resources. Check first if this is one
- * of the pre-allocated group structures that we will retain in a free list.
- */
-
-#if CONFIG_PREALLOC_IGMPGROUPS > 0
- if (IS_PREALLOCATED(group->flags))
- {
- grplldbg("Put back on free list\n");
- sq_addlast((FAR sq_entry_t*)group, &g_freelist);
- uip_unlock(flags);
- }
- else
-#endif
- {
- /* No.. deallocate the group structure. Use sched_free() just in case
- * this function is executing within an interrupt handler.
- */
-
- uip_unlock(flags);
- grplldbg("Call sched_free()\n");
- sched_free(group);
- }
-}
-
-#endif /* CONFIG_NET_IGMP */
+/****************************************************************************
+ * net/uip/uip_igmpgroup.c
+ * IGMP group data structure management 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 <nuttx/compiler.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <wdog.h>
+#include <queue.h>
+#include <debug.h>
+
+#include <arch/irq.h>
+#include <nuttx/arch.h>
+#include <nuttx/kmalloc.h>
+
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-igmp.h>
+
+#include "uip_internal.h"
+
+#ifdef CONFIG_NET_IGMP
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Configuration ************************************************************/
+
+#ifdef CONFIG_NET_IPv6
+# error "IGMP for IPv6 not supported"
+#endif
+
+#ifndef CONFIG_PREALLOC_IGMPGROUPS
+# define CONFIG_PREALLOC_IGMPGROUPS 4
+#endif
+
+/* Debug ********************************************************************/
+
+#undef IGMP_GRPDEBUG /* Define to enable detailed IGMP group debug */
+
+#ifndef CONFIG_NET_IGMP
+# undef IGMP_GRPDEBUG
+#endif
+
+#ifdef CONFIG_CPP_HAVE_VARARGS
+# ifdef IGMP_GRPDEBUG
+# define grpdbg(format, arg...) ndbg(format, ##arg)
+# define grplldbg(format, arg...) nlldbg(format, ##arg)
+# define grpvdbg(format, arg...) nvdbg(format, ##arg)
+# define grpllvdbg(format, arg...) nllvdbg(format, ##arg)
+# else
+# define grpdbg(x...)
+# define grplldbg(x...)
+# define grpvdbg(x...)
+# define grpllvdbg(x...)
+# endif
+#else
+# ifdef IGMP_GRPDEBUG
+# define grpdbg ndbg
+# define grplldbg nlldbg
+# define grpvdbg nvdbg
+# define grpllvdbg nllvdbg
+# else
+# define grpdbg (void)
+# define grplldbg (void)
+# define grpvdbg (void)
+# define grpllvdbg (void)
+# endif
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* malloc() cannot be called from an interrupt handler. To work around this,
+ * a small number of IGMP groups are preallocated just for use in interrupt
+ * handling logic.
+ */
+
+#if CONFIG_PREALLOC_IGMPGROUPS > 0
+static struct igmp_group_s g_preallocgrps[CONFIG_PREALLOC_IGMPGROUPS];
+static FAR sq_queue_t g_freelist;
+#endif
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: uip_grpalloc
+ *
+ * Description:
+ * Allocate a new group from heap memory.
+ *
+ * Assumptions:
+ * Calls malloc and so cannot be called from an interrupt handler.
+ *
+ ****************************************************************************/
+
+static inline FAR struct igmp_group_s *uip_grpheapalloc(void)
+{
+ return (FAR struct igmp_group_s *)zalloc(sizeof(struct igmp_group_s));
+}
+
+/****************************************************************************
+ * Name: uip_grpprealloc
+ *
+ * Description:
+ * Allocate a new group from the pre-allocated groups.
+ *
+ * Assumptions:
+ * This function should only be called from an interrupt handler (or with
+ * interrupts disabled).
+ *
+ ****************************************************************************/
+
+#if CONFIG_PREALLOC_IGMPGROUPS > 0
+static inline FAR struct igmp_group_s *uip_grpprealloc(void)
+{
+ FAR struct igmp_group_s *group = (FAR struct igmp_group_s *)sq_remfirst(&g_freelist);
+ if (group)
+ {
+ memset(group, 0, sizeof(struct igmp_group_s));
+ group->flags = IGMP_PREALLOCATED;
+ }
+ return group;
+}
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: uip_grpinit
+ *
+ * Description:
+ * One-time initialization of group data.
+ *
+ * Assumptions:
+ * Called only during early boot phases (pre-multitasking).
+ *
+ ****************************************************************************/
+
+void uip_grpinit(void)
+{
+ FAR struct igmp_group_s *group;
+ int i;
+
+ grplldbg("Initializing\n");
+
+#if CONFIG_PREALLOC_IGMPGROUPS > 0
+ for (i = 0; i < CONFIG_PREALLOC_IGMPGROUPS; i++)
+ {
+ group = &g_preallocgrps[i];
+ sq_addfirst((FAR sq_entry_t *)group, &g_freelist);
+ }
+#endif
+}
+
+/****************************************************************************
+ * Name: uip_grpalloc
+ *
+ * Description:
+ * Allocate a new group from heap memory.
+ *
+ * Assumptions:
+ * May be called from either user or interrupt level processing.
+ *
+ ****************************************************************************/
+
+FAR struct igmp_group_s *uip_grpalloc(FAR struct uip_driver_s *dev,
+ FAR const uip_ipaddr_t *addr)
+{
+ FAR struct igmp_group_s *group;
+ uip_lock_t flags;
+
+ nllvdbg("addr: %08x dev: %p\n", *addr, dev);
+ if (up_interrupt_context())
+ {
+#if CONFIG_PREALLOC_IGMPGROUPS > 0
+ grplldbg("Use a pre-allocated group entry\n");
+ group = uip_grpprealloc();
+#else
+ grplldbg("Cannot allocate from interrupt handler\n");
+ group = NULL;
+#endif
+ }
+ else
+ {
+ grplldbg("Allocate from the heap\n");
+ group = uip_grpheapalloc();
+ }
+ grplldbg("group: %p\n", group);
+
+ /* Check if we succesfully allocated a group structure */
+
+ if (group)
+ {
+ /* Initialize the non-zero elements of the group structure */
+
+ uip_ipaddr_copy(group->grpaddr, *addr);
+ sem_init(&group->sem, 0, 0);
+
+ /* Initialize the group timer (but don't start it yet) */
+
+ group->wdog = wd_create();
+ DEBUGASSERT(group->wdog);
+
+ /* Interrupts must be disabled in order to modify the group list */
+
+ flags = uip_lock();
+
+ /* Add the group structure to the list in the device structure */
+
+ sq_addfirst((FAR sq_entry_t*)group, &dev->grplist);
+ uip_unlock(flags);
+ }
+ return group;
+}
+
+/****************************************************************************
+ * Name: uip_grpfind
+ *
+ * Description:
+ * Find an existing group.
+ *
+ * Assumptions:
+ * May be called from either user or interrupt level processing.
+ *
+ ****************************************************************************/
+
+FAR struct igmp_group_s *uip_grpfind(FAR struct uip_driver_s *dev,
+ FAR const uip_ipaddr_t *addr)
+{
+ FAR struct igmp_group_s *group;
+ uip_lock_t flags;
+
+ grplldbg("Searching for addr %08x\n", (int)*addr);
+
+ /* We must disable interrupts because we don't which context we were
+ * called from.
+ */
+
+ flags = uip_lock();
+ for (group = (FAR struct igmp_group_s *)dev->grplist.head;
+ group;
+ group = group->next)
+ {
+ grplldbg("Compare: %08x vs. %08x\n", group->grpaddr, *addr);
+ if (uip_ipaddr_cmp(group->grpaddr, *addr))
+ {
+ grplldbg("Match!\n");
+ break;
+ }
+ }
+ uip_unlock(flags);
+ return group;
+}
+
+/****************************************************************************
+ * Name: uip_grpallocfind
+ *
+ * Description:
+ * Find an existing group. If not found, create a new group for the
+ * address.
+ *
+ * Assumptions:
+ * May be called from either user or interrupt level processing.
+ *
+ ****************************************************************************/
+
+FAR struct igmp_group_s *uip_grpallocfind(FAR struct uip_driver_s *dev,
+ FAR const uip_ipaddr_t *addr)
+{
+ FAR struct igmp_group_s *group = uip_grpfind(dev, addr);
+
+ grplldbg("group: %p addr: %08x\n", group, (int)*addr);
+ if (!group)
+ {
+ group = uip_grpalloc(dev, addr);
+ }
+ grplldbg("group: %p\n", group);
+ return group;
+}
+
+/****************************************************************************
+ * Name: uip_grpfree
+ *
+ * Description:
+ * Release a previously allocated group.
+ *
+ * Assumptions:
+ * May be called from either user or interrupt level processing.
+ *
+ ****************************************************************************/
+
+void uip_grpfree(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group)
+{
+ uip_lock_t flags;
+
+ grplldbg("Free: %p flags: %02x\n", group, group->flags);
+
+ /* Cancel the wdog */
+
+ flags = uip_lock();
+ wd_cancel(group->wdog);
+
+ /* Remove the group structure from the group list in the device structure */
+
+ sq_rem((FAR sq_entry_t*)group, &dev->grplist);
+
+ /* Destroy the wait semapore */
+
+ (void)sem_destroy(&group->sem);
+
+ /* Destroy the wdog */
+
+ wd_delete(group->wdog);
+
+ /* Then release the group structure resources. Check first if this is one
+ * of the pre-allocated group structures that we will retain in a free list.
+ */
+
+#if CONFIG_PREALLOC_IGMPGROUPS > 0
+ if (IS_PREALLOCATED(group->flags))
+ {
+ grplldbg("Put back on free list\n");
+ sq_addlast((FAR sq_entry_t*)group, &g_freelist);
+ uip_unlock(flags);
+ }
+ else
+#endif
+ {
+ /* No.. deallocate the group structure. Use sched_free() just in case
+ * this function is executing within an interrupt handler.
+ */
+
+ uip_unlock(flags);
+ grplldbg("Call sched_free()\n");
+ sched_free(group);
+ }
+}
+
+#endif /* CONFIG_NET_IGMP */
diff --git a/nuttx/net/uip/uip_igmpinit.c b/nuttx/net/uip/uip_igmpinit.c
index b6483b0a7..7954e7b3e 100755
--- a/nuttx/net/uip/uip_igmpinit.c
+++ b/nuttx/net/uip/uip_igmpinit.c
@@ -47,8 +47,8 @@
#include <assert.h>
#include <debug.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-igmp.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-igmp.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_igmpinput.c b/nuttx/net/uip/uip_igmpinput.c
index ba70af5bf..5b4fbefa4 100755
--- a/nuttx/net/uip/uip_igmpinput.c
+++ b/nuttx/net/uip/uip_igmpinput.c
@@ -47,9 +47,9 @@
#include <assert.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-igmp.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-igmp.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_igmpjoin.c b/nuttx/net/uip/uip_igmpjoin.c
index a7118051a..eb6e88837 100755
--- a/nuttx/net/uip/uip_igmpjoin.c
+++ b/nuttx/net/uip/uip_igmpjoin.c
@@ -46,9 +46,9 @@
#include <assert.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-igmp.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-igmp.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_igmpleave.c b/nuttx/net/uip/uip_igmpleave.c
index bbc25a830..7e2a31a19 100755
--- a/nuttx/net/uip/uip_igmpleave.c
+++ b/nuttx/net/uip/uip_igmpleave.c
@@ -47,9 +47,9 @@
#include <assert.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-igmp.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-igmp.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_igmpmsg.c b/nuttx/net/uip/uip_igmpmsg.c
index 182d7b92d..9ea3daa4e 100755
--- a/nuttx/net/uip/uip_igmpmsg.c
+++ b/nuttx/net/uip/uip_igmpmsg.c
@@ -46,9 +46,9 @@
#include <assert.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-igmp.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-igmp.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_igmppoll.c b/nuttx/net/uip/uip_igmppoll.c
index 9ec96ed43..cec2a5e1b 100755
--- a/nuttx/net/uip/uip_igmppoll.c
+++ b/nuttx/net/uip/uip_igmppoll.c
@@ -46,9 +46,9 @@
#include <assert.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_igmpsend.c b/nuttx/net/uip/uip_igmpsend.c
index 568794f1f..21fc2beb0 100755
--- a/nuttx/net/uip/uip_igmpsend.c
+++ b/nuttx/net/uip/uip_igmpsend.c
@@ -42,11 +42,11 @@
#include <debug.h>
#include <arpa/inet.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
-#include <net/uip/uip-ipopt.h>
-#include <net/uip/uip-igmp.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
+#include <nuttx/net/uip/uip-ipopt.h>
+#include <nuttx/net/uip/uip-igmp.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_igmptimer.c b/nuttx/net/uip/uip_igmptimer.c
index 4d454b091..27e2f9ff0 100755
--- a/nuttx/net/uip/uip_igmptimer.c
+++ b/nuttx/net/uip/uip_igmptimer.c
@@ -48,9 +48,9 @@
#include <assert.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-igmp.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-igmp.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_initialize.c b/nuttx/net/uip/uip_initialize.c
index 765a20ecd..8839836c4 100644
--- a/nuttx/net/uip/uip_initialize.c
+++ b/nuttx/net/uip/uip_initialize.c
@@ -45,7 +45,7 @@
#ifdef CONFIG_NET
#include <stdint.h>
-#include <net/uip/uip.h>
+#include <nuttx/net/uip/uip.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_input.c b/nuttx/net/uip/uip_input.c
index 99e237929..7ae2f2739 100644
--- a/nuttx/net/uip/uip_input.c
+++ b/nuttx/net/uip/uip_input.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * net/uip/uip_input.c
+ * netuip/uip_input.c
* The uIP TCP/IP stack code.
*
* Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
@@ -85,9 +85,9 @@
#include <debug.h>
#include <string.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#ifdef CONFIG_NET_IPv6
# include "uip_neighbor.h"
diff --git a/nuttx/net/uip/uip_internal.h b/nuttx/net/uip/uip_internal.h
index 01c018c51..eee99a222 100644
--- a/nuttx/net/uip/uip_internal.h
+++ b/nuttx/net/uip/uip_internal.h
@@ -50,7 +50,7 @@
#include <stdbool.h>
#include <errno.h>
#include <arch/irq.h>
-#include <net/uip/uip.h>
+#include <nuttx/net/uip/uip.h>
/****************************************************************************
* Public Macro Definitions
diff --git a/nuttx/net/uip/uip_listen.c b/nuttx/net/uip/uip_listen.c
index 8052ca236..5f867fef2 100644
--- a/nuttx/net/uip/uip_listen.c
+++ b/nuttx/net/uip/uip_listen.c
@@ -48,7 +48,7 @@
#include <stdbool.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
+#include <nuttx/net/uip/uipopt.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_lock.c b/nuttx/net/uip/uip_lock.c
index f7e218d91..7ba5f88a0 100644
--- a/nuttx/net/uip/uip_lock.c
+++ b/nuttx/net/uip/uip_lock.c
@@ -45,7 +45,7 @@
#include <debug.h>
#include <nuttx/arch.h>
-#include <net/uip/uip.h>
+#include <nuttx/net/uip/uip.h>
#if defined(CONFIG_NET) && defined(CONFIG_NET_NOINTS)
diff --git a/nuttx/net/uip/uip_mcastmac.c b/nuttx/net/uip/uip_mcastmac.c
index ebe97f75f..7795becab 100755
--- a/nuttx/net/uip/uip_mcastmac.c
+++ b/nuttx/net/uip/uip_mcastmac.c
@@ -1,132 +1,132 @@
-/****************************************************************************
- * net/uip/uip_mcastmac.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 "uip_internal.h"
-
-#ifdef CONFIG_NET_IGMP
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: uip_mcastmac
- *
- * Description:
- * Given an IP address (in network order), create a IGMP multicast MAC
- * address.
- *
- ****************************************************************************/
-
-static void uip_mcastmac(uip_ipaddr_t *ip, FAR uint8_t *mac)
-{
- /* This mapping is from the IETF IN RFC 1700 */
-
- mac[0] = 0x01;
- mac[1] = 0x00;
- mac[2] = 0x5e;
- mac[3] = ip4_addr2(*ip) & 0x7f;
- mac[4] = ip4_addr3(*ip);
- mac[5] = ip4_addr4(*ip);
-
- nvdbg("IP: %08x -> MAC: %02x%02x%02x%02x%02x%02x\n",
- *ip, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-}
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: uip_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)
-{
- uint8_t mcastmac[6];
-
- nvdbg("Adding: IP %08x\n", *ip);
- if (dev->d_addmac)
- {
- uip_mcastmac(ip, mcastmac);
- dev->d_addmac(dev, mcastmac);
- }
-}
-
-/****************************************************************************
- * Name: uip_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)
-{
- uint8_t mcastmac[6];
-
- nvdbg("Removing: IP %08x\n", *ip);
- if (dev->d_rmmac)
- {
- uip_mcastmac(ip, mcastmac);
- dev->d_rmmac(dev, mcastmac);
- }
-}
-
-#endif /* CONFIG_NET_IGMP */
+/****************************************************************************
+ * net/uip/uip_mcastmac.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 <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+
+#include "uip_internal.h"
+
+#ifdef CONFIG_NET_IGMP
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: uip_mcastmac
+ *
+ * Description:
+ * Given an IP address (in network order), create a IGMP multicast MAC
+ * address.
+ *
+ ****************************************************************************/
+
+static void uip_mcastmac(uip_ipaddr_t *ip, FAR uint8_t *mac)
+{
+ /* This mapping is from the IETF IN RFC 1700 */
+
+ mac[0] = 0x01;
+ mac[1] = 0x00;
+ mac[2] = 0x5e;
+ mac[3] = ip4_addr2(*ip) & 0x7f;
+ mac[4] = ip4_addr3(*ip);
+ mac[5] = ip4_addr4(*ip);
+
+ nvdbg("IP: %08x -> MAC: %02x%02x%02x%02x%02x%02x\n",
+ *ip, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: uip_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)
+{
+ uint8_t mcastmac[6];
+
+ nvdbg("Adding: IP %08x\n", *ip);
+ if (dev->d_addmac)
+ {
+ uip_mcastmac(ip, mcastmac);
+ dev->d_addmac(dev, mcastmac);
+ }
+}
+
+/****************************************************************************
+ * Name: uip_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)
+{
+ uint8_t mcastmac[6];
+
+ nvdbg("Removing: IP %08x\n", *ip);
+ if (dev->d_rmmac)
+ {
+ uip_mcastmac(ip, mcastmac);
+ dev->d_rmmac(dev, mcastmac);
+ }
+}
+
+#endif /* CONFIG_NET_IGMP */
diff --git a/nuttx/net/uip/uip_neighbor.h b/nuttx/net/uip/uip_neighbor.h
index 355d1fdad..eac08f938 100644
--- a/nuttx/net/uip/uip_neighbor.h
+++ b/nuttx/net/uip/uip_neighbor.h
@@ -40,7 +40,7 @@
#define __UIP_NEIGHBOR_H__
#include <stdint.h>
-#include <net/uip/uip.h>
+#include <nuttx/net/uip/uip.h>
#include <net/ethernet.h>
struct uip_neighbor_addr
diff --git a/nuttx/net/uip/uip_poll.c b/nuttx/net/uip/uip_poll.c
index bb45cb943..5aeb3b788 100644
--- a/nuttx/net/uip/uip_poll.c
+++ b/nuttx/net/uip/uip_poll.c
@@ -42,9 +42,9 @@
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_send.c b/nuttx/net/uip/uip_send.c
index 2c8044e15..fd0f4f7da 100644
--- a/nuttx/net/uip/uip_send.c
+++ b/nuttx/net/uip/uip_send.c
@@ -44,8 +44,8 @@
#include <string.h>
#include <debug.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
/****************************************************************************
* Definitions
diff --git a/nuttx/net/uip/uip_setipid.c b/nuttx/net/uip/uip_setipid.c
index 2cbccece4..f9d13cc9d 100644
--- a/nuttx/net/uip/uip_setipid.c
+++ b/nuttx/net/uip/uip_setipid.c
@@ -44,7 +44,7 @@
#include <stdint.h>
#include <debug.h>
-#include <net/uip/uip.h>
+#include <nuttx/net/uip/uip.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_tcpappsend.c b/nuttx/net/uip/uip_tcpappsend.c
index e887e9efc..d8a187503 100644
--- a/nuttx/net/uip/uip_tcpappsend.c
+++ b/nuttx/net/uip/uip_tcpappsend.c
@@ -48,9 +48,9 @@
#include <assert.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_tcpbacklog.c b/nuttx/net/uip/uip_tcpbacklog.c
index 198bbd6b5..459d54312 100644
--- a/nuttx/net/uip/uip_tcpbacklog.c
+++ b/nuttx/net/uip/uip_tcpbacklog.c
@@ -1,8 +1,8 @@
/****************************************************************************
* net/uip/uip_tcpbacklog.c
*
- * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2008-2009, 2011-2012 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
@@ -37,7 +37,7 @@
* Included Files
****************************************************************************/
-#include <net/uip/uipopt.h>
+#include <nuttx/net/uip/uipopt.h>
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) && defined(CONFIG_NET_TCPBACKLOG)
#include <stdint.h>
@@ -46,8 +46,8 @@
#include <queue.h>
#include <debug.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-tcp.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-tcp.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_tcpcallback.c b/nuttx/net/uip/uip_tcpcallback.c
index 099c29bf3..9ce8eb132 100644
--- a/nuttx/net/uip/uip_tcpcallback.c
+++ b/nuttx/net/uip/uip_tcpcallback.c
@@ -45,9 +45,9 @@
#include <string.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_tcpconn.c b/nuttx/net/uip/uip_tcpconn.c
index 932aad2f7..c2b64ad89 100644
--- a/nuttx/net/uip/uip_tcpconn.c
+++ b/nuttx/net/uip/uip_tcpconn.c
@@ -55,9 +55,9 @@
#include <arch/irq.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_tcpinput.c b/nuttx/net/uip/uip_tcpinput.c
index a8e8032e9..5b40963b6 100644
--- a/nuttx/net/uip/uip_tcpinput.c
+++ b/nuttx/net/uip/uip_tcpinput.c
@@ -50,9 +50,9 @@
#include <string.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_tcppoll.c b/nuttx/net/uip/uip_tcppoll.c
index de827692d..29cb6d4b4 100644
--- a/nuttx/net/uip/uip_tcppoll.c
+++ b/nuttx/net/uip/uip_tcppoll.c
@@ -48,9 +48,9 @@
#include <stdint.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_tcpreadahead.c b/nuttx/net/uip/uip_tcpreadahead.c
index fefe76bae..21ed58b99 100644
--- a/nuttx/net/uip/uip_tcpreadahead.c
+++ b/nuttx/net/uip/uip_tcpreadahead.c
@@ -37,13 +37,13 @@
* Included Files
****************************************************************************/
-#include <net/uip/uipopt.h>
+#include <nuttx/net/uip/uipopt.h>
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP) && (CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0)
#include <queue.h>
#include <debug.h>
-#include <net/uip/uip.h>
+#include <nuttx/net/uip/uip.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_tcpsend.c b/nuttx/net/uip/uip_tcpsend.c
index 9ca81a606..7051d7621 100644
--- a/nuttx/net/uip/uip_tcpsend.c
+++ b/nuttx/net/uip/uip_tcpsend.c
@@ -48,9 +48,9 @@
#include <string.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_tcpseqno.c b/nuttx/net/uip/uip_tcpseqno.c
index 8c19eb257..eab3a054a 100755
--- a/nuttx/net/uip/uip_tcpseqno.c
+++ b/nuttx/net/uip/uip_tcpseqno.c
@@ -50,9 +50,9 @@
#include <stdint.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_tcptimer.c b/nuttx/net/uip/uip_tcptimer.c
index 1f29f7b89..c95376ab0 100644
--- a/nuttx/net/uip/uip_tcptimer.c
+++ b/nuttx/net/uip/uip_tcptimer.c
@@ -48,9 +48,9 @@
#include <stdint.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_udpcallback.c b/nuttx/net/uip/uip_udpcallback.c
index 109f76f50..f00c5e0f8 100644
--- a/nuttx/net/uip/uip_udpcallback.c
+++ b/nuttx/net/uip/uip_udpcallback.c
@@ -43,9 +43,9 @@
#include <stdint.h>
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_udpconn.c b/nuttx/net/uip/uip_udpconn.c
index 0180a9c14..2babad75f 100644
--- a/nuttx/net/uip/uip_udpconn.c
+++ b/nuttx/net/uip/uip_udpconn.c
@@ -56,9 +56,9 @@
#include <arch/irq.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_udpinput.c b/nuttx/net/uip/uip_udpinput.c
index 839508334..456c34799 100644
--- a/nuttx/net/uip/uip_udpinput.c
+++ b/nuttx/net/uip/uip_udpinput.c
@@ -47,9 +47,9 @@
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_udppoll.c b/nuttx/net/uip/uip_udppoll.c
index 8b80ab178..984566ed4 100644
--- a/nuttx/net/uip/uip_udppoll.c
+++ b/nuttx/net/uip/uip_udppoll.c
@@ -47,9 +47,9 @@
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"
diff --git a/nuttx/net/uip/uip_udpsend.c b/nuttx/net/uip/uip_udpsend.c
index fbdfa89ae..1dc33bbd1 100644
--- a/nuttx/net/uip/uip_udpsend.c
+++ b/nuttx/net/uip/uip_udpsend.c
@@ -46,9 +46,9 @@
#include <debug.h>
-#include <net/uip/uipopt.h>
-#include <net/uip/uip.h>
-#include <net/uip/uip-arch.h>
+#include <nuttx/net/uip/uipopt.h>
+#include <nuttx/net/uip/uip.h>
+#include <nuttx/net/uip/uip-arch.h>
#include "uip_internal.h"