Move IPv6 files from net/uip to net/ipv6

This commit is contained in:
Gregory Nutt 2014-06-28 17:42:34 -06:00
parent 1341296b82
commit 3451ce2996
7 changed files with 139 additions and 52 deletions

View File

@ -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"

11
net/ipv6/Kconfig Normal file
View File

@ -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.

46
net/ipv6/Make.defs Normal file
View File

@ -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

View File

@ -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 __UIP_NEIGHBOR_H__
#define __UIP_NEIGHBOR_H__
#ifndef __NET_IPV6_IPV6_H
#define __NET_IPV6_IPV6_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__ */

View File

@ -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));
memcpy(&entries[oldest].addr, addr, sizeof(struct net_neighbor_addr_s));
}
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;
}
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;

View File

@ -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

View File

@ -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"