forked from nuttx/nuttx-update
Addes support for read-only routing tables. Prior to this change, routing tables were only support in RAM and had to be initialized with explicit logic to add the necessary routes to the routing table. With this change, routes may be defined in the pre-initialized, read-only routing table provided by the board-specific logic
This would be particularly useful, for example, in the case where there is only a single network adaptor and you want all output packets to go to the single adaptor in all cases. So for that behavior you could add a read-only routing table to the board-specific long that contains a single entry, the default route: 0.0.0.0/0. Squashed commit of the following: net/route: RAM and ROM routing tables build correctly in all IPv4 and IPv6 configurations. net/route: Verify IPv6 ROM route build; Make number of ROM routes a variable, not a configuration item. net/route: Add initial support for ROM-base, read-only routing tables. net/route: Adjust and generalize some structures, rename some functions, and add configuration and build support that will eventually support read-only routing tables. net/route: Some initial though experiments on use of a fixe, read-only routing table
This commit is contained in:
parent
cc6b1275f9
commit
3aa18ef56e
15 changed files with 955 additions and 194 deletions
|
@ -73,4 +73,3 @@ FAR sq_entry_t *sq_remafter(FAR sq_entry_t *node, sq_queue_t *queue)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ void net_setup(void)
|
|||
#ifdef CONFIG_NET_ROUTE
|
||||
/* Initialize the routing table */
|
||||
|
||||
net_initroute();
|
||||
net_init_route();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_USRSOCK
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
@ -91,9 +90,25 @@
|
|||
#include "icmpv6/icmpv6.h"
|
||||
#include "route/route.h"
|
||||
|
||||
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration */
|
||||
|
||||
#undef HAVE_WRITABLE_IPv4ROUTE
|
||||
#undef HAVE_WRITABLE_IPv6ROUTE
|
||||
|
||||
#ifdef CONFIG_NET_ROUTE
|
||||
# if defined(CONFIG_NET_IPv4) && !defined(CONFIG_ROUTE_IPv4_ROMROUTE)
|
||||
# define HAVE_WRITABLE_IPv4ROUTE 1
|
||||
# endif
|
||||
|
||||
# if defined(CONFIG_NET_IPv6) && !defined(CONFIG_ROUTE_IPv6_ROMROUTE)
|
||||
# define HAVE_WRITABLE_IPv6ROUTE 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This is really kind of bogus.. When asked for an IP address, this is
|
||||
* family that is returned in the ifr structure. Probably could just skip
|
||||
|
@ -121,7 +136,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv4)
|
||||
#ifdef HAVE_WRITABLE_IPv4ROUTE
|
||||
static int ioctl_add_ipv4route(FAR struct rtentry *rtentry)
|
||||
{
|
||||
FAR struct sockaddr_in *addr;
|
||||
|
@ -149,7 +164,7 @@ static int ioctl_add_ipv4route(FAR struct rtentry *rtentry)
|
|||
|
||||
return net_addroute_ipv4(target, netmask, router);
|
||||
}
|
||||
#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv4 */
|
||||
#endif /* HAVE_WRITABLE_IPv4ROUTE */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ioctl_add_ipv6route
|
||||
|
@ -162,7 +177,7 @@ static int ioctl_add_ipv4route(FAR struct rtentry *rtentry)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv6)
|
||||
#ifdef HAVE_WRITABLE_IPv6ROUTE
|
||||
static int ioctl_add_ipv6route(FAR struct rtentry *rtentry)
|
||||
{
|
||||
FAR struct sockaddr_in6 *target;
|
||||
|
@ -187,7 +202,7 @@ static int ioctl_add_ipv6route(FAR struct rtentry *rtentry)
|
|||
|
||||
return net_addroute_ipv6(target->sin6_addr.s6_addr16, netmask->sin6_addr.s6_addr16, router);
|
||||
}
|
||||
#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv6 */
|
||||
#endif /* HAVE_WRITABLE_IPv6ROUTE */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ioctl_del_ipv4route
|
||||
|
@ -200,7 +215,7 @@ static int ioctl_add_ipv6route(FAR struct rtentry *rtentry)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv4)
|
||||
#ifdef HAVE_WRITABLE_IPv4ROUTE
|
||||
static int ioctl_del_ipv4route(FAR struct rtentry *rtentry)
|
||||
{
|
||||
FAR struct sockaddr_in *addr;
|
||||
|
@ -215,7 +230,7 @@ static int ioctl_del_ipv4route(FAR struct rtentry *rtentry)
|
|||
|
||||
return net_delroute_ipv4(target, netmask);
|
||||
}
|
||||
#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv4 */
|
||||
#endif /* HAVE_WRITABLE_IPv4ROUTE */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ioctl_del_ipv6route
|
||||
|
@ -228,7 +243,7 @@ static int ioctl_del_ipv4route(FAR struct rtentry *rtentry)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv6)
|
||||
#ifdef HAVE_WRITABLE_IPv6ROUTE
|
||||
static int ioctl_del_ipv6route(FAR struct rtentry *rtentry)
|
||||
{
|
||||
FAR struct sockaddr_in6 *target;
|
||||
|
@ -239,7 +254,7 @@ static int ioctl_del_ipv6route(FAR struct rtentry *rtentry)
|
|||
|
||||
return net_delroute_ipv6(target->sin6_addr.s6_addr16, netmask->sin6_addr.s6_addr16);
|
||||
}
|
||||
#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv6 */
|
||||
#endif /* HAVE_WRITABLE_IPv6ROUTE */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ioctl_get_ipv4addr
|
||||
|
@ -1223,7 +1238,11 @@ static int netdev_rt_ioctl(FAR struct socket *psock, int cmd,
|
|||
if (rtentry->rt_target->ss_family == AF_INET)
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_WRITABLE_IPv4ROUTE
|
||||
ret = ioctl_add_ipv4route(rtentry);
|
||||
#else
|
||||
ret = -EACCES;
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
|
@ -1232,7 +1251,11 @@ static int netdev_rt_ioctl(FAR struct socket *psock, int cmd,
|
|||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_WRITABLE_IPv6ROUTE
|
||||
ret = ioctl_add_ipv6route(rtentry);
|
||||
#else
|
||||
ret = -EACCES;
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
}
|
||||
|
@ -1252,7 +1275,11 @@ static int netdev_rt_ioctl(FAR struct socket *psock, int cmd,
|
|||
if (rtentry->rt_target->ss_family == AF_INET)
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_WRITABLE_IPv4ROUTE
|
||||
ret = ioctl_del_ipv4route(rtentry);
|
||||
#else
|
||||
ret = -EACCES;
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
|
@ -1261,7 +1288,11 @@ static int netdev_rt_ioctl(FAR struct socket *psock, int cmd,
|
|||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_WRITABLE_IPv6ROUTE
|
||||
ret = ioctl_del_ipv6route(rtentry);
|
||||
#else
|
||||
ret = -EACCES;
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
}
|
||||
|
|
|
@ -14,19 +14,85 @@ config NET_ROUTE
|
|||
|
||||
if NET_ROUTE
|
||||
|
||||
config ROUTE_MAX_IPv4ROUTES
|
||||
int "IPv4 routing table size"
|
||||
default 4
|
||||
choice
|
||||
prompt "IPv4 routing table"
|
||||
default ROUTE_IPv4_RAMROUTE
|
||||
depends on NET_IPv4
|
||||
---help---
|
||||
The size of the IPv4 routing table (in entries).
|
||||
|
||||
config ROUTE_MAX_IPv6ROUTES
|
||||
int "IPv6 routing table size"
|
||||
default 4
|
||||
depends on NET_IPv6
|
||||
config ROUTE_IPv4_RAMROUTE
|
||||
bool "In-memory"
|
||||
---help---
|
||||
The size of the IPv6 routing table (in entries).
|
||||
Select to used a IPv4 routing table RAM.
|
||||
|
||||
config ROUTE_IPv4_ROMROUTE
|
||||
bool "Read-only"
|
||||
---help---
|
||||
Select to used a fixed read-only IPv4 routing table in FLASH or ROM.
|
||||
In this case, the board-specific logic must provide a routing table
|
||||
of the form of a simple array:
|
||||
|
||||
FAR const struct net_route_ipv4_s g_ipv4_routes[];
|
||||
const unsigned int g_ipv4_nroutes;
|
||||
|
||||
NOTE: The read-only variable g_ipv4_nroutes must be set to the
|
||||
actual number of valid entries in the array.
|
||||
|
||||
config NET_ROUTE_IPv4_FILEROUTE
|
||||
bool "File"
|
||||
depends on EXPERIMENTAL
|
||||
---help---
|
||||
Select to used a IPv4 routing table in a file in a mounted file system.
|
||||
|
||||
endchoice # IPv4 routing table
|
||||
|
||||
config ROUTE_MAX_IPv4_RAMROUTES
|
||||
int "Preallocated IPv4 routing table entries"
|
||||
default 4
|
||||
depends on ROUTE_IPv4_RAMROUTE
|
||||
---help---
|
||||
The number of preallocated of the IPv4 routing table entries. This
|
||||
eliminates dynamica memory allocations, but limits the maximum size
|
||||
of the in-memory routing table to this number.
|
||||
|
||||
choice
|
||||
prompt "IPv6 routing table"
|
||||
default ROUTE_IPv6_RAMROUTE
|
||||
depends on NET_IPv6
|
||||
|
||||
config ROUTE_IPv6_RAMROUTE
|
||||
bool "In-memory"
|
||||
---help---
|
||||
Select to used a IPv6 routing table RAM.
|
||||
|
||||
config ROUTE_IPv6_ROMROUTE
|
||||
bool "Read-only"
|
||||
---help---
|
||||
Select to used a fixed read-only IPv6 routing table in FLASH or ROM.
|
||||
In this case, the board-specific logic must provide a routing table
|
||||
of the form of simply array:
|
||||
|
||||
FAR const struct net_route_ipv6_s g_ipv6_routes[];
|
||||
const unsigned int g_ipv6_nroutes;
|
||||
|
||||
NOTE: The read-only variable g_ipv6_nroutes must be set to the
|
||||
actual number of valid entries in the array.
|
||||
|
||||
config NET_ROUTE_IPv6_FILEROUTE
|
||||
bool "File"
|
||||
depends on EXPERIMENTAL
|
||||
---help---
|
||||
Select to used a IPv6 routing table in a file in a mounted file system.
|
||||
|
||||
endchoice # IPv6 routing table
|
||||
|
||||
config ROUTE_MAX_IPv6_RAMROUTES
|
||||
int "Preallocated IPv6 routing table entries"
|
||||
default 4
|
||||
depends on ROUTE_IPv6_RAMROUTE
|
||||
---help---
|
||||
The number of preallocated of the IPv6 routing table entries. This
|
||||
eliminates dynamica memory allocations, but limits the maximum size
|
||||
of the in-memory routing table to this number.
|
||||
|
||||
endif # NET_ROUTE
|
||||
endmenu # ARP Configuration
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
############################################################################
|
||||
# net/route/Make.defs
|
||||
#
|
||||
# Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
@ -35,10 +35,27 @@
|
|||
|
||||
ifeq ($(CONFIG_NET_ROUTE),y)
|
||||
|
||||
# Routing table support
|
||||
# General outing table support
|
||||
|
||||
SOCK_CSRCS += net_addroute.c net_allocroute.c net_delroute.c
|
||||
SOCK_CSRCS += net_foreachroute.c net_router.c netdev_router.c
|
||||
SOCK_CSRCS += net_initroute.c net_router.c netdev_router.c
|
||||
|
||||
# Support in-memory, RAM-based routing tables
|
||||
|
||||
ifeq ($(CONFIG_ROUTE_IPv4_RAMROUTE),y)
|
||||
SOCK_CSRCS += net_alloc_ramroute.c net_add_ramroute.c net_del_ramroute.c
|
||||
SOCK_CSRCS += net_queue_ramroute.c net_foreach_ramroute.c
|
||||
else ifeq ($(CONFIG_ROUTE_IPv6_RAMROUTE),y)
|
||||
SOCK_CSRCS += net_alloc_ramroute.c net_add_ramroute.c net_del_ramroute.c
|
||||
SOCK_CSRCS += net_queue_ramroute.c net_foreach_ramroute.c
|
||||
endif
|
||||
|
||||
# Support for in-memory, read-only (ROM) routing tables
|
||||
|
||||
ifeq ($(CONFIG_ROUTE_IPv4_ROMROUTE),y)
|
||||
SOCK_CSRCS += net_foreach_romroute.c
|
||||
else ifeq ($(CONFIG_ROUTE_IPv6_ROMROUTE),y)
|
||||
SOCK_CSRCS += net_foreach_romroute.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_NET_INFO),y)
|
||||
SOCK_CSRCS += net_dumproute.c
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/****************************************************************************
|
||||
* net/route/net_addroute.c
|
||||
* net/route/net_add_ramroute.c
|
||||
*
|
||||
* Copyright (C) 2013, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
|
@ -41,7 +41,6 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <queue.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
|
@ -50,9 +49,10 @@
|
|||
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "route/ramroute.h"
|
||||
#include "route/route.h"
|
||||
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE)
|
||||
#ifdef CONFIG_NET_ROUTE
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
@ -71,7 +71,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
int net_addroute_ipv4(in_addr_t target, in_addr_t netmask, in_addr_t router)
|
||||
{
|
||||
FAR struct net_route_ipv4_s *route;
|
||||
|
@ -98,13 +98,14 @@ int net_addroute_ipv4(in_addr_t target, in_addr_t netmask, in_addr_t router)
|
|||
|
||||
/* Then add the new entry to the table */
|
||||
|
||||
sq_addlast((FAR sq_entry_t *)route, (FAR sq_queue_t *)&g_ipv4_routes);
|
||||
ramroute_ipv4_addlast((FAR struct net_route_ipv4_entry_s *)route,
|
||||
&g_ipv4_routes);
|
||||
net_unlock();
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
int net_addroute_ipv6(net_ipv6addr_t target, net_ipv6addr_t netmask,
|
||||
net_ipv6addr_t router)
|
||||
{
|
||||
|
@ -132,10 +133,11 @@ int net_addroute_ipv6(net_ipv6addr_t target, net_ipv6addr_t netmask,
|
|||
|
||||
/* Then add the new entry to the table */
|
||||
|
||||
sq_addlast((FAR sq_entry_t *)route, (FAR sq_queue_t *)&g_ipv6_routes);
|
||||
ramroute_ipv6_addlast((FAR struct net_route_ipv6_entry_s *)route,
|
||||
&g_ipv6_routes);
|
||||
net_unlock();
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NET_ROUTE */
|
||||
#endif /* CONFIG_NET_ROUTE */
|
|
@ -1,5 +1,5 @@
|
|||
/****************************************************************************
|
||||
* net/route/net_allocroute.c
|
||||
* net/route/net_alloc_ramroute.c
|
||||
*
|
||||
* Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
|
@ -46,22 +46,25 @@
|
|||
#include <nuttx/net/net.h>
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "route/ramroute.h"
|
||||
#include "route/route.h"
|
||||
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE)
|
||||
#if defined(CONFIG_ROUTE_IPv4_RAMROUTE) || defined(CONFIG_ROUTE_IPv6_RAMROUTE)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* These are the routing tables */
|
||||
/* These are the routing tables. The in-memory routing tables are
|
||||
* represented as singly linked lists.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
sq_queue_t g_ipv4_routes;
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
FAR struct net_route_ipv4_queue_s g_ipv4_routes;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
sq_queue_t g_ipv6_routes;
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
FAR struct net_route_ipv6_queue_s g_ipv6_routes;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -70,24 +73,24 @@ sq_queue_t g_ipv6_routes;
|
|||
|
||||
/* These are lists of free routing table entries */
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
static sq_queue_t g_free_ipv4routes;
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
static struct net_route_ipv4_queue_s g_free_ipv4routes;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
static sq_queue_t g_free_ipv6routes;
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
static struct net_route_ipv6_queue_s g_free_ipv6routes;
|
||||
#endif
|
||||
|
||||
/* These are arrays of pre-allocated network routes */
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
static struct net_route_ipv4_s
|
||||
g_prealloc_ipv4routes[CONFIG_ROUTE_MAX_IPv4ROUTES];
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
static struct net_route_ipv4_entry_s
|
||||
g_prealloc_ipv4routes[CONFIG_ROUTE_MAX_IPv4_RAMROUTES];
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
static struct net_route_ipv6_s
|
||||
g_prealloc_ipv6routes[CONFIG_ROUTE_MAX_IPv6ROUTES];
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
static struct net_route_ipv6_entry_s
|
||||
g_prealloc_ipv6routes[CONFIG_ROUTE_MAX_IPv6_RAMROUTES];
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -95,10 +98,10 @@ static struct net_route_ipv6_s
|
|||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_initroute
|
||||
* Name: net_init_ramroute
|
||||
*
|
||||
* Description:
|
||||
* Initialize to the routing table
|
||||
* Initialize the in-memory, RAM routing table
|
||||
*
|
||||
* Parameters:
|
||||
* None
|
||||
|
@ -111,35 +114,33 @@ static struct net_route_ipv6_s
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
void net_initroute(void)
|
||||
void net_init_ramroute(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Initialize the routing table and the free list */
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
sq_init(&g_ipv4_routes);
|
||||
sq_init(&g_free_ipv4routes);
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
ramroute_init(&g_ipv4_routes);
|
||||
ramroute_init(&g_free_ipv4routes);
|
||||
|
||||
/* All all of the pre-allocated routing table entries to a free list */
|
||||
|
||||
for (i = 0; i < CONFIG_ROUTE_MAX_IPv4ROUTES; i++)
|
||||
for (i = 0; i < CONFIG_ROUTE_MAX_IPv4_RAMROUTES; i++)
|
||||
{
|
||||
sq_addlast((FAR sq_entry_t *)&g_prealloc_ipv4routes[i],
|
||||
(FAR sq_queue_t *)&g_free_ipv4routes);
|
||||
ramroute_ipv4_addlast(&g_prealloc_ipv4routes[i], &g_free_ipv4routes);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
sq_init(&g_ipv6_routes);
|
||||
sq_init(&g_free_ipv6routes);
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
ramroute_init(&g_ipv6_routes);
|
||||
ramroute_init(&g_free_ipv6routes);
|
||||
|
||||
/* All all of the pre-allocated routing table entries to a free list */
|
||||
|
||||
for (i = 0; i < CONFIG_ROUTE_MAX_IPv6ROUTES; i++)
|
||||
for (i = 0; i < CONFIG_ROUTE_MAX_IPv6_RAMROUTES; i++)
|
||||
{
|
||||
sq_addlast((FAR sq_entry_t *)&g_prealloc_ipv6routes[i],
|
||||
(FAR sq_queue_t *)&g_free_ipv6routes);
|
||||
ramroute_ipv6_addlast(&g_prealloc_ipv6routes[i], &g_free_ipv6routes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -159,41 +160,39 @@ void net_initroute(void)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
FAR struct net_route_ipv4_s *net_allocroute_ipv4(void)
|
||||
{
|
||||
FAR struct net_route_ipv4_s *route;
|
||||
FAR struct net_route_ipv4_entry_s *route;
|
||||
|
||||
/* Get exclusive address to the networking data structures */
|
||||
|
||||
net_lock();
|
||||
|
||||
/* Then add the new entry to the table */
|
||||
/* Then add the remove the first entry from the table */
|
||||
|
||||
route = (FAR struct net_route_ipv4_s *)
|
||||
sq_remfirst((FAR sq_queue_t *)&g_free_ipv4routes);
|
||||
route = ramroute_ipv4_remfirst(&g_free_ipv4routes);
|
||||
|
||||
net_unlock();
|
||||
return route;
|
||||
return &route->entry;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
FAR struct net_route_ipv6_s *net_allocroute_ipv6(void)
|
||||
{
|
||||
FAR struct net_route_ipv6_s *route;
|
||||
FAR struct net_route_ipv6_entry_s *route;
|
||||
|
||||
/* Get exclusive address to the networking data structures */
|
||||
|
||||
net_lock();
|
||||
|
||||
/* Then add the new entry to the table */
|
||||
/* Then add the remove the first entry from the table */
|
||||
|
||||
route = (FAR struct net_route_ipv6_s *)
|
||||
sq_remfirst((FAR sq_queue_t *)&g_free_ipv6routes);
|
||||
route = ramroute_ipv6_remfirst(&g_free_ipv6routes);
|
||||
|
||||
net_unlock();
|
||||
return route;
|
||||
return &route->entry;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -211,7 +210,7 @@ FAR struct net_route_ipv6_s *net_allocroute_ipv6(void)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
void net_freeroute_ipv4(FAR struct net_route_ipv4_s *route)
|
||||
{
|
||||
DEBUGASSERT(route);
|
||||
|
@ -222,12 +221,13 @@ void net_freeroute_ipv4(FAR struct net_route_ipv4_s *route)
|
|||
|
||||
/* Then add the new entry to the table */
|
||||
|
||||
sq_addlast((FAR sq_entry_t *)route, (FAR sq_queue_t *)&g_free_ipv4routes);
|
||||
ramroute_ipv4_addlast((FAR struct net_route_ipv4_entry_s *)route,
|
||||
&g_free_ipv4routes);
|
||||
net_unlock();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
void net_freeroute_ipv6(FAR struct net_route_ipv6_s *route)
|
||||
{
|
||||
DEBUGASSERT(route);
|
||||
|
@ -238,9 +238,10 @@ void net_freeroute_ipv6(FAR struct net_route_ipv6_s *route)
|
|||
|
||||
/* Then add the new entry to the table */
|
||||
|
||||
sq_addlast((FAR sq_entry_t *)route, (FAR sq_queue_t *)&g_free_ipv6routes);
|
||||
ramroute_ipv6_addlast((FAR struct net_route_ipv6_entry_s *)route,
|
||||
&g_free_ipv6routes);
|
||||
net_unlock();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NET_ROUTE */
|
||||
#endif /* CONFIG_ROUTE_IPv4_RAMROUTE || CONFIG_ROUTE_IPv6_RAMROUTE */
|
|
@ -1,5 +1,5 @@
|
|||
/****************************************************************************
|
||||
* net/route/net_delroute.c
|
||||
* net/route/net_del_ramroute.c
|
||||
*
|
||||
* Copyright (C) 2013, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
|
||||
#include "route/ramroute.h"
|
||||
#include "route/route.h"
|
||||
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE)
|
||||
|
@ -55,7 +56,7 @@
|
|||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
struct route_match_s
|
||||
{
|
||||
FAR struct net_route_ipv4_s *prev; /* Predecessor in the list */
|
||||
|
@ -64,7 +65,7 @@ struct route_match_s
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
struct route_match_ipv6_s
|
||||
{
|
||||
FAR struct net_route_ipv6_s *prev; /* Predecessor in the list */
|
||||
|
@ -92,7 +93,7 @@ struct route_match_ipv6_s
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
static int net_match_ipv4(FAR struct net_route_ipv4_s *route, FAR void *arg)
|
||||
{
|
||||
FAR struct route_match_s *match = (FAR struct route_match_s *)arg;
|
||||
|
@ -113,12 +114,12 @@ static int net_match_ipv4(FAR struct net_route_ipv4_s *route, FAR void *arg)
|
|||
|
||||
if (match->prev)
|
||||
{
|
||||
(void)sq_remafter((FAR sq_entry_t *)match->prev,
|
||||
(FAR sq_queue_t *)&g_ipv4_routes);
|
||||
(void)ramroute_ipv4_remafter((FAR struct net_route_ipv4_entry_s *)match->prev,
|
||||
&g_ipv4_routes);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)sq_remfirst((FAR sq_queue_t *)&g_ipv4_routes);
|
||||
(void)ramroute_ipv4_remfirst(&g_ipv4_routes);
|
||||
}
|
||||
|
||||
/* And free the routing table entry by adding it to the free list */
|
||||
|
@ -137,7 +138,7 @@ static int net_match_ipv4(FAR struct net_route_ipv4_s *route, FAR void *arg)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
static int net_match_ipv6(FAR struct net_route_ipv6_s *route, FAR void *arg)
|
||||
{
|
||||
FAR struct route_match_ipv6_s *match = (FAR struct route_match_ipv6_s *)arg;
|
||||
|
@ -166,12 +167,12 @@ static int net_match_ipv6(FAR struct net_route_ipv6_s *route, FAR void *arg)
|
|||
|
||||
if (match->prev)
|
||||
{
|
||||
(void)sq_remafter((FAR sq_entry_t *)match->prev,
|
||||
(FAR sq_queue_t *)&g_ipv6_routes);
|
||||
(void)ramroute_ipv6_remafter((FAR struct net_route_ipv6_entry_s *)match->prev,
|
||||
&g_ipv6_routes);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)sq_remfirst((FAR sq_queue_t *)&g_ipv6_routes);
|
||||
(void)ramroute_ipv6_remfirst(&g_ipv6_routes);
|
||||
}
|
||||
|
||||
/* And free the routing table entry by adding it to the free list */
|
||||
|
@ -207,7 +208,7 @@ static int net_match_ipv6(FAR struct net_route_ipv6_s *route, FAR void *arg)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
int net_delroute_ipv4(in_addr_t target, in_addr_t netmask)
|
||||
{
|
||||
struct route_match_s match;
|
||||
|
@ -224,7 +225,7 @@ int net_delroute_ipv4(in_addr_t target, in_addr_t netmask)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
int net_delroute_ipv6(net_ipv6addr_t target, net_ipv6addr_t netmask)
|
||||
{
|
||||
struct route_match_ipv6_s match;
|
|
@ -1,5 +1,5 @@
|
|||
/****************************************************************************
|
||||
* net/route/net_foreachroute.c
|
||||
* net/route/net_foreach_ramroute.c
|
||||
*
|
||||
* Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
|
@ -46,9 +46,10 @@
|
|||
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "route/ramroute.h"
|
||||
#include "route/route.h"
|
||||
|
||||
#if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE)
|
||||
#ifdef CONFIG_NET_ROUTE
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
@ -69,11 +70,11 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
int net_foreachroute_ipv4(route_handler_t handler, FAR void *arg)
|
||||
{
|
||||
FAR struct net_route_ipv4_s *route;
|
||||
FAR struct net_route_ipv4_s *next;
|
||||
FAR struct net_route_ipv4_entry_s *route;
|
||||
FAR struct net_route_ipv4_entry_s *next;
|
||||
int ret = 0;
|
||||
|
||||
/* Prevent concurrent access to the routing table */
|
||||
|
@ -82,16 +83,14 @@ int net_foreachroute_ipv4(route_handler_t handler, FAR void *arg)
|
|||
|
||||
/* Visit each entry in the routing table */
|
||||
|
||||
for (route = (FAR struct net_route_ipv4_s *)g_ipv4_routes.head;
|
||||
ret == 0 && route != NULL;
|
||||
route = next)
|
||||
for (route = g_ipv4_routes.head; ret == 0 && route != NULL; route = next)
|
||||
{
|
||||
/* Get the next entry in the to visit. We do this BEFORE calling the
|
||||
* handler because the hanlder may delete this entry.
|
||||
*/
|
||||
|
||||
next = route->flink;
|
||||
ret = handler(route, arg);
|
||||
ret = handler(&route->entry, arg);
|
||||
}
|
||||
|
||||
/* Unlock the network */
|
||||
|
@ -101,11 +100,11 @@ int net_foreachroute_ipv4(route_handler_t handler, FAR void *arg)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
int net_foreachroute_ipv6(route_handler_ipv6_t handler, FAR void *arg)
|
||||
{
|
||||
FAR struct net_route_ipv6_s *route;
|
||||
FAR struct net_route_ipv6_s *next;
|
||||
FAR struct net_route_ipv6_entry_s *route;
|
||||
FAR struct net_route_ipv6_entry_s *next;
|
||||
int ret = 0;
|
||||
|
||||
/* Prevent concurrent access to the routing table */
|
||||
|
@ -114,16 +113,14 @@ int net_foreachroute_ipv6(route_handler_ipv6_t handler, FAR void *arg)
|
|||
|
||||
/* Visit each entry in the routing table */
|
||||
|
||||
for (route = (FAR struct net_route_ipv6_s *)g_ipv6_routes.head;
|
||||
ret == 0 && route != NULL;
|
||||
route = next)
|
||||
for (route = g_ipv6_routes.head; ret == 0 && route != NULL; route = next)
|
||||
{
|
||||
/* Get the next entry in the to visit. We do this BEFORE calling the
|
||||
* handler because the hanlder may delete this entry.
|
||||
*/
|
||||
|
||||
next = route->flink;
|
||||
ret = handler(route, arg);
|
||||
ret = handler(&route->entry, arg);
|
||||
}
|
||||
|
||||
/* Unlock the network */
|
||||
|
@ -133,4 +130,4 @@ int net_foreachroute_ipv6(route_handler_ipv6_t handler, FAR void *arg)
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NET_ROUTE */
|
||||
#endif /* CONFIG_NET_ROUTE */
|
108
net/route/net_foreach_romroute.c
Normal file
108
net/route/net_foreach_romroute.c
Normal file
|
@ -0,0 +1,108 @@
|
|||
/****************************************************************************
|
||||
* net/route/net_foreach_romroute.c
|
||||
*
|
||||
* Copyright (C) 2017 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include "route/romroute.h"
|
||||
#include "route/route.h"
|
||||
|
||||
#ifdef CONFIG_NET_ROUTE
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_foreachroute_ipv4 and net_foreachroute_ipv6
|
||||
*
|
||||
* Description:
|
||||
* Traverse the routing table
|
||||
*
|
||||
* Parameters:
|
||||
* handler - Will be called for each route in the routing table.
|
||||
* arg - An arbitrary value that will be passed tot he handler.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 if in use; 1 if avaialble and the new entry was added
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv4_ROMROUTE
|
||||
int net_foreachroute_ipv4(route_handler_t handler, FAR void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
/* Visit each entry in the routing table */
|
||||
|
||||
for (i = 0; ret == 0 && i < g_ipv4_nroutes; i++)
|
||||
{
|
||||
/* Call the handler. */
|
||||
|
||||
ret = handler(&g_ipv4_routes[i], arg);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv6_ROMROUTE
|
||||
int net_foreachroute_ipv6(route_handler_ipv6_t handler, FAR void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
/* Visit each entry in the routing table */
|
||||
|
||||
for (i = 0; ret == 0 && i < g_ipv6_nroutes; i++)
|
||||
{
|
||||
/* Call the handler. */
|
||||
|
||||
ret = handler(&g_ipv6_routes[i], arg);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NET_ROUTE */
|
72
net/route/net_initroute.c
Normal file
72
net/route/net_initroute.c
Normal file
|
@ -0,0 +1,72 @@
|
|||
/****************************************************************************
|
||||
* net/route/net_initroute.c
|
||||
*
|
||||
* Copyright (C) 2017 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "route/ramroute.h"
|
||||
#include "route/route.h"
|
||||
|
||||
#ifdef CONFIG_NET_ROUTE
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_init_route
|
||||
*
|
||||
* Description:
|
||||
* Initialize to the routing table
|
||||
*
|
||||
* Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void net_init_route(void)
|
||||
{
|
||||
#if defined(CONFIG_ROUTE_IPv4_RAMROUTE) || defined(CONFIG_ROUTE_IPv6_RAMROUTE)
|
||||
net_init_ramroute();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_ROUTE */
|
233
net/route/net_queue_ramroute.c
Normal file
233
net/route/net_queue_ramroute.c
Normal file
|
@ -0,0 +1,233 @@
|
|||
/****************************************************************************
|
||||
* net/route/net_queue_ramroute.c
|
||||
*
|
||||
* Copyright (C) 2017 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "route/ramroute.h"
|
||||
#include "route/route.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ramroute_ipv4_addlast/ramroute_ipv6_addlast
|
||||
*
|
||||
* Description:
|
||||
* Remove the entry at the end of an IPv4/IPv6 routing table list
|
||||
*
|
||||
* Parameters:
|
||||
* entry - A pointer to the new entry to add to the list
|
||||
* list - The list to be used.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
void ramroute_ipv4_addlast(FAR struct net_route_ipv4_entry_s *entry,
|
||||
FAR struct net_route_ipv4_queue_s *list)
|
||||
{
|
||||
entry->flink = NULL;
|
||||
if (!list->head)
|
||||
{
|
||||
list->head = entry;
|
||||
list->tail = entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
list->tail->flink = entry;
|
||||
list->tail = entry;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
void ramroute_ipv6_addlast(FAR struct net_route_ipv6_entry_s *entry,
|
||||
FAR struct net_route_ipv6_queue_s *list)
|
||||
{
|
||||
entry->flink = NULL;
|
||||
if (!list->head)
|
||||
{
|
||||
list->head = entry;
|
||||
list->tail = entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
list->tail->flink = entry;
|
||||
list->tail = entry;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ramroute_ipv4_remfirst/ramroute_ipv6_remfirst
|
||||
*
|
||||
* Description:
|
||||
* Add an entry to the end of an IPv4/IPv6 routing table list
|
||||
*
|
||||
* Parameters:
|
||||
* entry - A pointer to the new entry to add to the list
|
||||
* list - The list to be used.
|
||||
*
|
||||
* Returned Value:
|
||||
* A pointer to the entry removed from the head of the list or NULL if the
|
||||
* list was empty.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
FAR struct net_route_ipv4_entry_s *
|
||||
ramroute_ipv4_remfirst(struct net_route_ipv4_queue_s *list)
|
||||
{
|
||||
FAR struct net_route_ipv4_entry_s *ret = list->head;
|
||||
|
||||
if (ret)
|
||||
{
|
||||
list->head = ret->flink;
|
||||
if (!list->head)
|
||||
{
|
||||
list->tail = NULL;
|
||||
}
|
||||
|
||||
ret->flink = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
FAR struct net_route_ipv6_entry_s *
|
||||
ramroute_ipv6_remfirst(struct net_route_ipv6_queue_s *list)
|
||||
{
|
||||
FAR struct net_route_ipv6_entry_s *ret = list->head;
|
||||
|
||||
if (ret)
|
||||
{
|
||||
list->head = ret->flink;
|
||||
if (!list->head)
|
||||
{
|
||||
list->tail = NULL;
|
||||
}
|
||||
|
||||
ret->flink = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ramroute_ipv4_remafter/ramroute_ipv6_remafter
|
||||
*
|
||||
* Description:
|
||||
* Remove the entry in the IPv4/IPv6 routing table list after the specified
|
||||
entry.
|
||||
*
|
||||
* Parameters:
|
||||
* entry - A pointer to the new entry to add to the list
|
||||
* list - The list to be used.
|
||||
*
|
||||
* Returned Value:
|
||||
* A pointer to the entry removed from the head of the list or NULL if the
|
||||
* list was empty.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
FAR struct net_route_ipv4_entry_s *
|
||||
ramroute_ipv4_remafter(FAR struct net_route_ipv4_entry_s *entry,
|
||||
FAR struct net_route_ipv4_queue_s *list)
|
||||
{
|
||||
FAR struct net_route_ipv4_entry_s *ret = entry->flink;
|
||||
|
||||
if (list->head && ret)
|
||||
{
|
||||
if (list->tail == ret)
|
||||
{
|
||||
list->tail = entry;
|
||||
entry->flink = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry->flink = ret->flink;
|
||||
}
|
||||
|
||||
ret->flink = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
FAR struct net_route_ipv6_entry_s *
|
||||
ramroute_ipv6_remafter(FAR struct net_route_ipv6_entry_s *entry,
|
||||
struct net_route_ipv6_queue_s *list)
|
||||
{
|
||||
FAR struct net_route_ipv6_entry_s *ret = entry->flink;
|
||||
|
||||
if (list->head && ret)
|
||||
{
|
||||
if (list->tail == ret)
|
||||
{
|
||||
list->tail = entry;
|
||||
entry->flink = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry->flink = ret->flink;
|
||||
}
|
||||
|
||||
ret->flink = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
232
net/route/ramroute.h
Normal file
232
net/route/ramroute.h
Normal file
|
@ -0,0 +1,232 @@
|
|||
/****************************************************************************
|
||||
* net/route/ramroute.h
|
||||
*
|
||||
* Copyright (C) 2017 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __NET_ROUTE_RAMROUTE_H
|
||||
#define __NET_ROUTE_RAMROUTE_H 1
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "route/route.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_ROUTE_MAX_IPv4_RAMROUTES
|
||||
# define CONFIG_ROUTE_MAX_IPv4_RAMROUTES 4
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ROUTE_MAX_IPv6_RAMROUTES
|
||||
# define CONFIG_ROUTE_MAX_IPv6_RAMROUTES 4
|
||||
#endif
|
||||
|
||||
/* Routing table initializer */
|
||||
|
||||
#define ramroute_init(rr) \
|
||||
do \
|
||||
{ \
|
||||
(rr)->head = NULL; \
|
||||
(rr)->tail = NULL; \
|
||||
} \
|
||||
while (0) \
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
/* This structure describes one entry in the routing table */
|
||||
|
||||
struct net_route_ipv4_entry_s
|
||||
{
|
||||
struct net_route_ipv4_s entry;
|
||||
FAR struct net_route_ipv4_entry_s *flink;
|
||||
};
|
||||
|
||||
/* This structure describes the head of a routing table list */
|
||||
|
||||
struct net_route_ipv4_queue_s
|
||||
{
|
||||
FAR struct net_route_ipv4_entry_s *head;
|
||||
FAR struct net_route_ipv4_entry_s *tail;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
/* This structure describes one entry in the routing table */
|
||||
|
||||
struct net_route_ipv6_entry_s
|
||||
{
|
||||
struct net_route_ipv6_s entry;
|
||||
FAR struct net_route_ipv6_entry_s *flink;
|
||||
};
|
||||
|
||||
/* This structure describes the head of a routing table list */
|
||||
|
||||
struct net_route_ipv6_queue_s
|
||||
{
|
||||
FAR struct net_route_ipv6_entry_s *head;
|
||||
FAR struct net_route_ipv6_entry_s *tail;
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* These are the routing tables */
|
||||
|
||||
#if defined(CONFIG_ROUTE_IPv4_RAMROUTE)
|
||||
/* The in-memory routing tables are represented as singly linked lists. */
|
||||
|
||||
extern struct net_route_ipv4_queue_s g_ipv4_routes;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ROUTE_IPv6_RAMROUTE)
|
||||
/* The in-memory routing tables are represented as singly linked lists. */
|
||||
|
||||
extern struct net_route_ipv6_queue_s g_ipv6_routes;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_init_ramroute
|
||||
*
|
||||
* Description:
|
||||
* Initialize the in-memory, RAM routing table
|
||||
*
|
||||
* Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Called early in initialization so that no special protection is needed.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void net_init_ramroute(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_allocroute_ipv4 and net_allocroute_ipv6
|
||||
*
|
||||
* Description:
|
||||
* Allocate one route by removing it from the free list
|
||||
*
|
||||
* Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, a pointer to the newly allocated routing table entry is
|
||||
* returned; NULL is returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
FAR struct net_route_ipv4_s *net_allocroute_ipv4(void);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
FAR struct net_route_ipv6_s *net_allocroute_ipv6(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_freeroute_ipv4 and net_freeroute_ipv6
|
||||
*
|
||||
* Description:
|
||||
* Free one route by adding it from the free list
|
||||
*
|
||||
* Parameters:
|
||||
* route - The route to be freed
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
void net_freeroute_ipv4(FAR struct net_route_ipv4_s *route);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
void net_freeroute_ipv6(FAR struct net_route_ipv6_s *route);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: (various low-level list operations)
|
||||
*
|
||||
* Description:
|
||||
* Perform operations on in-memory routing table lists
|
||||
*
|
||||
* Parameters:
|
||||
* entry - A pointer to the new entry to add to the list
|
||||
* list - The list to be used.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv4_RAMROUTE
|
||||
void ramroute_ipv4_addlast(FAR struct net_route_ipv4_entry_s *entry,
|
||||
FAR struct net_route_ipv4_queue_s *list);
|
||||
FAR struct net_route_ipv4_entry_s *
|
||||
ramroute_ipv4_remfirst(struct net_route_ipv4_queue_s *list);
|
||||
FAR struct net_route_ipv4_entry_s *
|
||||
ramroute_ipv4_remafter(FAR struct net_route_ipv4_entry_s *entry,
|
||||
FAR struct net_route_ipv4_queue_s *list);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ROUTE_IPv6_RAMROUTE
|
||||
void ramroute_ipv6_addlast(FAR struct net_route_ipv6_entry_s *entry,
|
||||
FAR struct net_route_ipv6_queue_s *list);
|
||||
FAR struct net_route_ipv6_entry_s *
|
||||
ramroute_ipv6_remfirst(struct net_route_ipv6_queue_s *list);
|
||||
FAR struct net_route_ipv6_entry_s *
|
||||
ramroute_ipv6_remafter(FAR struct net_route_ipv6_entry_s *entry,
|
||||
struct net_route_ipv6_queue_s *list);
|
||||
#endif
|
||||
|
||||
#endif /* __NET_ROUTE_RAMROUTE_H */
|
73
net/route/romroute.h
Normal file
73
net/route/romroute.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/****************************************************************************
|
||||
* net/route/romroute.h
|
||||
*
|
||||
* Copyright (C) 2017 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __NET_ROUTE_ROMROUTE_H
|
||||
#define __NET_ROUTE_ROMROUTE_H 1
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "route/route.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* These are the routing tables. These must be provided by board-specific
|
||||
* logic.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ROUTE_IPv4_ROMROUTE)
|
||||
/* The in-memory routing tables are represented as a simple array. */
|
||||
|
||||
extern struct net_route_ipv4_s g_ipv4_routes[];
|
||||
extern const unsigned int g_ipv4_nroutes;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ROUTE_IPv6_ROMROUTE)
|
||||
/* The in-memory routing tables are represented as asimple array. */
|
||||
|
||||
extern struct net_route_ipv6_s g_ipv6_routes[];
|
||||
extern const unsigned int g_ipv6_nroutes;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __NET_ROUTE_ROMROUTE_H */
|
|
@ -42,61 +42,45 @@
|
|||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <queue.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <nuttx/net/ip.h>
|
||||
|
||||
#ifdef CONFIG_NET_ROUTE
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_ROUTE_MAX_IPv4ROUTES
|
||||
# define CONFIG_ROUTE_MAX_IPv4ROUTES 4
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_ROUTE_MAX_IPv6ROUTES
|
||||
# define CONFIG_ROUTE_MAX_IPv6ROUTES 4
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure describes one entry in the routing table */
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
struct net_route_ipv4_s
|
||||
{
|
||||
FAR struct net_route_ipv4_s *flink; /* Supports a singly linked list */
|
||||
in_addr_t target; /* The destination network */
|
||||
in_addr_t netmask; /* The network address mask */
|
||||
in_addr_t router; /* Route packets via this router */
|
||||
in_addr_t target; /* The destination network */
|
||||
in_addr_t netmask; /* The network address mask */
|
||||
in_addr_t router; /* Route packets via this router */
|
||||
};
|
||||
|
||||
/* Type of the call out function pointer provided to net_foreachroute_ipv4() */
|
||||
|
||||
typedef int (*route_handler_t)(FAR struct net_route_ipv4_s *route,
|
||||
FAR void *arg);
|
||||
#endif
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
struct net_route_ipv6_s
|
||||
{
|
||||
FAR struct net_route_ipv6_s *flink; /* Supports a singly linked list */
|
||||
net_ipv6addr_t target; /* The destination network */
|
||||
net_ipv6addr_t netmask; /* The network address mask */
|
||||
net_ipv6addr_t router; /* Route packets via this router */
|
||||
net_ipv6addr_t target; /* The destination network */
|
||||
net_ipv6addr_t netmask; /* The network address mask */
|
||||
net_ipv6addr_t router; /* Route packets via this router */
|
||||
};
|
||||
|
||||
/* Type of the call out function pointer provided to net_foreachroute_ipv6() */
|
||||
|
||||
typedef int (*route_handler_ipv6_t)(FAR struct net_route_ipv6_s *route,
|
||||
FAR void *arg);
|
||||
#endif
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
|
@ -110,22 +94,12 @@ extern "C"
|
|||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* These are the routing tables */
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
EXTERN sq_queue_t g_ipv4_routes;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
EXTERN sq_queue_t g_ipv6_routes;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_initroute
|
||||
* Name: net_init_route
|
||||
*
|
||||
* Description:
|
||||
* Initialize to the routing table
|
||||
|
@ -138,52 +112,7 @@ EXTERN sq_queue_t g_ipv6_routes;
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
void net_initroute(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_allocroute_ipv4 and net_allocroute_ipv6
|
||||
*
|
||||
* Description:
|
||||
* Allocate one route by removing it from the free list
|
||||
*
|
||||
* Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, a pointer to the newly allocated routing table entry is
|
||||
* returned; NULL is returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
FAR struct net_route_ipv4_s *net_allocroute_ipv4(void);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
FAR struct net_route_ipv6_s *net_allocroute_ipv6(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_freeroute_ipv4 and net_freeroute_ipv6
|
||||
*
|
||||
* Description:
|
||||
* Free one route by adding it from the free list
|
||||
*
|
||||
* Parameters:
|
||||
* route - The route to be freed
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
void net_freeroute_ipv4(FAR struct net_route_ipv4_s *route);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
void net_freeroute_ipv6(FAR struct net_route_ipv6_s *route);
|
||||
#endif
|
||||
void net_init_route(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_addroute_ipv4 and net_addroute_ipv6
|
||||
|
|
Loading…
Reference in a new issue