diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-06-28 17:42:34 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-06-28 17:42:34 -0600 |
commit | f21061b3a2a2477560871a5198adcb5bf7540e67 (patch) | |
tree | 7bf689b5a15e5890ba20447cd559bb1431ae2367 | |
parent | 3a564cf05163e17dc6f09f7646920515fb1d4cc2 (diff) | |
download | nuttx-f21061b3a2a2477560871a5198adcb5bf7540e67.tar.gz nuttx-f21061b3a2a2477560871a5198adcb5bf7540e67.tar.bz2 nuttx-f21061b3a2a2477560871a5198adcb5bf7540e67.zip |
Move IPv6 files from net/uip to net/ipv6
-rw-r--r-- | nuttx/net/Kconfig | 8 | ||||
-rw-r--r-- | nuttx/net/ipv6/Kconfig | 11 | ||||
-rw-r--r-- | nuttx/net/ipv6/Make.defs | 46 | ||||
-rw-r--r-- | nuttx/net/ipv6/ipv6.h (renamed from nuttx/net/uip/uip_neighbor.h) | 34 | ||||
-rw-r--r-- | nuttx/net/ipv6/net_neighbor.c (renamed from nuttx/net/uip/uip_neighbor.c) | 84 | ||||
-rw-r--r-- | nuttx/net/uip/Make.defs | 6 | ||||
-rw-r--r-- | nuttx/net/uip/uip_input.c | 2 |
7 files changed, 139 insertions, 52 deletions
diff --git a/nuttx/net/Kconfig b/nuttx/net/Kconfig index 5b627ab04..c303146ba 100644 --- a/nuttx/net/Kconfig +++ b/nuttx/net/Kconfig @@ -47,13 +47,6 @@ config NET_PROMISCUOUS Force the Ethernet driver to operate in promiscuous mode (if supported by the Ethernet driver). -config NET_IPv6 - bool "IPv6" - default n - depends on EXPERIMENTAL - ---help--- - Build in support for IPv6. Not fully implemented. - config NET_BUFSIZE int "Network packet buffer size (MTU)" default 1294 if !NET_SLIP && NET_IPv6 @@ -97,6 +90,7 @@ config NET_GUARDSIZE source "net/socket/Kconfig" source "net/netdev/Kconfig" +source "net/ipv6/Kconfig" source "net/pkt/Kconfig" source "net/tcp/Kconfig" source "net/udp/Kconfig" diff --git a/nuttx/net/ipv6/Kconfig b/nuttx/net/ipv6/Kconfig new file mode 100644 index 000000000..369344afc --- /dev/null +++ b/nuttx/net/ipv6/Kconfig @@ -0,0 +1,11 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config NET_IPv6 + bool "IPv6" + default n + depends on EXPERIMENTAL + ---help--- + Build in support for IPv6. Not fully implemented. diff --git a/nuttx/net/ipv6/Make.defs b/nuttx/net/ipv6/Make.defs new file mode 100644 index 000000000..de5562267 --- /dev/null +++ b/nuttx/net/ipv6/Make.defs @@ -0,0 +1,46 @@ +############################################################################ +# net/utils/Make.defs +# +# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt <gnutt@nuttx.org> +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +# IPv6-specific logic + +ifeq ($(CONFIG_NET_IPv6),y) + +NET_CSRCS += net_neighbor.c + +# Include utility build support + +DEPPATH += --dep-path ipv6 +VPATH += :ipv6 +endif diff --git a/nuttx/net/uip/uip_neighbor.h b/nuttx/net/ipv6/ipv6.h index 455610d02..9d1b13472 100644 --- a/nuttx/net/uip/uip_neighbor.h +++ b/nuttx/net/ipv6/ipv6.h @@ -1,4 +1,5 @@ -/* net/uip/uip_neighbor.h +/**************************************************************************** + * net/ipv6/ipv6.h * Header file for database of link-local neighbors, used by IPv6 code and * to be used by future ARP code. * @@ -34,16 +35,25 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - */ + * + ****************************************************************************/ + +#ifndef __NET_IPV6_IPV6_H +#define __NET_IPV6_IPV6_H -#ifndef __UIP_NEIGHBOR_H__ -#define __UIP_NEIGHBOR_H__ +/**************************************************************************** + * Included Files + ****************************************************************************/ #include <stdint.h> #include <nuttx/net/uip.h> #include <net/ethernet.h> -struct uip_neighbor_addr +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct net_neighbor_addr_s { #if UIP_NEIGHBOR_CONF_ADDRTYPE UIP_NEIGHBOR_CONF_ADDRTYPE addr; @@ -52,10 +62,14 @@ struct uip_neighbor_addr #endif }; -void uip_neighbor_init(void); -void uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr); -void uip_neighbor_update(uip_ipaddr_t ipaddr); -struct uip_neighbor_addr *uip_neighbor_lookup(uip_ipaddr_t ipaddr); -void uip_neighbor_periodic(void); +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +void net_neighbor_init(void); +void net_neighbor_add(uip_ipaddr_t ipaddr, struct net_neighbor_addr_s *addr); +void net_neighbor_update(uip_ipaddr_t ipaddr); +struct net_neighbor_addr_s *net_neighbor_lookup(uip_ipaddr_t ipaddr); +void net_neighbor_periodic(void); #endif /* __UIP-NEIGHBOR_H__ */ diff --git a/nuttx/net/uip/uip_neighbor.c b/nuttx/net/ipv6/net_neighbor.c index 0dbb001dd..4de284af9 100644 --- a/nuttx/net/uip/uip_neighbor.c +++ b/nuttx/net/ipv6/net_neighbor.c @@ -1,5 +1,5 @@ -/* - * uip_neighbor.c +/**************************************************************************** + * net/ipv6/net_neighbor.c * Database of link-local neighbors, used by IPv6 code and to be used by * a future ARP code rewrite. * @@ -31,30 +31,73 @@ * 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 <string.h> #include <debug.h> -#include "uip_neighbor.h" +#include "ipv6/ipv6.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ #define MAX_TIME 128 #ifdef UIP_NEIGHBOR_CONF_ENTRIES -#define ENTRIES UIP_NEIGHBOR_CONF_ENTRIES +# define ENTRIES UIP_NEIGHBOR_CONF_ENTRIES #else /* UIP_NEIGHBOR_CONF_ENTRIES */ -#define ENTRIES 8 +# define ENTRIES 8 #endif /* UIP_NEIGHBOR_CONF_ENTRIES */ +/**************************************************************************** + * Private Types + ****************************************************************************/ + struct neighbor_entry { uip_ipaddr_t ipaddr; - struct uip_neighbor_addr addr; + struct net_neighbor_addr_s addr; uint8_t time; }; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + static struct neighbor_entry entries[ENTRIES]; -void uip_neighbor_init(void) +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static struct neighbor_entry *find_entry(uip_ipaddr_t ipaddr) +{ + int i; + + for (i = 0; i < ENTRIES; ++i) + { + if (uip_ipaddr_cmp(entries[i].ipaddr, ipaddr)) + { + return &entries[i]; + } + } + + return NULL; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void net_neighbor_init(void) { int i; @@ -64,7 +107,7 @@ void uip_neighbor_init(void) } } -void uip_neighbor_periodic(void) +void net_neighbor_periodic(void) { int i; @@ -77,7 +120,7 @@ void uip_neighbor_periodic(void) } } -void uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr) +void net_neighbor_add(uip_ipaddr_t ipaddr, struct net_neighbor_addr_s *addr) { uint8_t oldest_time; int oldest; @@ -118,25 +161,10 @@ void uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr) entries[oldest].time = 0; uip_ipaddr_copy(entries[oldest].ipaddr, ipaddr); - memcpy(&entries[oldest].addr, addr, sizeof(struct uip_neighbor_addr)); -} - -static struct neighbor_entry *find_entry(uip_ipaddr_t ipaddr) -{ - int i; - - for (i = 0; i < ENTRIES; ++i) - { - if (uip_ipaddr_cmp(entries[i].ipaddr, ipaddr)) - { - return &entries[i]; - } - } - - return NULL; + memcpy(&entries[oldest].addr, addr, sizeof(struct net_neighbor_addr_s)); } -void uip_neighbor_update(uip_ipaddr_t ipaddr) +void net_neighbor_update(uip_ipaddr_t ipaddr) { struct neighbor_entry *e; @@ -147,7 +175,7 @@ void uip_neighbor_update(uip_ipaddr_t ipaddr) } } -struct uip_neighbor_addr *uip_neighbor_lookup(uip_ipaddr_t ipaddr) +struct net_neighbor_addr_s *net_neighbor_lookup(uip_ipaddr_t ipaddr) { struct neighbor_entry *e; diff --git a/nuttx/net/uip/Make.defs b/nuttx/net/uip/Make.defs index cb65bc94b..fac4c0d5d 100644 --- a/nuttx/net/uip/Make.defs +++ b/nuttx/net/uip/Make.defs @@ -50,12 +50,6 @@ ifeq ($(CONFIG_NET_PKT),y) NET_CSRCS += uip_pktsend.c endif -# IPv6-specific logic - -ifeq ($(CONFIG_NET_IPv6),y) -NET_CSRCS += uip_neighbor.c -endif - # Include uip build support DEPPATH += --dep-path uip diff --git a/nuttx/net/uip/uip_input.c b/nuttx/net/uip/uip_input.c index 190b3647c..bab44aaa0 100644 --- a/nuttx/net/uip/uip_input.c +++ b/nuttx/net/uip/uip_input.c @@ -91,7 +91,7 @@ #include <nuttx/net/netstats.h> #ifdef CONFIG_NET_IPv6 -# include "uip_neighbor.h" +# include "net_neighbor.h" #endif /* CONFIG_NET_IPv6 */ #include "uip/uip.h" |