summaryrefslogtreecommitdiff
path: root/nuttx/net/net_delroute.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/net/net_delroute.c')
-rw-r--r--nuttx/net/net_delroute.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/nuttx/net/net_delroute.c b/nuttx/net/net_delroute.c
index 08d9ad154..b203f0349 100644
--- a/nuttx/net/net_delroute.c
+++ b/nuttx/net/net_delroute.c
@@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
+#include <string.h>
#include <errno.h>
#include <nuttx/net/route.h>
@@ -54,8 +55,8 @@
struct route_match_s
{
- uip_ipaddr_t target; /* The target IP address to match */
- FAR struct net_route_s *route; /* The location to return the route */
+ uip_ipaddr_t target; /* The target IP address to match */
+ uip_ipaddr_t netmask; /* The network mask to match */
};
/****************************************************************************
@@ -81,17 +82,17 @@ 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 entry has to be in use, the masked target addresses must
- * be the same. In the event of multiple matches, only the first is
- * returned.
+ /* To match, the entry has to be in use, the masked target address must
+ * be the same, and the masks must be the same.
*/
if (route->inuse &&
- uip_ipaddr_maskcmp(route->target, match->target, route>netmask))
+ uip_ipaddr_maskcmp(route->target, match->target, match->netmask) &&
+ uip_ipaddr_cmp(route->target, match->netmask))
{
/* They match.. clear the route table entry */
- memcpy(match->route, route, sizeof(struct net_route_s));
+ memset(route, 0, sizeof(struct net_route_s));
return 1;
}
@@ -103,10 +104,10 @@ static int net_match(FAR struct net_route_s *route, FAR void *arg)
****************************************************************************/
/****************************************************************************
- * Function: net_findroute
+ * Function: net_delroute
*
* Description:
- * Given an IP address, return a copy of the routing table contents
+ * Remove an existing route from the routing table
*
* Parameters:
*
@@ -115,7 +116,7 @@ static int net_match(FAR struct net_route_s *route, FAR void *arg)
*
****************************************************************************/
-int net_findroute(uip_ipaddr_t target, FAR struct net_route_s *route);
+int net_delroute(uip_ipaddr_t target, uip_ipaddr_t netmask)
{
struct route_match_s match;
@@ -129,4 +130,4 @@ int net_findroute(uip_ipaddr_t target, FAR struct net_route_s *route);
return net_foreachroute(net_match, &match) ? OK : -ENOENT;
}
-#endif /* CONFIG_NET && CONFIG_NET_ROUTE */
+#endif /* CONFIG_NET && CONFIG_NET_SOCKOPTS && !CONFIG_DISABLE_CLOCK */