remove the route table features
authorkang <pilseob.kang@samsung.com>
Fri, 1 Sep 2017 07:20:54 +0000 (16:20 +0900)
committerkang <pilseob.kang@samsung.com>
Fri, 1 Sep 2017 07:20:54 +0000 (16:20 +0900)
13 files changed:
os/net/Kconfig
os/net/Makefile
os/net/net_initialize.c
os/net/netdev/netdev_ioctl.c
os/net/route/Kconfig [deleted file]
os/net/route/Make.defs [deleted file]
os/net/route/net_addroute.c [deleted file]
os/net/route/net_allocroute.c [deleted file]
os/net/route/net_delroute.c [deleted file]
os/net/route/net_foreachroute.c [deleted file]
os/net/route/net_router.c [deleted file]
os/net/route/netdev_router.c [deleted file]
os/net/route/route.h [deleted file]

index dc420c5..cba85c8 100644 (file)
@@ -39,7 +39,7 @@ endif #NET_LWIP
 menu "Driver buffer configuration"
 
 config NET_MULTIBUFFER
-       bool "Use multiple device-side I/O buffers"
+       bool #"Use multiple device-side I/O buffers"
        default n
        ---help---
                Traditionally, uIP has used a single buffer for all incoming and
@@ -50,7 +50,7 @@ config NET_MULTIBUFFER
                input/ouput and output transfers for better performance.
 
 config NET_ETH_MTU
-       int "Ethernet packet buffer size (MTU)"
+       int #"Ethernet packet buffer size (MTU)"
        default 1294 if NET_IPv6
        default 590 if !NET_IPv6
        depends on NET_ETHERNET
@@ -69,7 +69,7 @@ config NET_ETH_MTU
                resulting in a minimum buffer size of of 1220+20+40+14 = 1294
 
 config NET_GUARDSIZE
-       int "Driver I/O guard size"
+       int #"Driver I/O guard size"
        default 2
        ---help---
                Network drivers often receive packets with garbage at the end and
@@ -101,7 +101,6 @@ config NET_ETHERNET
 endmenu # Data link support
 
 source net/netdev/Kconfig
-source net/route/Kconfig
 
 menu "Protocols"
 
index 86e9296..313cf41 100644 (file)
@@ -97,7 +97,6 @@ include lwip/src/netif/ppp/Make.defs
 include lwip/sys/arch/Make.defs
 endif
 
-include route/Make.defs
 include utils/Make.defs
 
 endif
index eb0148d..2272771 100644 (file)
@@ -70,7 +70,6 @@
 #endif
 
 #include "netdev/netdev.h"
