Make uip-ds6-route use neighbor table. Instead of storing a global list of routing entries that contain both the next hop and the destination, we have a separate list of reachable destination for each neighbor in the global table.
This commit is contained in:
parent
ec609b49eb
commit
09d26f8060
5 changed files with 167 additions and 89 deletions
|
@ -243,6 +243,13 @@ dio_input(void)
|
||||||
PRINTF(", ");
|
PRINTF(", ");
|
||||||
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||||
PRINTF("\n");
|
PRINTF("\n");
|
||||||
|
} else {
|
||||||
|
PRINTF("RPL: Out of Memory, dropping DIO from ");
|
||||||
|
PRINT6ADDR(&from);
|
||||||
|
PRINTF(", ");
|
||||||
|
PRINTLLADDR((uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||||
|
PRINTF("\n");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PRINTF("RPL: Neighbor already in neighbor cache\n");
|
PRINTF("RPL: Neighbor already in neighbor cache\n");
|
||||||
|
@ -657,11 +664,11 @@ dao_input(void)
|
||||||
|
|
||||||
if(lifetime == RPL_ZERO_LIFETIME) {
|
if(lifetime == RPL_ZERO_LIFETIME) {
|
||||||
/* No-Path DAO received; invoke the route purging routine. */
|
/* No-Path DAO received; invoke the route purging routine. */
|
||||||
if(rep != NULL && rep->state.saved_lifetime == 0 && rep->length == prefixlen && uip_ipaddr_cmp(&rep->nexthop, &dao_sender_addr)) {
|
if(rep != NULL && rep->state.nopath_received == 0 && rep->length == prefixlen && uip_ipaddr_cmp(&rep->nexthop, &dao_sender_addr)) {
|
||||||
PRINTF("RPL: Setting expiration timer for prefix ");
|
PRINTF("RPL: Setting expiration timer for prefix ");
|
||||||
PRINT6ADDR(&prefix);
|
PRINT6ADDR(&prefix);
|
||||||
PRINTF("\n");
|
PRINTF("\n");
|
||||||
rep->state.saved_lifetime = rep->state.lifetime;
|
rep->state.nopath_received = 1;
|
||||||
rep->state.lifetime = DAO_EXPIRATION_TIMEOUT;
|
rep->state.lifetime = DAO_EXPIRATION_TIMEOUT;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -67,7 +67,7 @@ rpl_purge_routes(void)
|
||||||
rpl_dag_t *dag;
|
rpl_dag_t *dag;
|
||||||
|
|
||||||
/* First pass, decrement lifetime */
|
/* First pass, decrement lifetime */
|
||||||
r = uip_ds6_route_list_head();
|
r = uip_ds6_route_head();
|
||||||
|
|
||||||
while(r != NULL) {
|
while(r != NULL) {
|
||||||
if(r->state.lifetime >= 1) {
|
if(r->state.lifetime >= 1) {
|
||||||
|
@ -78,11 +78,11 @@ rpl_purge_routes(void)
|
||||||
*/
|
*/
|
||||||
r->state.lifetime--;
|
r->state.lifetime--;
|
||||||
}
|
}
|
||||||
r = list_item_next(r);
|
r = uip_ds6_route_next(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Second pass, remove dead routes */
|
/* Second pass, remove dead routes */
|
||||||
r = uip_ds6_route_list_head();
|
r = uip_ds6_route_head();
|
||||||
|
|
||||||
while(r != NULL) {
|
while(r != NULL) {
|
||||||
if(r->state.lifetime < 1) {
|
if(r->state.lifetime < 1) {
|
||||||
|
@ -90,7 +90,7 @@ rpl_purge_routes(void)
|
||||||
* thus we want to keep them. Hence < and not <= */
|
* thus we want to keep them. Hence < and not <= */
|
||||||
uip_ipaddr_copy(&prefix, &r->ipaddr);
|
uip_ipaddr_copy(&prefix, &r->ipaddr);
|
||||||
uip_ds6_route_rm(r);
|
uip_ds6_route_rm(r);
|
||||||
r = uip_ds6_route_list_head();
|
r = uip_ds6_route_head();
|
||||||
PRINTF("No more routes to ");
|
PRINTF("No more routes to ");
|
||||||
PRINT6ADDR(&prefix);
|
PRINT6ADDR(&prefix);
|
||||||
dag = default_instance->current_dag;
|
dag = default_instance->current_dag;
|
||||||
|
@ -103,7 +103,7 @@ rpl_purge_routes(void)
|
||||||
}
|
}
|
||||||
PRINTF("\n");
|
PRINTF("\n");
|
||||||
} else {
|
} else {
|
||||||
r = list_item_next(r);
|
r = uip_ds6_route_next(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,14 +113,14 @@ rpl_remove_routes(rpl_dag_t *dag)
|
||||||
{
|
{
|
||||||
uip_ds6_route_t *r;
|
uip_ds6_route_t *r;
|
||||||
|
|
||||||
r = uip_ds6_route_list_head();
|
r = uip_ds6_route_head();
|
||||||
|
|
||||||
while(r != NULL) {
|
while(r != NULL) {
|
||||||
if(r->state.dag == dag) {
|
if(r->state.dag == dag) {
|
||||||
uip_ds6_route_rm(r);
|
uip_ds6_route_rm(r);
|
||||||
r = uip_ds6_route_list_head();
|
r = uip_ds6_route_head();
|
||||||
} else {
|
} else {
|
||||||
r = list_item_next(r);
|
r = uip_ds6_route_next(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,15 +130,15 @@ rpl_remove_routes_by_nexthop(uip_ipaddr_t *nexthop, rpl_dag_t *dag)
|
||||||
{
|
{
|
||||||
uip_ds6_route_t *r;
|
uip_ds6_route_t *r;
|
||||||
|
|
||||||
r = uip_ds6_route_list_head();
|
r = uip_ds6_route_head();
|
||||||
|
|
||||||
while(r != NULL) {
|
while(r != NULL) {
|
||||||
if(uip_ipaddr_cmp(&r->nexthop, nexthop) &&
|
if(uip_ipaddr_cmp(uip_ds6_route_nexthop(r), nexthop) &&
|
||||||
r->state.dag == dag) {
|
r->state.dag == dag) {
|
||||||
uip_ds6_route_rm(r);
|
uip_ds6_route_rm(r);
|
||||||
r = uip_ds6_route_list_head();
|
r = uip_ds6_route_head();
|
||||||
} else {
|
} else {
|
||||||
r = list_item_next(r);
|
r = uip_ds6_route_next(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ANNOTATE("#L %u 0\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
|
ANNOTATE("#L %u 0\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
|
||||||
|
@ -150,20 +150,11 @@ rpl_add_route(rpl_dag_t *dag, uip_ipaddr_t *prefix, int prefix_len,
|
||||||
{
|
{
|
||||||
uip_ds6_route_t *rep;
|
uip_ds6_route_t *rep;
|
||||||
|
|
||||||
rep = uip_ds6_route_lookup(prefix);
|
if((rep = uip_ds6_route_add(prefix, prefix_len, next_hop)) == NULL) {
|
||||||
if(rep == NULL) {
|
|
||||||
if((rep = uip_ds6_route_add(prefix, prefix_len, next_hop, 0)) == NULL) {
|
|
||||||
PRINTF("RPL: No space for more route entries\n");
|
PRINTF("RPL: No space for more route entries\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
PRINTF("RPL: Updated the next hop for prefix ");
|
|
||||||
PRINT6ADDR(prefix);
|
|
||||||
PRINTF(" to ");
|
|
||||||
PRINT6ADDR(next_hop);
|
|
||||||
PRINTF("\n");
|
|
||||||
uip_ipaddr_copy(&rep->nexthop, next_hop);
|
|
||||||
}
|
|
||||||
rep->state.dag = dag;
|
rep->state.dag = dag;
|
||||||
rep->state.lifetime = RPL_LIFETIME(dag->instance, dag->instance->default_lifetime);
|
rep->state.lifetime = RPL_LIFETIME(dag->instance, dag->instance->default_lifetime);
|
||||||
rep->state.learned_from = RPL_ROUTE_FROM_INTERNAL;
|
rep->state.learned_from = RPL_ROUTE_FROM_INTERNAL;
|
||||||
|
|
|
@ -587,7 +587,7 @@ tcpip_ipv6_output(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nexthop = &locrt->nexthop;
|
nexthop = uip_ds6_route_nexthop(locrt);
|
||||||
}
|
}
|
||||||
if(nexthop != NULL) {
|
if(nexthop != NULL) {
|
||||||
PRINTF("tcpip_ipv6_output: next hop ");
|
PRINTF("tcpip_ipv6_output: next hop ");
|
||||||
|
|
|
@ -34,12 +34,15 @@
|
||||||
|
|
||||||
#include "lib/list.h"
|
#include "lib/list.h"
|
||||||
#include "lib/memb.h"
|
#include "lib/memb.h"
|
||||||
|
#include "net/neighbor-table.h"
|
||||||
|
|
||||||
#if UIP_CONF_IPV6
|
#if UIP_CONF_IPV6
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
LIST(routelist);
|
void uip_ds6_route_rm_routelist(list_t nbr_table_get_from_lladdr);
|
||||||
|
|
||||||
|
NEIGHBOR_TABLE(uip_ds6_route_t *, nbr_routes);
|
||||||
MEMB(routememb, uip_ds6_route_t, UIP_DS6_ROUTE_NB);
|
MEMB(routememb, uip_ds6_route_t, UIP_DS6_ROUTE_NB);
|
||||||
|
|
||||||
LIST(defaultrouterlist);
|
LIST(defaultrouterlist);
|
||||||
|
@ -49,6 +52,8 @@ MEMB(defaultroutermemb, uip_ds6_defrt_t, UIP_DS6_DEFRT_NB);
|
||||||
LIST(notificationlist);
|
LIST(notificationlist);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int num_routes = 0;
|
||||||
|
|
||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
#define DEBUG DEBUG_NONE
|
#define DEBUG DEBUG_NONE
|
||||||
#include "net/uip-debug.h"
|
#include "net/uip-debug.h"
|
||||||
|
@ -68,7 +73,7 @@ call_route_callback(int event, uip_ipaddr_t *route,
|
||||||
event == UIP_DS6_NOTIFICATION_DEFRT_RM) {
|
event == UIP_DS6_NOTIFICATION_DEFRT_RM) {
|
||||||
num = list_length(defaultrouterlist);
|
num = list_length(defaultrouterlist);
|
||||||
} else {
|
} else {
|
||||||
num = list_length(routelist);
|
num = num_routes;
|
||||||
}
|
}
|
||||||
n->callback(event, route, nexthop, num);
|
n->callback(event, route, nexthop, num);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +100,7 @@ void
|
||||||
uip_ds6_route_init(void)
|
uip_ds6_route_init(void)
|
||||||
{
|
{
|
||||||
memb_init(&routememb);
|
memb_init(&routememb);
|
||||||
list_init(routelist);
|
nbr_table_register(nbr_routes, (remove_callback_func *)uip_ds6_route_rm_routelist);
|
||||||
|
|
||||||
memb_init(&defaultroutermemb);
|
memb_init(&defaultroutermemb);
|
||||||
list_init(defaultrouterlist);
|
list_init(defaultrouterlist);
|
||||||
|
@ -105,16 +110,59 @@ uip_ds6_route_init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
uip_ds6_route_t *
|
static uip_lladdr_t *
|
||||||
uip_ds6_route_list_head(void)
|
uip_ds6_route_nexthop_lladdr(uip_ds6_route_t *route)
|
||||||
{
|
{
|
||||||
return list_head(routelist);
|
if(route != NULL) {
|
||||||
|
return (uip_lladdr_t *)nbr_table_get_lladdr(nbr_routes, route->route_list);
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
uip_ipaddr_t *
|
||||||
|
uip_ds6_route_nexthop(uip_ds6_route_t *route)
|
||||||
|
{
|
||||||
|
if(route != NULL) {
|
||||||
|
return uip_ds6_nbr_ipaddr_from_lladdr(uip_ds6_route_nexthop_lladdr(route));
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
uip_ds6_route_t *
|
||||||
|
uip_ds6_route_head(void)
|
||||||
|
{
|
||||||
|
list_t nbr_route_list = nbr_table_head(nbr_routes);
|
||||||
|
if(nbr_route_list != NULL) {
|
||||||
|
return list_head((list_t)nbr_route_list);
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
uip_ds6_route_t *
|
||||||
|
uip_ds6_route_next(uip_ds6_route_t *r)
|
||||||
|
{
|
||||||
|
if(r != NULL) {
|
||||||
|
uip_ds6_route_t *n = list_item_next(r);
|
||||||
|
if(n != NULL) {
|
||||||
|
return n;
|
||||||
|
} else {
|
||||||
|
list_t nbr_route_list = nbr_table_next(nbr_routes, r->route_list);
|
||||||
|
if(nbr_route_list != NULL) {
|
||||||
|
return list_head((list_t)nbr_route_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int
|
int
|
||||||
uip_ds6_route_num_routes(void)
|
uip_ds6_route_num_routes(void)
|
||||||
{
|
{
|
||||||
return list_length(routelist);
|
return num_routes;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
uip_ds6_route_t *
|
uip_ds6_route_t *
|
||||||
|
@ -131,22 +179,21 @@ uip_ds6_route_lookup(uip_ipaddr_t *addr)
|
||||||
|
|
||||||
found_route = NULL;
|
found_route = NULL;
|
||||||
longestmatch = 0;
|
longestmatch = 0;
|
||||||
for(r = list_head(routelist);
|
for(r = uip_ds6_route_head();
|
||||||
r != NULL;
|
r != NULL;
|
||||||
r = list_item_next(r)) {
|
r = uip_ds6_route_next(r)) {
|
||||||
if(r->length >= longestmatch &&
|
if(r->length >= longestmatch &&
|
||||||
uip_ipaddr_prefixcmp(addr, &r->ipaddr, r->length)) {
|
uip_ipaddr_prefixcmp(addr, &r->ipaddr, r->length)) {
|
||||||
longestmatch = r->length;
|
longestmatch = r->length;
|
||||||
found_route = r;
|
found_route = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(found_route != NULL) {
|
if(found_route != NULL) {
|
||||||
PRINTF("uip-ds6-route: Found route:");
|
PRINTF("uip-ds6-route: Found route: ");
|
||||||
PRINT6ADDR(addr);
|
PRINT6ADDR(addr);
|
||||||
PRINTF(" via ");
|
PRINTF(" via ");
|
||||||
PRINT6ADDR(&found_route->nexthop);
|
PRINT6ADDR(uip_ds6_route_nexthop(found_route));
|
||||||
PRINTF("\n");
|
PRINTF("\n");
|
||||||
} else {
|
} else {
|
||||||
PRINTF("uip-ds6-route: No route found\n");
|
PRINTF("uip-ds6-route: No route found\n");
|
||||||
|
@ -157,9 +204,22 @@ uip_ds6_route_lookup(uip_ipaddr_t *addr)
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
uip_ds6_route_t *
|
uip_ds6_route_t *
|
||||||
uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
||||||
uip_ipaddr_t *nexthop, uint8_t metric)
|
uip_ipaddr_t *nexthop)
|
||||||
{
|
{
|
||||||
uip_ds6_route_t *r;
|
uip_ds6_route_t *r;
|
||||||
|
list_t nbr_route_list;
|
||||||
|
|
||||||
|
/* Get link-layer address of next hop, make sure it is in neighbor table */
|
||||||
|
uip_lladdr_t *nexthop_lladdr = uip_ds6_nbr_lladdr_from_ipaddr(nexthop);
|
||||||
|
if(nexthop_lladdr == NULL) {
|
||||||
|
PRINTF("uip_ds6_route_add: neighbor link-local address unknown ");
|
||||||
|
PRINT6ADDR(ipaddr);
|
||||||
|
PRINTF("\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get routing entry list of this neighbor */
|
||||||
|
nbr_route_list = nbr_table_get_from_lladdr(nbr_routes, (rimeaddr_t *)nexthop_lladdr);
|
||||||
|
|
||||||
/* First make sure that we don't add a route twice. If we find an
|
/* First make sure that we don't add a route twice. If we find an
|
||||||
existing route for our destination, we'll just update the old
|
existing route for our destination, we'll just update the old
|
||||||
|
@ -170,6 +230,18 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
||||||
PRINT6ADDR(ipaddr);
|
PRINT6ADDR(ipaddr);
|
||||||
PRINTF("\n");
|
PRINTF("\n");
|
||||||
} else {
|
} else {
|
||||||
|
/* If there is no routing entry, create one */
|
||||||
|
if(nbr_route_list == NULL) {
|
||||||
|
nbr_route_list = nbr_table_add_lladdr(nbr_routes, (rimeaddr_t *)nexthop_lladdr);
|
||||||
|
if(nbr_route_list == NULL) {
|
||||||
|
PRINTF("uip_ds6_route_add: could not allocate memory (route list) for new route to ");
|
||||||
|
PRINT6ADDR(ipaddr);
|
||||||
|
PRINTF(", dropping it\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
list_init((list_t)nbr_route_list);
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate a routing entry and add the route to the list */
|
/* Allocate a routing entry and add the route to the list */
|
||||||
r = memb_alloc(&routememb);
|
r = memb_alloc(&routememb);
|
||||||
if(r == NULL) {
|
if(r == NULL) {
|
||||||
|
@ -178,15 +250,16 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
||||||
PRINTF(", dropping it\n");
|
PRINTF(", dropping it\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
list_add(routelist, r);
|
/* Add the route to this neighbor */
|
||||||
|
list_add((list_t)nbr_route_list, r);
|
||||||
|
num_routes++;
|
||||||
|
|
||||||
PRINTF("uip_ds6_route_add num %d\n", list_length(routelist));
|
PRINTF("uip_ds6_route_add num %d\n", num_routes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r->route_list = nbr_route_list;
|
||||||
uip_ipaddr_copy(&(r->ipaddr), ipaddr);
|
uip_ipaddr_copy(&(r->ipaddr), ipaddr);
|
||||||
r->length = length;
|
r->length = length;
|
||||||
uip_ipaddr_copy(&(r->nexthop), nexthop);
|
|
||||||
r->metric = metric;
|
|
||||||
|
|
||||||
#ifdef UIP_DS6_ROUTE_STATE_TYPE
|
#ifdef UIP_DS6_ROUTE_STATE_TYPE
|
||||||
memset(&r->state, 0, sizeof(UIP_DS6_ROUTE_STATE_TYPE));
|
memset(&r->state, 0, sizeof(UIP_DS6_ROUTE_STATE_TYPE));
|
||||||
|
@ -210,57 +283,61 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
||||||
void
|
void
|
||||||
uip_ds6_route_rm(uip_ds6_route_t *route)
|
uip_ds6_route_rm(uip_ds6_route_t *route)
|
||||||
{
|
{
|
||||||
uip_ds6_route_t *r;
|
if(route != NULL && route->route_list != NULL) {
|
||||||
/* Make sure that the route is in the list before removing it. */
|
|
||||||
for(r = list_head(routelist);
|
if(list_head((list_t)route->route_list) == NULL) {
|
||||||
r != NULL;
|
/* If this was the only route using this neighbor, remove the neibhor from the table */
|
||||||
r = list_item_next(r)) {
|
nbr_table_remove(nbr_routes, route->route_list);
|
||||||
if(r == route) {
|
}
|
||||||
list_remove(routelist, route);
|
list_remove((list_t)route->route_list, route);
|
||||||
memb_free(&routememb, route);
|
memb_free(&routememb, route);
|
||||||
|
|
||||||
PRINTF("uip_ds6_route_rm num %d\n", list_length(routelist));
|
num_routes--;
|
||||||
|
|
||||||
|
PRINTF("uip_ds6_route_rm num %d\n", num_routes);
|
||||||
|
|
||||||
#if UIP_DS6_NOTIFICATIONS
|
#if UIP_DS6_NOTIFICATIONS
|
||||||
call_route_callback(UIP_DS6_NOTIFICATION_ROUTE_RM,
|
call_route_callback(UIP_DS6_NOTIFICATION_ROUTE_RM,
|
||||||
&route->ipaddr, &route->nexthop);
|
&route->ipaddr, uip_ds6_route_nexthop(route));
|
||||||
#endif
|
#endif
|
||||||
#if (DEBUG & DEBUG_ANNOTATE) == DEBUG_ANNOTATE
|
#if (DEBUG & DEBUG_ANNOTATE) == DEBUG_ANNOTATE
|
||||||
/* we need to check if this was the last route towards "nexthop" */
|
/* we need to check if this was the last route towards "nexthop" */
|
||||||
/* if so - remove that link (annotation) */
|
/* if so - remove that link (annotation) */
|
||||||
for(r = list_head(routelist);
|
for(r = uip_ds6_route_head();
|
||||||
r != NULL;
|
r != NULL;
|
||||||
r = list_item_next(r)) {
|
r = uip_ds6_route_next(r)) {
|
||||||
if(uip_ipaddr_cmp(&r->nexthop, &route->nexthop)) {
|
if(uip_ipaddr_cmp(uip_ds6_route_nexthop(r), uip_ds6_route_nexthop(route))) {
|
||||||
/* we found another link using the specific nexthop, so keep the #L */
|
/* we found another link using the specific nexthop, so keep the #L */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ANNOTATE("#L %u 0\n", route->nexthop.u8[sizeof(uip_ipaddr_t) - 1]);
|
ANNOTATE("#L %u 0\n", uip_ds6_route_nexthop(route)->u8[sizeof(uip_ipaddr_t) - 1]);
|
||||||
#endif
|
#endif
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
uip_ds6_route_rm_routelist(list_t nbr_route_list)
|
||||||
|
{
|
||||||
|
if(nbr_route_list != NULL) {
|
||||||
|
uip_ds6_route_t *r;
|
||||||
|
r = list_head((list_t)nbr_route_list);
|
||||||
|
while(r != NULL) {
|
||||||
|
uip_ds6_route_rm(r);
|
||||||
|
r = list_head((list_t)nbr_route_list);
|
||||||
|
}
|
||||||
|
nbr_table_remove(nbr_routes, nbr_route_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop)
|
uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop)
|
||||||
{
|
{
|
||||||
uip_ds6_route_t *r;
|
/* Get routing entry list of this neighbor */
|
||||||
|
uip_lladdr_t *nexthop_lladdr = uip_ds6_nbr_lladdr_from_ipaddr(nexthop);
|
||||||
r = list_head(routelist);
|
list_t nbr_route_list = nbr_table_get_from_lladdr(nbr_routes, (rimeaddr_t *)nexthop_lladdr);
|
||||||
while(r != NULL) {
|
uip_ds6_route_rm_routelist(nbr_route_list);
|
||||||
if(uip_ipaddr_cmp(&r->nexthop, nexthop)) {
|
|
||||||
list_remove(routelist, r);
|
|
||||||
#if UIP_DS6_NOTIFICATIONS
|
|
||||||
call_route_callback(UIP_DS6_NOTIFICATION_ROUTE_RM,
|
|
||||||
&r->ipaddr, &r->nexthop);
|
|
||||||
#endif
|
|
||||||
r = list_head(routelist);
|
|
||||||
} else {
|
|
||||||
r = list_item_next(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
uip_ds6_defrt_t *
|
uip_ds6_defrt_t *
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#ifndef UIP_DS6_ROUTE_H
|
#ifndef UIP_DS6_ROUTE_H
|
||||||
#define UIP_DS6_ROUTE_H
|
#define UIP_DS6_ROUTE_H
|
||||||
|
|
||||||
|
#include "lib/list.h"
|
||||||
|
|
||||||
void uip_ds6_route_init(void);
|
void uip_ds6_route_init(void);
|
||||||
|
|
||||||
#ifndef UIP_CONF_UIP_DS6_NOTIFICATIONS
|
#ifndef UIP_CONF_UIP_DS6_NOTIFICATIONS
|
||||||
|
@ -84,9 +86,9 @@ void uip_ds6_notification_rm(struct uip_ds6_notification *n);
|
||||||
/* Needed for the extended route entry state when using ContikiRPL */
|
/* Needed for the extended route entry state when using ContikiRPL */
|
||||||
typedef struct rpl_route_entry {
|
typedef struct rpl_route_entry {
|
||||||
uint32_t lifetime;
|
uint32_t lifetime;
|
||||||
uint32_t saved_lifetime;
|
|
||||||
void *dag;
|
void *dag;
|
||||||
uint8_t learned_from;
|
uint8_t learned_from;
|
||||||
|
uint8_t nopath_received;
|
||||||
} rpl_route_entry_t;
|
} rpl_route_entry_t;
|
||||||
#endif /* UIP_DS6_ROUTE_STATE_TYPE */
|
#endif /* UIP_DS6_ROUTE_STATE_TYPE */
|
||||||
|
|
||||||
|
@ -95,13 +97,12 @@ typedef struct rpl_route_entry {
|
||||||
/** \brief An entry in the routing table */
|
/** \brief An entry in the routing table */
|
||||||
typedef struct uip_ds6_route {
|
typedef struct uip_ds6_route {
|
||||||
struct uip_ds6_route *next;
|
struct uip_ds6_route *next;
|
||||||
|
list_t route_list; /* The list the routing entry belongs to. */
|
||||||
uip_ipaddr_t ipaddr;
|
uip_ipaddr_t ipaddr;
|
||||||
uip_ipaddr_t nexthop;
|
|
||||||
uint8_t length;
|
|
||||||
uint8_t metric;
|
|
||||||
#ifdef UIP_DS6_ROUTE_STATE_TYPE
|
#ifdef UIP_DS6_ROUTE_STATE_TYPE
|
||||||
UIP_DS6_ROUTE_STATE_TYPE state;
|
UIP_DS6_ROUTE_STATE_TYPE state;
|
||||||
#endif
|
#endif
|
||||||
|
uint8_t length;
|
||||||
} uip_ds6_route_t;
|
} uip_ds6_route_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,12 +131,14 @@ void uip_ds6_defrt_periodic(void);
|
||||||
/** @{ */
|
/** @{ */
|
||||||
uip_ds6_route_t *uip_ds6_route_lookup(uip_ipaddr_t *destipaddr);
|
uip_ds6_route_t *uip_ds6_route_lookup(uip_ipaddr_t *destipaddr);
|
||||||
uip_ds6_route_t *uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
uip_ds6_route_t *uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
||||||
uip_ipaddr_t *next_hop, uint8_t metric);
|
uip_ipaddr_t *next_hop);
|
||||||
void uip_ds6_route_rm(uip_ds6_route_t *route);
|
void uip_ds6_route_rm(uip_ds6_route_t *route);
|
||||||
void uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop);
|
void uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop);
|
||||||
|
|
||||||
|
uip_ipaddr_t *uip_ds6_route_nexthop(uip_ds6_route_t *);
|
||||||
int uip_ds6_route_num_routes(void);
|
int uip_ds6_route_num_routes(void);
|
||||||
uip_ds6_route_t *uip_ds6_route_list_head(void);
|
uip_ds6_route_t *uip_ds6_route_head(void);
|
||||||
|
uip_ds6_route_t *uip_ds6_route_next(uip_ds6_route_t *);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue