From d181bd9e6ff8b5468522c0370177ee895fecf4f2 Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Thu, 20 Aug 2015 17:00:47 +0200 Subject: [PATCH] added config for enabling/disabling removal of oldest route and added support function for checking if lladdress is used as nexthop --- core/net/ipv6/uip-ds6-route.c | 17 ++++++++++++++--- core/net/ipv6/uip-ds6-route.h | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core/net/ipv6/uip-ds6-route.c b/core/net/ipv6/uip-ds6-route.c index 3f4ac81e7..3113986a1 100644 --- a/core/net/ipv6/uip-ds6-route.c +++ b/core/net/ipv6/uip-ds6-route.c @@ -207,6 +207,12 @@ uip_ds6_route_next(uip_ds6_route_t *r) } /*---------------------------------------------------------------------------*/ int +uip_ds6_route_is_nexthop(const uip_lladdr_t *lladdr) +{ + return nbr_table_get_from_lladdr(nbr_routes, (linkaddr_t *)lladdr) != NULL; +} +/*---------------------------------------------------------------------------*/ +int uip_ds6_route_num_routes(void) { return num_routes; @@ -307,11 +313,16 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length, least recently used one we have. */ if(uip_ds6_route_num_routes() == UIP_DS6_ROUTE_NB) { + uip_ds6_route_t *oldest; + oldest = NULL; +#if UIP_DS6_ROUTE_REMOVE_LEAST_RECENTLY_USED /* Removing the oldest route entry from the route table. The least recently used route is the first route on the list. */ - uip_ds6_route_t *oldest; - - oldest = list_tail(routelist); /* uip_ds6_route_head(); */ + oldest = list_tail(routelist); +#endif + if(oldest == NULL) { + return NULL; + } PRINTF("uip_ds6_route_add: dropping route to "); PRINT6ADDR(&oldest->ipaddr); PRINTF("\n"); diff --git a/core/net/ipv6/uip-ds6-route.h b/core/net/ipv6/uip-ds6-route.h index 8df18796b..3324a8e08 100644 --- a/core/net/ipv6/uip-ds6-route.h +++ b/core/net/ipv6/uip-ds6-route.h @@ -197,7 +197,7 @@ uip_ipaddr_t *uip_ds6_route_nexthop(uip_ds6_route_t *); int uip_ds6_route_num_routes(void); uip_ds6_route_t *uip_ds6_route_head(void); uip_ds6_route_t *uip_ds6_route_next(uip_ds6_route_t *); - +int uip_ds6_route_is_nexthop(const uip_lladdr_t *lladdr); /** @} */ #endif /* UIP_DS6_ROUTE_H */