-#include "route/route.h"
 #include "utils/utils.h"
 
 /****************************************************************************
index e951833..d3626ad 100644 (file)
@@ -84,7 +84,6 @@
 
 #include "socket/socket.h"
 #include "netdev/netdev.h"
-#include "route/route.h"
 
 /****************************************************************************
  * Pre-processor Definitions
diff --git a/os/net/route/Kconfig b/os/net/route/Kconfig
deleted file mode 100644 (file)
index ebd2a6d..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see kconfig-language at https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt
-#
-
-menu "Routing Table Configuration"
-
-config NET_ROUTE
-       bool "Routing table support"
-       default n
-       ---help---
-               Build in support for a routing table.  See include/net/route.h
-
-if NET_ROUTE
-
-config NET_MAXROUTES
-       int "Routing table size"
-       default 4
-       ---help---
-               The size of the routing table (in entries).
-
-endif # NET_ROUTE
-endmenu # ARP Configuration
diff --git a/os/net/route/Make.defs b/os/net/route/Make.defs
deleted file mode 100644 (file)
index 5525e4e..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-###########################################################################
-#
-# Copyright 2016 Samsung Electronics All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-# either express or implied. See the License for the specific
-# language governing permissions and limitations under the License.
-#
-###########################################################################
-
-############################################################################
-# net/route/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.
-#
-############################################################################
-
-ifeq ($(CONFIG_NET_ROUTE),y)
-
-# Routing table support
-
-SOCK_CSRCS += net_addroute.c net_allocroute.c net_delroute.c
-SOCK_CSRCS += net_foreachroute.c net_router.c netdev_router.c
-
-# Include routing table build support
-
-DEPPATH += --dep-path route
-VPATH += :route
-
-endif
diff --git a/os/net/route/net_addroute.c b/os/net/route/net_addroute.c
deleted file mode 100644 (file)
index dcbe196..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * net/route/net_addroute.c
- *
- *   Copyright (C) 2013, 2015 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 <tinyara/config.h>
-
-#include <stdint.h>
-#include <queue.h>
-#include <errno.h>
-#include <debug.h>
-
-#include <tinyara/net/net.h>
-#include <tinyara/net/ip.h>
-
-#include <arch/irq.h>
-
-#include "route/route.h"
-
-#if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE)
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Function: net_addroute
- *
- * Description:
- *   Add a new route to the routing table
- *
- * Parameters:
- *
- * Returned Value:
- *   OK on success; Negated errno on failure.
- *
- ****************************************************************************/
-
-int net_addroute(in_addr_t target, in_addr_t netmask, in_addr_t router)
-{
-       FAR struct net_route_s *route;
-       net_lock_t save;
-
-       /* Allocate a route entry */
-
-       route = net_allocroute();
-       if (!route) {
-               ndbg("ERROR:  Failed to allocate a route\n");
-               return -ENOMEM;
-       }
-
-       /* Format the new route table entry */
-
-       net_ipv4addr_copy(route->target, target);
-       net_ipv4addr_copy(route->netmask, netmask);
-       net_ipv4addr_copy(route->router, router);
-
-       /* Get exclusive address to the networking data structures */
-
-       save = net_lock();
-
-       /* Then add the new entry to the table */
-
-       sq_addlast((FAR sq_entry_t *) route, (FAR sq_queue_t *)&g_routes);
-       net_unlock(save);
-       return OK;
-}
-
-#endif                                                 /* CONFIG_NET && CONFIG_NET_ROUTE */
diff --git a/os/net/route/net_allocroute.c b/os/net/route/net_allocroute.c
deleted file mode 100644 (file)
index 2a8a242..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * net/route/net_allocroute.c
- *
- *   Copyright (C) 2013 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 <tinyara/config.h>
-
-#include <stdint.h>
-#include <errno.h>
-#include <assert.h>
-
-#include <tinyara/net/net.h>
-#include <arch/irq.h>
-
-#include "route/route.h"
-
-#if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE)
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/* This is the routing table */
-
-sq_queue_t g_routes;
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/* This is a list of free routing table entries */
-
-static sq_queue_t g_freeroutes;
-
-/* This is an array of pre-allocated network routes */
-
-static struct net_route_s g_preallocroutes[CONFIG_NET_MAXROUTES];
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Function: net_initroute
- *
- * Description:
- *   Initialize to the routing table
- *
- * Parameters:
- *   None
- *
- * Returned Value:
- *   None
- *
- * Assumptions:
- *   Called early in initialization so that no special protection is needed.
- *
- ****************************************************************************/
-
-void net_initroute(void)
-{
-       int i;
-
-       /* Initialize the routing table and the free list */
-
-       sq_init(&g_routes);
-       sq_init(&g_freeroutes);
-
-       /* All all of the pre-allocated routing table entries to a free list */
-
-       for (i = 0; i < CONFIG_NET_MAXROUTES; i++) {
-               sq_addlast((FAR sq_entry_t *)&g_preallocroutes[i], (FAR sq_queue_t *)&g_freeroutes);
-       }
-}
-
-/****************************************************************************
- * Function: net_allocroute
- *
- * Description:
- *   Allocate one route by removing it from the free list
- *
- * Parameters:
- *   None
- *
- * Returned Value:
- *   On success, a pointer to the newly allocated route table entry is
- *   returned; NULL is returned on failure.
- *
- ****************************************************************************/
-
-FAR struct net_route_s *net_allocroute(void)
-{
-       FAR struct net_route_s *route;
-       net_lock_t save;
-
-       /* Get exclusive address to the networking data structures */
-
-       save = net_lock();
-
-       /* Then add the new entry to the table */
-
-       route = (FAR struct net_route_s *)
-                       sq_remfirst((FAR sq_queue_t *)&g_freeroutes);
-
-       net_unlock(save);
-       return route;
-}
-
-/****************************************************************************
- * Function: net_allocroute
- *
- * Description:
- *   Free one route by adding it from the free list
- *
- * Parameters:
- *   route - The route to be freed
- *
- * Returned Value:
- *   None
- *
- ****************************************************************************/
-
-void net_freeroute(FAR struct net_route_s *route)
-{
-       net_lock_t save;
-
-       DEBUGASSERT(route);
-
-       /* Get exclusive address to the networking data structures */
-
-       save = net_lock();
-
-       /* Then add the new entry to the table */
-
-       sq_addlast((FAR sq_entry_t *) route, (FAR sq_queue_t *)&g_freeroutes);
-       net_unlock(save);
-}
-
-#endif                                                 /* CONFIG_NET && CONFIG_NET_ROUTE */
diff --git a/os/net/route/net_delroute.c b/os/net/route/net_delroute.c
deleted file mode 100644 (file)
index af3d1c3..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * net/route/net_delroute.c
- *
- *   Copyright (C) 2013, 2015 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 <tinyara/config.h>
-
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-
-#include <tinyara/net/ip.h>
-
-#include "route/route.h"
-
-#if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE)
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-
-struct route_match_s {
-       FAR struct net_route_s *prev;   /* Predecessor in the list */
-       in_addr_t target;                       /* The target IP address to match */
-       in_addr_t netmask;                      /* The network mask to match */
-};
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Function: net_match
- *
- * Description:
- *   Return 1 if the route is available
- *
- * Parameters:
- *   route - The next route to examine
- *   arg   - The match values (cast to void*)
- *
- * Returned Value:
- *   0 if the entry is not a match; 1 if the entry matched and was cleared.
- *
- ****************************************************************************/
-
-static int net_match(FAR struct net_route_s *route, FAR void *arg)
-{
-       FAR struct route_match_s *match = (FAR struct route_match_s *)arg;
-
-       /* To match, the masked target address must be the same, and the masks
-        * must be the same.
-        */
-
-       if (net_ipv4addr_maskcmp(route->target, match->target, match->netmask) && net_ipv4addr_cmp(route->netmask, match->netmask)) {
-               /* They match.. Remove the entry from the routing table */
-
-               if (match->prev) {
-                       (void)sq_remafter((FAR sq_entry_t *) match->prev, (FAR sq_queue_t *)&g_routes);
-               } else {
-                       (void)sq_remfirst((FAR sq_queue_t *)&g_routes);
-               }
-
-               /* And free the routing table entry by adding it to the free list */
-
-               net_freeroute(route);
-
-               /* Return a non-zero value to terminate the traversal */
-
-               return 1;
-       }
-
-       /* Next time we are here, this will be the previous entry */
-
-       match->prev = route;
-       return 0;
-}
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Function: net_delroute
- *
- * Description:
- *   Remove an existing route from the routing table
- *
- * Parameters:
- *
- * Returned Value:
- *   OK on success; Negated errno on failure.
- *
- ****************************************************************************/
-
-int net_delroute(in_addr_t target, in_addr_t netmask)
-{
-       struct route_match_s match;
-
-       /* Set up the comparison structure */
-
-       match.prev = NULL;
-       net_ipv4addr_copy(match.target, target);
-       net_ipv4addr_copy(match.netmask, netmask);
-
-       /* Then remove the entry from the routing table */
-
-       return net_foreachroute(net_match, &match) ? OK : -ENOENT;
-}
-
-#endif                                                 /* CONFIG_NET && CONFIG_NET_ROUTE  */
diff --git a/os/net/route/net_foreachroute.c b/os/net/route/net_foreachroute.c
deleted file mode 100644 (file)
index 4c7089b..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * net/route/net_foreachroute.c
- *
- *   Copyright (C) 2013 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 <tinyara/config.h>
-
-#include <stdint.h>
-#include <errno.h>
-
-#include <tinyara/net/net.h>
-
-#include <arch/irq.h>
-
-#include "route/route.h"
-
-#if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE)
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Function: net_foreachroute
- *
- * Description:
- *   Traverse the route table
- *
- * Parameters:
- *
- * Returned Value:
- *   0 if in use; 1 if avaialble and the new entry was added
- *
- ****************************************************************************/
-
-int net_foreachroute(route_handler_t handler, FAR void *arg)
-{
-       FAR struct net_route_s *route;
-       FAR struct net_route_s *next;
-       net_lock_t save;
-       int ret = 0;
-
-       /* Prevent concurrent access to the routing table */
-
-       save = net_lock();
-
-       /* Visit each entry in the routing table */
-
-       for (route = (FAR struct net_route_s *)g_routes.head; route; 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);
-       }
-
-       /* Unlock uIP */
-
-       net_unlock(save);
-       return ret;
-}
-
-#endif                                                 /* CONFIG_NET && CONFIG_NET_ROUTE */
diff --git a/os/net/route/net_router.c b/os/net/route/net_router.c
deleted file mode 100644 (file)
index 90ce165..0000000
+++ /dev/null
@@ -1,280 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * net/route/net_router.c
- *
- *   Copyright (C) 2013-2015 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 <tinyara/config.h>
-
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-
-#include <tinyara/net/ip.h>
-
-#include "route/route.h"
-
-#if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE)
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv4
-struct route_ipv4_match_s {
-       in_addr_t target;                       /* Target IPv4 address on an external network to match */
-       in_addr_t router;                       /* IPv4 address of the router on one of our networks */
-};
-#endif
-
-#ifdef CONFIG_NET_IPv6
-struct route_ipv6_match_s {
-       net_ipv6addr_t target;          /* Target IPv6 address on an external network to match */
-       net_ipv6addr_t router;          /* IPv6 address of the router on one of our networks */
-};
-#endif
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Function: net_ipv4_match
- *
- * Description:
- *   Return 1 if the IPv4 route is available
- *
- * Parameters:
- *   route - The next route to examine
- *   arg   - The match values (cast to void*)
- *
- * Returned Value:
- *   0 if the entry is not a match; 1 if the entry matched and was cleared.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv4
-static int net_ipv4_match(FAR struct net_route_s *route, FAR void *arg)
-{
-       FAR struct route_ipv4_match_s *match = (FAR struct route_ipv4_match_s *)arg;
-
-       /* To match, the masked target addresses must be the same.  In the event
-        * of multiple matches, only the first is returned.  There is not (yet) any
-        * concept for the precedence of networks.
-        */
-
-       if (net_ipv4addr_maskcmp(route->target, match->target, route->netmask)) {
-               /* They match.. Copy the router address */
-
-               net_ipv4addr_copy(match->router, route->router);
-               return 1;
-       }
-
-       return 0;
-}
-#endif                                                 /* CONFIG_NET_IPv4 */
-
-/****************************************************************************
- * Function: net_ipv6_match
- *
- * Description:
- *   Return 1 if the IPv6 route is available
- *
- * Parameters:
- *   route - The next route to examine
- *   arg   - The match values (cast to void*)
- *
- * Returned Value:
- *   0 if the entry is not a match; 1 if the entry matched and was cleared.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv6
-static int net_ipv6_match(FAR struct net_route_s *route, FAR void *arg)
-{
-#if 1
-#warning Missing logic
-#else
-       FAR struct route_ipv4_match_s *match = (FAR struct route_ipv4_match_s *)arg;
-
-       /* To match, the masked target addresses must be the same.  In the event
-        * of multiple matches, only the first is returned.  There is not (yet) any
-        * concept for the precedence of networks.
-        */
-
-       if (net_ipv6ddr_maskcmp(route->target, match->target, route->netmask)) {
-               /* They match.. Copy the router address */
-
-               net_ipv6addr_copy(match->router, route->router);
-               return 1;
-       }
-#endif
-
-       return 0;
-}
-#endif                                                 /* CONFIG_NET_IPv6 */
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Function: net_ipv4_router
- *
- * Description:
- *   Given an IPv4 address on a external network, return the address of the
- *   router on a local network that can forward to the external network.
- *
- * Parameters:
- *   target - An IPv4 address on a remote network to use in the lookup.
- *   router - The address of router on a local network that can forward our
- *     packets to the target.
- *
- * Returned Value:
- *   OK on success; Negated errno on failure.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv4
-int net_ipv4_router(in_addr_t target, FAR in_addr_t *router)
-{
-       struct route_ipv4_match_s match;
-       int ret;
-
-       /* Do not route the special broadcast IP address */
-
-       if (net_ipv4addr_cmp(target, g_ipv4_alloneaddr)) {
-               return -ENOENT;
-       }
-
-       /* Set up the comparison structure */
-
-       memset(&match, 0, sizeof(struct route_ipv4_match_s));
-       net_ipv4addr_copy(match.target, target);
-
-       /* Find an router entry with the routing table that can forward to this
-        * address
-        */
-
-       ret = net_foreachroute(net_ipv4_match, &match);
-       if (ret > 0) {
-               /* We found a route.  Return the router address. */
-
-               net_ipv4addr_copy(*router, match.router);
-               ret = OK;
-       } else {
-               /* There is no route for this address */
-
-               ret = -ENOENT;
-       }
-
-       return ret;
-}
-#endif                                                 /* CONFIG_NET_IPv4 */
-
-/****************************************************************************
- * Function: net_ipv6_router
- *
- * Description:
- *   Given an IPv6 address on a external network, return the address of the
- *   router on a local network that can forward to the external network.
- *
- * Parameters:
- *   target - An IPv6 address on a remote network to use in the lookup.
- *   router - The address of router on a local network that can forward our
- *     packets to the target.
- *
- * Returned Value:
- *   OK on success; Negated errno on failure.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv6
-int net_ipv6_router(net_ipv6addr_t target, net_ipv6addr_t router)
-{
-       struct route_ipv6_match_s match;
-       int ret;
-
-       /* Do not route the special broadcast IP address */
-
-       if (net_ipv6addr_cmp(target, g_ipv6_alloneaddr)) {
-               return -ENOENT;
-       }
-
-       /* Set up the comparison structure */
-
-       memset(&match, 0, sizeof(struct route_ipv6_match_s));
-       net_ipv6addr_copy(match.target, target);
-
-       /* Find an router entry with the routing table that can forward to this
-        * address
-        */
-
-       ret = net_foreachroute(net_ipv6_match, &match);
-       if (ret > 0) {
-               /* We found a route.  Return the router address. */
-
-               net_ipv6addr_copy(router, match.router);
-               ret = OK;
-       } else {
-               /* There is no route for this address */
-
-               ret = -ENOENT;
-       }
-
-       return ret;
-}
-#endif                                                 /* CONFIG_NET_IPv6 */
-
-#endif                                                 /* CONFIG_NET && CONFIG_NET_ROUTE */
diff --git a/os/net/route/netdev_router.c b/os/net/route/netdev_router.c
deleted file mode 100644 (file)
index ac77967..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * net/route/netdev_router.c
- *
- *   Copyright (C) 2013-2015 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 <tinyara/config.h>
-
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-
-#include <tinyara/net/ip.h>
-
-#include <net/lwip/netif.h>
-#include "netdev/netdev.h"
-#include "route/route.h"
-
-#if defined(CONFIG_NET) && defined(CONFIG_NET_ROUTE)
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv4
-struct route_ipv4_devmatch_s {
-       FAR struct netif *dev;          /* The route must use this device */
-       in_addr_t target;                       /* Target IPv4 address on an external network to match */
-       in_addr_t router;                       /* IPv6 address of the router on one of our networks */
-};
-#endif
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Function: net_ipv4_devmatch
- *
- * Description:
- *   Return 1 if the IPv4 route is available on the device's network.
- *
- * Parameters:
- *   route - The next route to examine
- *   arg   - The match values (cast to void*)
- *
- * Returned Value:
- *   0 if the entry is not a match; 1 if the entry matched and was cleared.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv4
-static int net_ipv4_devmatch(FAR struct net_route_s *route, FAR void *arg)
-{
-       FAR struct route_ipv4_devmatch_s *match = (FAR struct route_ipv4_devmatch_s *)arg;
-       FAR struct netif *dev = match->dev;
-
-       /* To match, (1) the masked target addresses must be the same, and (2) the
-        * router address must like on the network provided by the device.
-        *
-        * In the event of multiple matches, only the first is returned.  There
-        * not (yet) any concept for the precedence of networks.
-        */
-
-       if (net_ipv4addr_maskcmp(route->target, match->target, route->netmask) && net_ipv4addr_maskcmp(route->router, dev->d_ipaddr, dev->d_netmask)) {
-               /* They match.. Copy the router address */
-
-               net_ipv4addr_copy(match->router, route->router);
-               return 1;
-       }
-
-       return 0;
-}
-#endif                                                 /* CONFIG_NET_IPv4 */
-
-/****************************************************************************
- * Function: net_ipv6_devmatch
- *
- * Description:
- *   Return 1 if the IPv6 route is available on the device's network.
- *
- * Parameters:
- *   route - The next route to examine
- *   arg   - The match values (cast to void*)
- *
- * Returned Value:
- *   0 if the entry is not a match; 1 if the entry matched and was cleared.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv6
-static int net_ipv6_devmatch(FAR struct net_route_s *route, FAR void *arg)
-{
-#if 1
-#warning Missing logic
-#else
-       FAR struct route_ipv6_devmatch_s *match = (FAR struct route_ipv6_devmatch_s *)arg;
-       FAR struct netif *dev = match->dev;
-
-       /* To match, (1) the masked target addresses must be the same, and (2) the
-        * router address must like on the network provided by the device.
-        *
-        * In the event of multiple matches, only the first is returned.  There
-        * not (yet) any concept for the precedence of networks.
-        */
-
-       if (net_ipv6addr_maskcmp(route->target, match->target, route->netmask) && net_ipv6addr_maskcmp(route->router, dev->d_ipaddr, dev->d_netmask)) {
-               /* They match.. Copy the router address */
-
-               net_ipv6addr_copy(match->router, route->router);
-               return 1;
-       }
-#endif
-
-       return 0;
-}
-#endif                                                 /* CONFIG_NET_IPv6 */
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Function: netdev_ipv4_router
- *
- * Description:
- *   Given an IPv4 address on a external network, return the address of the
- *   router on a local network that can forward to the external network.
- *   This is similar to net_ipv4_router().  However, the set of routers is
- *   constrained to those accessible by the specific device
- *
- * Parameters:
- *   dev    - We are committed to using this device.
- *   target - An IPv4 address on a remote network to use in the lookup.
- *   router - The address of router on a local network that can forward our
- *     packets to the target.
- *
- * Returned Value:
- *   A router address is always returned (which may just be, perhaps,
- *   device's default router address)
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv4
-void netdev_ipv4_router(FAR struct netif *dev, in_addr_t target, FAR in_addr_t *router)
-{
-       struct route_ipv4_devmatch_s match;
-       int ret;
-
-       /* Set up the comparison structure */
-
-       memset(&match, 0, sizeof(struct route_ipv4_devmatch_s));
-       match.dev = dev;
-       net_ipv4addr_copy(match.target, target);
-
-       /* Find an router entry with the routing table that can forward to this
-        * address using this device.
-        */
-
-       ret = net_foreachroute(net_ipv4_devmatch, &match);
-       if (ret > 0) {
-               /* We found a route.  Return the router address. */
-
-               net_ipv4addr_copy(*router, match.target);
-       } else {
-               /* There isn't a matching route.. fallback and use the default router
-                * of the device.
-                */
-
-               net_ipv4addr_copy(*router, dev->d_draddr);
-       }
-}
-#endif
-
-/****************************************************************************
- * Function: netdev_ipv6_router
- *
- * Description:
- *   Given an IPv6 address on a external network, return the address of the
- *   router on a local network that can forward to the external network.
- *   This is similar to net_ipv6_router().  However, the set of routers is
- *   constrained to those accessible by the specific device
- *
- * Parameters:
- *   dev    - We are committed to using this device.
- *   target - An IPv6 address on a remote network to use in the lookup.
- *   router - The address of router on a local network that can forward our
- *     packets to the target.
- *
- * Returned Value:
- *   A router address is always returned (which may just be, perhaps,
- *   device's default router address)
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv6
-void netdev_ipv6_router(FAR struct netif *dev, FAR const net_ipv6addr_t target, FAR net_ipv6addr_t router)
-{
-       struct route_ipv6_devmatch_s match;
-       int ret;
-
-       /* Set up the comparison structure */
-
-       memset(&match, 0, sizeof(struct route_ipv6_devmatch_s));
-       match.dev = dev;
-       net_ipv6addr_copy(match.target, target);
-
-       /* Find an router entry with the routing table that can forward to this
-        * address using this device.
-        */
-
-       ret = net_foreachroute(net_ipv6_devmatch, &match);
-       if (ret > 0) {
-               /* We found a route.  Return the router address. */
-
-               net_ipv6addr_copy(router, match.target);
-       } else {
-               /* There isn't a matching route.. fallback and use the default router
-                * of the device.
-                */
-
-               net_ipv6addr_copy(router, dev->d_draddr);
-       }
-}
-#endif
-
-#endif                                                 /* CONFIG_NET && CONFIG_NET_ROUTE */
diff --git a/os/net/route/route.h b/os/net/route/route.h
deleted file mode 100644 (file)
index 0ee3919..0000000
+++ /dev/null
@@ -1,313 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the specific
- * language governing permissions and limitations under the License.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * net/route/route.h
- *
- *   Copyright (C) 2013-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.
- *
- ****************************************************************************/
-
-#ifndef __NET_ROUTE_ROUTE_H
-#define __NET_ROUTE_ROUTE_H
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <tinyara/config.h>
-
-#include <queue.h>
-
-#include <net/if.h>
-
-#include <tinyara/net/ip.h>
-
-#ifdef CONFIG_NET_ROUTE
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-/* Configuration ************************************************************/
-
-#ifndef CONFIG_NET_MAXROUTES
-#define CONFIG_NET_MAXROUTES 4
-#endif
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-/* This structure describes one entry in the routing table */
-
-struct net_route_s {
-       FAR struct net_route_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 */
-};
-
-/* Type of the call out function pointer provided to net_foreachroute() */
-
-typedef int (*route_handler_t)(FAR struct net_route_s *route, FAR void *arg);
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-#ifdef __cplusplus
-#define EXTERN extern "C"
-extern "C" {
-#else
-#define EXTERN extern
-#endif
-
-/* This is the routing table */
-
-EXTERN sq_queue_t g_routes;
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Function: net_initroute
- *
- * Description:
- *   Initialize to the routing table
- *
- * Parameters:
- *   None
- *
- * Returned Value:
- *   None
- *
- ****************************************************************************/
-
-void net_initroute(void);
-
-/****************************************************************************
- * Function: net_allocroute
- *
- * Description:
- *   Allocate one route by removing it from the free list
- *
- * Parameters:
- *   None
- *
- * Returned Value:
- *   On success, a pointer to the newly allocated route table entry is
- *   returned; NULL is returned on failure.
- *
- ****************************************************************************/
-
-FAR struct net_route_s *net_allocroute(void);
-
-/****************************************************************************
- * Function: net_allocroute
- *
- * Description:
- *   Free one route by adding it from the free list
- *
- * Parameters:
- *   route - The route to be freed
- *
- * Returned Value:
- *   None
- *
- ****************************************************************************/
-
-void net_freeroute(FAR struct net_route_s *route);
-
-/****************************************************************************
- * Function: net_addroute
- *
- * Description:
- *   Add a new route to the routing table
- *
- * Parameters:
- *   target   - The destination IP address on the destination network
- *   netmask  - The mask defining the destination sub-net
- *   router   - The IP address on one of our networks that provides the
- *              router to the external network
- *
- * Returned Value:
- *   OK on success; Negated errno on failure.
- *
- ****************************************************************************/
-
-int net_addroute(in_addr_t target, in_addr_t netmask, in_addr_t router);
-
-/****************************************************************************
- * Function: net_delroute
- *
- * Description:
- *   Remove an existing route from the routing table
- *
- * Parameters:
- *
- * Returned Value:
- *   OK on success; Negated errno on failure.
- *
- ****************************************************************************/
-
-int net_delroute(in_addr_t target, in_addr_t netmask);
-
-/****************************************************************************
- * Function: net_ipv4_router
- *
- * Description:
- *   Given an IPv4 address on a external network, return the address of the
- *   router on a local network that can forward to the external network.
- *
- * Parameters:
- *   target - An IPv4 address on a remote network to use in the lookup.
- *   router - The address of router on a local network that can forward our
- *     packets to the target.
- *
- * Returned Value:
- *   OK on success; Negated errno on failure.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv4
-int net_ipv4_router(in_addr_t target, FAR in_addr_t *router);
-#endif
-
-/****************************************************************************
- * Function: net_ipv6_router
- *
- * Description:
- *   Given an IPv6 address on a external network, return the address of the
- *   router on a local network that can forward to the external network.
- *
- * Parameters:
- *   target - An IPv6 address on a remote network to use in the lookup.
- *   router - The address of router on a local network that can forward our
- *     packets to the target.
- *
- * Returned Value:
- *   OK on success; Negated errno on failure.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv6
-int net_ipv6_router(net_ipv6addr_t target, net_ipv6addr_t router);
-#endif
-
-/****************************************************************************
- * Function: netdev_ipv4_router
- *
- * Description:
- *   Given an IPv4 address on a external network, return the address of the
- *   router on a local network that can forward to the external network.
- *   This is similar to net_ipv4_router().  However, the set of routers is
- *   constrained to those accessible by the specific device
- *
- * Parameters:
- *   dev    - We are committed to using this device.
- *   target - An IPv4 address on a remote network to use in the lookup.
- *   router - The address of router on a local network that can forward our
- *     packets to the target.
- *
- * Returned Value:
- *   A router address is always returned (which may just be, perhaps,
- *   device's default router address)
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv4
-struct netif;
-void netdev_ipv4_router(FAR struct netif *dev, in_addr_t target, FAR in_addr_t *router);
-#endif
-
-/****************************************************************************
- * Function: netdev_ipv6_router
- *
- * Description:
- *   Given an IPv6 address on a external network, return the address of the
- *   router on a local network that can forward to the external network.
- *   This is similar to net_ipv6_router().  However, the set of routers is
- *   constrained to those accessible by the specific device
- *
- * Parameters:
- *   dev    - We are committed to using this device.
- *   target - An IPv6 address on a remote network to use in the lookup.
- *   router - The address of router on a local network that can forward our
- *     packets to the target.
- *
- * Returned Value:
- *   A router address is always returned (which may just be, perhaps,
- *   device's default router address)
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_IPv6
-struct netif;
-void netdev_ipv6_router(FAR struct netif *dev, FAR const net_ipv6addr_t target, FAR net_ipv6addr_t router);
-#endif
-
-/****************************************************************************
- * Function: net_foreachroute
- *
- * Description:
- *   Traverse the route table
- *
- * Parameters:
- *
- * Returned Value:
- *   OK on success; Negated errno on failure.
- *
- ****************************************************************************/
-
-int net_foreachroute(route_handler_t handler, FAR void *arg);
-
-#undef EXTERN
-#ifdef __cplusplus
-}
-#endif
-
-#endif                                                 /* CONFIG_NET_ROUTE */
-#endif                                                 /* __NET_ROUTE_ROUTE_H */