Implement RPL non-storing mode
This commit is contained in:
parent
d14b76d869
commit
b3e31e1456
17 changed files with 1149 additions and 278 deletions
|
@ -57,6 +57,7 @@ void NETSTACK_CONF_ROUTING_NEIGHBOR_ADDED_CALLBACK(const linkaddr_t *addr);
|
|||
void NETSTACK_CONF_ROUTING_NEIGHBOR_REMOVED_CALLBACK(const linkaddr_t *addr);
|
||||
#endif /* NETSTACK_CONF_ROUTING_NEIGHBOR_REMOVED_CALLBACK */
|
||||
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
/* The nbr_routes holds a neighbor table to be able to maintain
|
||||
information about what routes go through what neighbor. This
|
||||
neighbor table is registered with the central nbr-table repository
|
||||
|
@ -71,6 +72,11 @@ MEMB(neighborroutememb, struct uip_ds6_route_neighbor_route, UIP_DS6_ROUTE_NB);
|
|||
LIST(routelist);
|
||||
MEMB(routememb, uip_ds6_route_t, UIP_DS6_ROUTE_NB);
|
||||
|
||||
static int num_routes = 0;
|
||||
static void rm_routelist_callback(nbr_table_item_t *ptr);
|
||||
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
|
||||
/* Default routes are held on the defaultrouterlist and their
|
||||
structures are allocated from the defaultroutermemb memory block.*/
|
||||
LIST(defaultrouterlist);
|
||||
|
@ -80,13 +86,10 @@ MEMB(defaultroutermemb, uip_ds6_defrt_t, UIP_DS6_DEFRT_NB);
|
|||
LIST(notificationlist);
|
||||
#endif
|
||||
|
||||
static int num_routes = 0;
|
||||
|
||||
#undef DEBUG
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/ip/uip-debug.h"
|
||||
|
||||
static void rm_routelist_callback(nbr_table_item_t *ptr);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if DEBUG != DEBUG_NONE
|
||||
static void
|
||||
|
@ -156,10 +159,12 @@ uip_ds6_notification_rm(struct uip_ds6_notification *n)
|
|||
void
|
||||
uip_ds6_route_init(void)
|
||||
{
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
memb_init(&routememb);
|
||||
list_init(routelist);
|
||||
nbr_table_register(nbr_routes,
|
||||
(nbr_table_callback *)rm_routelist_callback);
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
|
||||
memb_init(&defaultroutermemb);
|
||||
list_init(defaultrouterlist);
|
||||
|
@ -168,6 +173,7 @@ uip_ds6_route_init(void)
|
|||
list_init(notificationlist);
|
||||
#endif
|
||||
}
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static uip_lladdr_t *
|
||||
uip_ds6_route_nexthop_lladdr(uip_ds6_route_t *route)
|
||||
|
@ -179,36 +185,48 @@ uip_ds6_route_nexthop_lladdr(uip_ds6_route_t *route)
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uip_ipaddr_t *
|
||||
uip_ds6_route_nexthop(uip_ds6_route_t *route)
|
||||
{
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
if(route != NULL) {
|
||||
return uip_ds6_nbr_ipaddr_from_lladdr(uip_ds6_route_nexthop_lladdr(route));
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
#else /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
return NULL;
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uip_ds6_route_t *
|
||||
uip_ds6_route_head(void)
|
||||
{
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
return list_head(routelist);
|
||||
#else /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
return NULL;
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uip_ds6_route_t *
|
||||
uip_ds6_route_next(uip_ds6_route_t *r)
|
||||
{
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
if(r != NULL) {
|
||||
uip_ds6_route_t *n = list_item_next(r);
|
||||
return n;
|
||||
}
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
return NULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
uip_ds6_route_is_nexthop(const uip_ipaddr_t *ipaddr)
|
||||
{
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
const uip_lladdr_t *lladdr;
|
||||
lladdr = uip_ds6_nbr_lladdr_from_ipaddr(ipaddr);
|
||||
|
||||
|
@ -217,17 +235,25 @@ uip_ds6_route_is_nexthop(const uip_ipaddr_t *ipaddr)
|
|||
}
|
||||
|
||||
return nbr_table_get_from_lladdr(nbr_routes, (linkaddr_t *)lladdr) != NULL;
|
||||
#else /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
return 0;
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
uip_ds6_route_num_routes(void)
|
||||
{
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
return num_routes;
|
||||
#else /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
return 0;
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uip_ds6_route_t *
|
||||
uip_ds6_route_lookup(uip_ipaddr_t *addr)
|
||||
{
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
uip_ds6_route_t *r;
|
||||
uip_ds6_route_t *found_route;
|
||||
uint8_t longestmatch;
|
||||
|
@ -274,12 +300,16 @@ uip_ds6_route_lookup(uip_ipaddr_t *addr)
|
|||
}
|
||||
|
||||
return found_route;
|
||||
#else /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
return NULL;
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uip_ds6_route_t *
|
||||
uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
||||
uip_ipaddr_t *nexthop)
|
||||
{
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
uip_ds6_route_t *r;
|
||||
struct uip_ds6_route_neighbor_route *nbrr;
|
||||
|
||||
|
@ -426,12 +456,17 @@ uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
|
|||
assert_nbr_routes_list_sane();
|
||||
#endif /* DEBUG != DEBUG_NONE */
|
||||
return r;
|
||||
|
||||
#else /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
return NULL;
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_ds6_route_rm(uip_ds6_route_t *route)
|
||||
{
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
struct uip_ds6_route_neighbor_route *neighbor_route;
|
||||
#if DEBUG != DEBUG_NONE
|
||||
assert_nbr_routes_list_sane();
|
||||
|
@ -488,8 +523,11 @@ uip_ds6_route_rm(uip_ds6_route_t *route)
|
|||
#if DEBUG != DEBUG_NONE
|
||||
assert_nbr_routes_list_sane();
|
||||
#endif /* DEBUG != DEBUG_NONE */
|
||||
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
return;
|
||||
}
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
rm_routelist(struct uip_ds6_route_neighbor_routes *routes)
|
||||
|
@ -517,10 +555,12 @@ rm_routelist_callback(nbr_table_item_t *ptr)
|
|||
{
|
||||
rm_routelist((struct uip_ds6_route_neighbor_routes *)ptr);
|
||||
}
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop)
|
||||
{
|
||||
#if (UIP_CONF_MAX_ROUTES != 0)
|
||||
/* Get routing entry list of this neighbor */
|
||||
const uip_lladdr_t *nexthop_lladdr;
|
||||
struct uip_ds6_route_neighbor_routes *routes;
|
||||
|
@ -529,6 +569,7 @@ uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop)
|
|||
routes = nbr_table_get_from_lladdr(nbr_routes,
|
||||
(linkaddr_t *)nexthop_lladdr);
|
||||
rm_routelist(routes);
|
||||
#endif /* (UIP_CONF_MAX_ROUTES != 0) */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
uip_ds6_defrt_t *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue