diff options
-rwxr-xr-x | nuttx/COPYING | 109 | ||||
-rw-r--r-- | nuttx/TODO | 13 | ||||
-rw-r--r-- | nuttx/arch/arm/src/c5471/c5471_ethernet.c | 72 | ||||
-rw-r--r-- | nuttx/arch/arm/src/lm3s/lm3s_ethernet.c | 68 | ||||
-rw-r--r-- | nuttx/arch/z80/src/ez80/ez80_emac.c | 70 | ||||
-rw-r--r-- | nuttx/drivers/net/cs89x0.c | 68 | ||||
-rw-r--r-- | nuttx/drivers/net/dm90x0.c | 70 | ||||
-rwxr-xr-x | nuttx/drivers/net/enc28j60.c | 68 | ||||
-rw-r--r-- | nuttx/drivers/net/skeleton.c | 66 | ||||
-rw-r--r-- | nuttx/include/net/uip/uip-arch.h | 4 | ||||
-rw-r--r-- | nuttx/include/net/uip/uip.h | 20 | ||||
-rw-r--r-- | nuttx/net/uip/Make.defs | 2 | ||||
-rw-r--r-- | nuttx/net/uip/uip_arp.c | 4 | ||||
-rwxr-xr-x | nuttx/net/uip/uip_igmpinit.c | 4 | ||||
-rwxr-xr-x | nuttx/net/uip/uip_igmpjoin.c | 2 | ||||
-rwxr-xr-x | nuttx/net/uip/uip_igmpleave.c | 2 | ||||
-rw-r--r-- | nuttx/net/uip/uip_input.c | 2 | ||||
-rw-r--r-- | nuttx/net/uip/uip_internal.h | 5 | ||||
-rwxr-xr-x | nuttx/net/uip/uip_mcastmac.c | 132 |
19 files changed, 718 insertions, 63 deletions
diff --git a/nuttx/COPYING b/nuttx/COPYING index ffcc06ca5..527c82c17 100755 --- a/nuttx/COPYING +++ b/nuttx/COPYING @@ -1,51 +1,70 @@ +COPYING -- Describes the terms under which Nuttx is distributed. A
+copy of the BSD-style licensing is included in this file. In my
+words -- I believe that you should free to use NuttX in any
+environment, private, private, commercial, open, closed, etc.
+provided only that you repect the modest copyright notices as
+described in license (below). Please feel free to contact me if you
+have any licensing concerns.
+
+License for NuttX in general (authorship of individual files may vary):
/*************************************************************************
- * *
- * COPYING -- Describes the terms under which Nuttx is distributed. A *
- * copy of the BSD-style licensing is included in this file. In my *
- * words -- I believe that you should free to use NuttX in any *
- * environment, private, private, commercial, open, closed, etc. *
- * provided only that you repect the modest copyright notices as *
- * described in license (below). Please feel free to contact me if you *
- * have any licensing concerns. *
- * *
- *************************************************************************
- * *
- * Copyright (C) 2007, 2008 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: *
- * *
- * 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. *
- * *
+ *
+ * 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:
+ *
+ * 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.
+ *
*************************************************************************/
-If you enable floating point conversions with CONFIG_LIBC_FLOATINGPOINT,
-then some files with an unmodified BSD license will be included. That
-license is similar to the above (modified) BSD license, but has an
-additional requirement that I state the following:
+Some networking components of NuttX derive from uIP which has a similar
+BSD style license:
+
+ Copyright (c) 2001-2003, Adam Dunkels.
+ All rights reserved.
+
+IGMP support, if enabled in uIP, adds additional logic by Steve Reynolds:
+
+ Copyright (c) 2002 CITEL Technologies Ltd.
+ All rights reserved.
+
+Certain functions in the NuttX C-library derive from other BSD-compatible
+sources:
+
+strtod():
+
+ Copyright (C) 2002 Michael Ringgaard. All rights reserved.
+ Copyright (C) 2006-2007 H. Peter Anvin.
+
+dtoa():
+ If you enable floating point conversions with CONFIG_LIBC_FLOATINGPOINT,
+ then some files with an unmodified BSD license will be included. That
+ license is similar to the above (modified) BSD license, but has an
+ additional requirement that I state the following:
"This product includes software developed by the University of
California, Berkeley and its contributors."
diff --git a/nuttx/TODO b/nuttx/TODO index 4fbfeee94..b329fe153 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -1,5 +1,5 @@ -NuttX TODO List (Last updated May 19, 2010) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +NuttX TODO List (Last updated July 11, 2010) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (5) Task/Scheduler (sched/) (2) Memory Managment (mm/) @@ -7,7 +7,7 @@ NuttX TODO List (Last updated May 19, 2010) (1) pthreads (sched/) (1) C++ Support (5) Binary loaders (binfmt/) - (15) Network (net/, drivers/net) + (16) Network (net/, drivers/net) (5) Network Utilities (netutils/) (1) USB (drivers/usbdev) (5) Libraries (lib/) @@ -256,6 +256,13 @@ o Network (net/, drivers/net) Status: Open Priority: Low unless you need it. + Description: Support for client-side IGMPv2 multicast has been added but not yet + tested (because I don't have a proper environment for multicast testing). + In addition, an ethernet driver that needs to work with the IGMP logic + will have to include additional support for multicast MAC address tables. + Status: Open + Priority: Low unless you need it. + o Network Utilities (netutils/) Description: One critical part of netutils/ apps is untested: The uIP diff --git a/nuttx/arch/arm/src/c5471/c5471_ethernet.c b/nuttx/arch/arm/src/c5471/c5471_ethernet.c index 25fa3cba1..fe18a9ace 100644 --- a/nuttx/arch/arm/src/c5471/c5471_ethernet.c +++ b/nuttx/arch/arm/src/c5471/c5471_ethernet.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/c5471/c5471_ethernet.c * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Based one a C5471 Linux driver and released under this BSD license with @@ -394,6 +394,10 @@ static void c5471_txtimeout(int argc, uint32_t arg, ...); static int c5471_ifup(struct uip_driver_s *dev); static int c5471_ifdown(struct uip_driver_s *dev); static int c5471_txavail(struct uip_driver_s *dev); +#ifdef CONFIG_NET_IGMP +static int c5471_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +static int c5471_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +#endif /* Initialization functions */ @@ -1735,6 +1739,66 @@ static int c5471_txavail(struct uip_driver_s *dev) } /**************************************************************************** + * Function: c5471_addmac + * + * Description: + * NuttX Callback: Add the specified MAC address to the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be added + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int c5471_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct c5471_driver_s *priv = (FAR struct c5471_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** + * Function: c5471_rmmac + * + * Description: + * NuttX Callback: Remove the specified MAC address from the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be removed + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int c5471_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct c5471_driver_s *priv = (FAR struct c5471_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** * Name: c5471_eimreset * * Description @@ -2094,7 +2158,11 @@ void up_netinitialize(void) g_c5471[0].c_dev.d_ifup = c5471_ifup; /* I/F down callback */ g_c5471[0].c_dev.d_ifdown = c5471_ifdown; /* I/F up (new IP address) callback */ g_c5471[0].c_dev.d_txavail = c5471_txavail; /* New TX data callback */ - g_c5471[0].c_dev.d_private = (void*)g_c5471; /* Used to recover private state from dev */ + #ifdef CONFIG_NET_IGMP + g_c5471[0].c_dev.d_addmac = c5471_addmac; /* Add multicast MAC address */ + g_c5471[0].c_dev.d_rmmac = c5471_rmmac; /* Remove multicast MAC address */ +#endif + g_c5471[0].c_dev.d_private = (void*)g_c5471; /* Used to recover private state from dev */ /* Create a watchdog for timing polling for and timing of transmisstions */ diff --git a/nuttx/arch/arm/src/lm3s/lm3s_ethernet.c b/nuttx/arch/arm/src/lm3s/lm3s_ethernet.c index 8751a8537..1dee89e79 100644 --- a/nuttx/arch/arm/src/lm3s/lm3s_ethernet.c +++ b/nuttx/arch/arm/src/lm3s/lm3s_ethernet.c @@ -254,6 +254,10 @@ static void lm3s_txtimeout(int argc, uint32_t arg, ...); static int lm3s_ifup(struct uip_driver_s *dev); static int lm3s_ifdown(struct uip_driver_s *dev); static int lm3s_txavail(struct uip_driver_s *dev); +#ifdef CONFIG_NET_IGMP +static int lm3s_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +static int lm3s_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +#endif /**************************************************************************** * Private Functions @@ -1282,6 +1286,66 @@ static int lm3s_txavail(struct uip_driver_s *dev) } /**************************************************************************** + * Function: lm3s_addmac + * + * Description: + * NuttX Callback: Add the specified MAC address to the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be added + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int lm3s_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct lm3s_driver_s *priv = (FAR struct lm3s_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** + * Function: lm3s_rmmac + * + * Description: + * NuttX Callback: Remove the specified MAC address from the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be removed + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int lm3s_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct lm3s_driver_s *priv = (FAR struct lm3s_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** * Public Functions ****************************************************************************/ @@ -1327,6 +1391,10 @@ static inline int lm3s_ethinitialize(int intf) priv->ld_dev.d_ifup = lm3s_ifup; /* I/F down callback */ priv->ld_dev.d_ifdown = lm3s_ifdown; /* I/F up (new IP address) callback */ priv->ld_dev.d_txavail = lm3s_txavail; /* New TX data callback */ +#ifdef CONFIG_NET_IGMP + priv->ld_dev.d_addmac = lm3s_addmac; /* Add multicast MAC address */ + priv->ld_dev.d_rmmac = lm3s_rmmac; /* Remove multicast MAC address */ +#endif priv->ld_dev.d_private = (void*)priv; /* Used to recover private state from dev */ /* Create a watchdog for timing polling for and timing of transmisstions */ diff --git a/nuttx/arch/z80/src/ez80/ez80_emac.c b/nuttx/arch/z80/src/ez80/ez80_emac.c index 75b96a6be..a8db36a67 100644 --- a/nuttx/arch/z80/src/ez80/ez80_emac.c +++ b/nuttx/arch/z80/src/ez80/ez80_emac.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/net/ez80_emac.c * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * References: @@ -377,6 +377,10 @@ static void ez80emac_txtimeout(int argc, uint32_t arg, ...); static int ez80emac_ifup(struct uip_driver_s *dev); static int ez80emac_ifdown(struct uip_driver_s *dev); static int ez80emac_txavail(struct uip_driver_s *dev); +#ifdef CONFIG_NET_IGMP +static int ez80emac_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +static int ez80emac_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +#endif /* Initialization */ @@ -1795,6 +1799,66 @@ static int ez80emac_txavail(struct uip_driver_s *dev) } /**************************************************************************** + * Function: ez80emac_addmac + * + * Description: + * NuttX Callback: Add the specified MAC address to the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be added + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int ez80emac_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** + * Function: ez80emac_rmmac + * + * Description: + * NuttX Callback: Remove the specified MAC address from the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be removed + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int ez80emac_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct ez80emac_driver_s *priv = (FAR struct ez80emac_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** * Function: ez80emac_initialize * * Description: @@ -2069,6 +2133,10 @@ int up_netinitialize(void) priv->dev.d_ifup = ez80emac_ifup; /* I/F down callback */ priv->dev.d_ifdown = ez80emac_ifdown; /* I/F up (new IP address) callback */ priv->dev.d_txavail = ez80emac_txavail; /* New TX data callback */ +#ifdef CONFIG_NET_IGMP + priv->dev.d_addmac = ez80emac_addmac; /* Add multicast MAC address */ + priv->dev.d_rmmac = ez80emac_rmmac; /* Remove multicast MAC address */ +#endif priv->dev.d_private = (FAR void*)&g_emac; /* Used to recover private state from dev */ /* Create a watchdog for timing polling for and timing of transmisstions */ diff --git a/nuttx/drivers/net/cs89x0.c b/nuttx/drivers/net/cs89x0.c index fc8a60729..89ecca76c 100644 --- a/nuttx/drivers/net/cs89x0.c +++ b/nuttx/drivers/net/cs89x0.c @@ -137,6 +137,10 @@ static void cs89x0_txtimeout(int argc, uint32_t arg, ...); static int cs89x0_ifup(struct uip_driver_s *dev); static int cs89x0_ifdown(struct uip_driver_s *dev); static int cs89x0_txavail(struct uip_driver_s *dev); +#ifdef CONFIG_NET_IGMP +static int cs89x0_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +static int cs89x0_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +#endif /**************************************************************************** * Private Functions @@ -815,6 +819,66 @@ static int cs89x0_txavail(struct uip_driver_s *dev) } /**************************************************************************** + * Function: cs89x0_addmac + * + * Description: + * NuttX Callback: Add the specified MAC address to the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be added + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int cs89x0_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct cs89x0_driver_s *priv = (FAR struct cs89x0_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** + * Function: cs89x0_rmmac + * + * Description: + * NuttX Callback: Remove the specified MAC address from the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be removed + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int cs89x0_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct cs89x0_driver_s *priv = (FAR struct cs89x0_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** * Public Functions ****************************************************************************/ @@ -872,6 +936,10 @@ int cs89x0_initialize(FAR const cs89x0_driver_s *cs89x0, int devno) cs89x0->cs_dev.d_ifup = cs89x0_ifup; /* I/F down callback */ cs89x0->cs_dev.d_ifdown = cs89x0_ifdown; /* I/F up (new IP address) callback */ cs89x0->cs_dev.d_txavail = cs89x0_txavail; /* New TX data callback */ +#ifdef CONFIG_NET_IGMP + cs89x0->cs_dev.d_addmac = cs89x0_addmac; /* Add multicast MAC address */ + cs89x0->cs_dev.d_rmmac = cs89x0_rmmac; /* Remove multicast MAC address */ +#endif cs89x0->cs_dev.d_private = (void*)cs89x0; /* Used to recover private state from dev */ /* Create a watchdog for timing polling for and timing of transmisstions */ diff --git a/nuttx/drivers/net/dm90x0.c b/nuttx/drivers/net/dm90x0.c index cec1e230c..d9973e77d 100644 --- a/nuttx/drivers/net/dm90x0.c +++ b/nuttx/drivers/net/dm90x0.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/net/dm9x.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> * * References: Davicom data sheets (DM9000-DS-F03-041906.pdf, @@ -398,6 +398,10 @@ static void dm9x_txtimeout(int argc, uint32_t arg, ...); static int dm9x_ifup(struct uip_driver_s *dev); static int dm9x_ifdown(struct uip_driver_s *dev); static int dm9x_txavail(struct uip_driver_s *dev); +#ifdef CONFIG_NET_IGMP +static int dm9x_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +static int dm9x_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +#endif /* Initialization functions */ @@ -1507,6 +1511,66 @@ static int dm9x_txavail(struct uip_driver_s *dev) } /**************************************************************************** + * Function: dm9x_addmac + * + * Description: + * NuttX Callback: Add the specified MAC address to the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be added + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int dm9x_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** + * Function: dm9x_rmmac + * + * Description: + * NuttX Callback: Remove the specified MAC address from the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be removed + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int dm9x_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct dm9x_driver_s *priv = (FAR struct dm9x_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** * Function: dm9x_bringup * * Description: @@ -1719,6 +1783,10 @@ int dm9x_initialize(void) g_dm9x[0].dm_dev.d_ifup = dm9x_ifup; /* I/F down callback */ g_dm9x[0].dm_dev.d_ifdown = dm9x_ifdown; /* I/F up (new IP address) callback */ g_dm9x[0].dm_dev.d_txavail = dm9x_txavail; /* New TX data callback */ +#ifdef CONFIG_NET_IGMP + g_dm9x[0].dm_dev.d_addmac = dm9x_addmac; /* Add multicast MAC address */ + g_dm9x[0].dm_dev.d_rmmac = dm9x_rmmac; /* Remove multicast MAC address */ +#endif g_dm9x[0].dm_dev.d_private = (void*)g_dm9x; /* Used to recover private state from dev */ /* Create a watchdog for timing polling for and timing of transmisstions */ diff --git a/nuttx/drivers/net/enc28j60.c b/nuttx/drivers/net/enc28j60.c index 1db44cef1..b2dcf5658 100755 --- a/nuttx/drivers/net/enc28j60.c +++ b/nuttx/drivers/net/enc28j60.c @@ -278,6 +278,10 @@ static void enc_txtimeout(int argc, uint32_t arg, ...); static int enc_ifup(struct uip_driver_s *dev); static int enc_ifdown(struct uip_driver_s *dev); static int enc_txavail(struct uip_driver_s *dev); +#ifdef CONFIG_NET_IGMP +static int enc_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +static int enc_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +#endif /* Initialization */ @@ -1755,6 +1759,66 @@ static int enc_txavail(struct uip_driver_s *dev) } /**************************************************************************** + * Function: enc_addmac + * + * Description: + * NuttX Callback: Add the specified MAC address to the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be added + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int enc_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** + * Function: enc_rmmac + * + * Description: + * NuttX Callback: Remove the specified MAC address from the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be removed + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int enc_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + +#warning "Multicast MAC support not implemented" + return OK; +} +#endif + +/**************************************************************************** * Function: enc_pwrsave * * Description: @@ -2079,6 +2143,10 @@ int enc_initialize(FAR struct spi_dev_s *spi, unsigned int devno, unsigned int i priv->dev.d_ifup = enc_ifup; /* I/F down callback */ priv->dev.d_ifdown = enc_ifdown; /* I/F up (new IP address) callback */ priv->dev.d_txavail = enc_txavail; /* New TX data callback */ +#ifdef CONFIG_NET_IGMP + priv->dev.d_addmac = enc_addmac; /* Add multicast MAC address */ + priv->dev.d_rmmac = enc_rmmac; /* Remove multicast MAC address */ +#endif priv->dev.d_private = priv; /* Used to recover private state from dev */ /* Create a watchdog for timing polling for and timing of transmisstions */ diff --git a/nuttx/drivers/net/skeleton.c b/nuttx/drivers/net/skeleton.c index f94799ba8..032df2619 100644 --- a/nuttx/drivers/net/skeleton.c +++ b/nuttx/drivers/net/skeleton.c @@ -130,6 +130,10 @@ static void skel_txtimeout(int argc, uint32_t arg, ...); static int skel_ifup(struct uip_driver_s *dev); static int skel_ifdown(struct uip_driver_s *dev); static int skel_txavail(struct uip_driver_s *dev); +#ifdef CONFIG_NET_IGMP +static int skel_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +static int skel_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac); +#endif /**************************************************************************** * Private Functions @@ -543,6 +547,64 @@ static int skel_txavail(struct uip_driver_s *dev) } /**************************************************************************** + * Function: skel_addmac + * + * Description: + * NuttX Callback: Add the specified MAC address to the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be added + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int skel_addmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct skel_driver_s *skel = (FAR struct skel_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + + return OK; +} +#endif + +/**************************************************************************** + * Function: skel_rmmac + * + * Description: + * NuttX Callback: Remove the specified MAC address from the hardware multicast + * address filtering + * + * Parameters: + * dev - Reference to the NuttX driver state structure + * mac - The MAC address to be removed + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IGMP +static int skel_rmmac(struct uip_driver_s *dev, FAR const uint8_t *mac) +{ + FAR struct skel_driver_s *skel = (FAR struct skel_driver_s *)dev->d_private; + + /* Add the MAC address to the hardware multicast routing table */ + + return OK; +} +#endif + +/**************************************************************************** * Public Functions ****************************************************************************/ @@ -583,6 +645,10 @@ int skel_initialize(void) g_skel[0].sk_dev.d_ifup = skel_ifup; /* I/F down callback */ g_skel[0].sk_dev.d_ifdown = skel_ifdown; /* I/F up (new IP address) callback */ g_skel[0].sk_dev.d_txavail = skel_txavail; /* New TX data callback */ +#ifdef CONFIG_NET_IGMP + g_skel[0].sk_dev.d_addmac = skel_addmac; /* Add multicast MAC address */ + g_skel[0].sk_dev.d_rmmac = skel_rmmac; /* Remove multicast MAC address */ +#endif g_skel[0].sk_dev.d_private = (void*)g_skel; /* Used to recover private state from dev */ /* Create a watchdog for timing polling for and timing of transmisstions */ diff --git a/nuttx/include/net/uip/uip-arch.h b/nuttx/include/net/uip/uip-arch.h index 939c60450..c7e8687c1 100644 --- a/nuttx/include/net/uip/uip-arch.h +++ b/nuttx/include/net/uip/uip-arch.h @@ -184,6 +184,10 @@ struct uip_driver_s int (*d_ifup)(struct uip_driver_s *dev); int (*d_ifdown)(struct uip_driver_s *dev); int (*d_txavail)(struct uip_driver_s *dev); +#ifdef CONFIG_NET_IGMP + int (*d_addmac)(struct uip_driver_s *dev, FAR const uint8_t *mac); + int (*d_rmmac)(struct uip_driver_s *dev, FAR const uint8_t *mac); +#endif /* Drivers may attached device-specific, private information */ diff --git a/nuttx/include/net/uip/uip.h b/nuttx/include/net/uip/uip.h index 3633a42a8..fd9373666 100644 --- a/nuttx/include/net/uip/uip.h +++ b/nuttx/include/net/uip/uip.h @@ -5,7 +5,7 @@ * are used by uIP programs as well as internal uIP structures and function * declarations. * - * 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> * * This logic was leveraged from uIP which also has a BSD-style license: @@ -370,6 +370,24 @@ extern void uip_send(struct uip_driver_s *dev, const void *buf, int len); # define uip_ip4addr_conv(addr) (((in_addr_t)((uint16_t*)addr)[1] << 16) | (in_addr_t)((uint16_t*)addr)[0]) #endif +/* Extract individual bytes from a 32-bit IPv4 IP address that is in network byte order */ + +#ifdef CONFIG_ENDIAN_BIG + /* Big-endian byte order: 11223344 */ + +# define ip4_addr1(ipaddr) (((ipaddr) >> 24) & 0xff) +# define ip4_addr2(ipaddr) (((ipaddr) >> 16) & 0xff) +# define ip4_addr3(ipaddr) (((ipaddr) >> 8) & 0xff) +# define ip4_addr4(ipaddr) ((ipaddr) & 0xff) +#else + /* Little endian byte order: 44223311 */ + +# define ip4_addr1(ipaddr) ((ipaddr) & 0xff) +# define ip4_addr2(ipaddr) (((ipaddr) >> 8) & 0xff) +# define ip4_addr3(ipaddr) (((ipaddr) >> 16) & 0xff) +# define ip4_addr4(ipaddr) (((ipaddr) >> 24) & 0xff) +#endif + /* Construct an IPv6 address from eight 16-bit words. * * This function constructs an IPv6 address. diff --git a/nuttx/net/uip/Make.defs b/nuttx/net/uip/Make.defs index f113ec3a7..ec0b06fb8 100644 --- a/nuttx/net/uip/Make.defs +++ b/nuttx/net/uip/Make.defs @@ -82,7 +82,7 @@ endif ifeq ($(CONFIG_NET_IGMP),y) UIP_CSRCS += uip_igmpinit.c uip_igmpgroup.c uip_igmpinput.c uip_igmpjoin.c \ - uip_igmpleave.c uip_igmpmsg.c uip_igmptimer.c + uip_igmpleave.c uip_igmpmsg.c uip_igmptimer.c uip_mcastmac.c endif endif diff --git a/nuttx/net/uip/uip_arp.c b/nuttx/net/uip/uip_arp.c index 6073f252c..b0e3e3fe7 100644 --- a/nuttx/net/uip/uip_arp.c +++ b/nuttx/net/uip/uip_arp.c @@ -140,7 +140,7 @@ static const uint16_t g_broadcast_ipaddr[2] = {0xffff, 0xffff}; * The following is the first three octects of the IGMP address: */ -#if defined(CONFIG_NET_MULTICAST) && !defined(CONFIG_NET_IPv6) +#if defined(CONFIG_NET_IGMP) && !defined(CONFIG_NET_IPv6) static const uint8_t g_multicast_ethaddr[3] = {0x01, 0x00, 0x5e}; #endif @@ -306,7 +306,7 @@ void uip_arp_out(struct uip_driver_s *dev) { memcpy(peth->dest, g_broadcast_ethaddr.ether_addr_octet, ETHER_ADDR_LEN); } -#if defined(CONFIG_NET_MULTICAST) && !defined(CONFIG_NET_IPv6) +#if defined(CONFIG_NET_IGMP) && !defined(CONFIG_NET_IPv6) /* Check if the destination address is a multicast address * * - IPv4: multicast addresses lie in the class D group -- The address range diff --git a/nuttx/net/uip/uip_igmpinit.c b/nuttx/net/uip/uip_igmpinit.c index 5c1dbdc68..c3c379904 100755 --- a/nuttx/net/uip/uip_igmpinit.c +++ b/nuttx/net/uip/uip_igmpinit.c @@ -119,8 +119,8 @@ void uip_igmpdevinit(struct uip_driver_s *dev) /* Allow the IGMP messages at the MAC level */
- uip_igmpmac(dev, &g_allrouters, true);
- uip_igmpmac(dev, &g_allsystems, true);
+ uip_addmcastmac(dev, &g_allrouters);
+ uip_addmcastmac(dev, &g_allsystems);
}
#endif /* CONFIG_NET_IGMP */
diff --git a/nuttx/net/uip/uip_igmpjoin.c b/nuttx/net/uip/uip_igmpjoin.c index 3f0224a92..b644cad10 100755 --- a/nuttx/net/uip/uip_igmpjoin.c +++ b/nuttx/net/uip/uip_igmpjoin.c @@ -146,7 +146,7 @@ void igmp_joingroup(struct uip_driver_s *dev, uip_ipaddr_t *grpaddr) /* Add the group (MAC) address to the ether drivers MAC filter list */
- uip_igmpmac(dev, grpaddr, true);
+ uip_addmcastmac(dev, grpaddr);
}
}
diff --git a/nuttx/net/uip/uip_igmpleave.c b/nuttx/net/uip/uip_igmpleave.c index a220662fd..a482c5c4a 100755 --- a/nuttx/net/uip/uip_igmpleave.c +++ b/nuttx/net/uip/uip_igmpleave.c @@ -166,7 +166,7 @@ void igmp_leavegroup(struct uip_driver_s *dev, uip_ipaddr_t *grpaddr) /* And remove the group address from the ethernet drivers MAC filter set */
- uip_igmpmac(dev, grpaddr, false);
+ uip_removemcastmac(dev, grpaddr);
}
}
diff --git a/nuttx/net/uip/uip_input.c b/nuttx/net/uip/uip_input.c index 6a8963f38..05fc358be 100644 --- a/nuttx/net/uip/uip_input.c +++ b/nuttx/net/uip/uip_input.c @@ -434,7 +434,7 @@ void uip_input(struct uip_driver_s *dev) } } - /* Check if the pack is destined for out IP address */ + /* Check if the packet is destined for out IP address */ else #endif { diff --git a/nuttx/net/uip/uip_internal.h b/nuttx/net/uip/uip_internal.h index 49ab4ea24..cfa9da85d 100644 --- a/nuttx/net/uip/uip_internal.h +++ b/nuttx/net/uip/uip_internal.h @@ -250,9 +250,10 @@ EXTERN void uip_igmpstartticks(FAR struct igmp_group_s *group, int ticks); EXTERN void uip_igmpstarttimer(FAR struct igmp_group_s *group, uint8_t decisecs); EXTERN bool uip_igmpcmptimer(FAR struct igmp_group_s *group, int maxticks); -/* Defined in TBD ************************************************************/ +/* Defined in uip_mcastmac ***************************************************/ -EXTERN void uip_igmpmac(struct uip_driver_s *dev, uip_ipaddr_t *ip, bool on); +EXTERN void uip_addmcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip); +EXTERN void uip_removemcastmac(FAR struct uip_driver_s *dev, FAR uip_ipaddr_t *ip); #endif /* CONFIG_NET_IGMP */ diff --git a/nuttx/net/uip/uip_mcastmac.c b/nuttx/net/uip/uip_mcastmac.c new file mode 100755 index 000000000..be0e21513 --- /dev/null +++ b/nuttx/net/uip/uip_mcastmac.c @@ -0,0 +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: %04x -> MAC: %02%02%02%02%02%02\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 %04x\n");
+ 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 %04x\n");
+ if (dev->d_rmmac)
+ {
+ uip_mcastmac(ip, mcastmac);
+ dev->d_rmmac(dev, mcastmac);
+ }
+}
+
+#endif /* CONFIG_NET_IGMP */
|