40 #include "net/rpl/rpl-conf.h"
46 #include "net/rpl/rpl-private.h"
51 #if RPL_WITH_NON_STORING
53 #define DEBUG DEBUG_NONE
64 MEMB(nodememb, rpl_ns_node_t, RPL_NS_LINK_NUM);
68 rpl_ns_num_nodes(
void)
74 node_matches_address(
const rpl_dag_t *dag,
const rpl_ns_node_t *node,
const uip_ipaddr_t *
addr)
80 && !memcmp(addr, &node->dag->dag_id, 8)
81 && !memcmp(((
const unsigned char *)addr) + 8, node->link_identifier, 8);
85 rpl_ns_get_node(
const rpl_dag_t *dag,
const uip_ipaddr_t *addr)
90 if(node_matches_address(dag, l, addr)) {
98 rpl_ns_is_node_reachable(
const rpl_dag_t *dag,
const uip_ipaddr_t *addr)
100 int max_depth = RPL_NS_LINK_NUM;
101 rpl_ns_node_t *node = rpl_ns_get_node(dag, addr);
102 rpl_ns_node_t *root_node = rpl_ns_get_node(dag, dag !=
NULL ? &dag->dag_id :
NULL);
103 while(node !=
NULL && node != root_node && max_depth > 0) {
107 return node !=
NULL && node == root_node;
111 rpl_ns_expire_parent(rpl_dag_t *dag,
const uip_ipaddr_t *child,
const uip_ipaddr_t *parent)
113 rpl_ns_node_t *l = rpl_ns_get_node(dag, child);
115 if(l !=
NULL && node_matches_address(dag, l->parent, parent)) {
116 l->lifetime = RPL_NOPATH_REMOVAL_DELAY;
121 rpl_ns_update_node(rpl_dag_t *dag,
const uip_ipaddr_t *child,
const uip_ipaddr_t *parent, uint32_t lifetime)
123 rpl_ns_node_t *child_node = rpl_ns_get_node(dag, child);
124 rpl_ns_node_t *parent_node = rpl_ns_get_node(dag, parent);
125 rpl_ns_node_t *old_parent_node;
129 if(parent_node ==
NULL) {
130 parent_node = rpl_ns_update_node(dag, parent,
NULL, 0xffffffff);
131 if(parent_node ==
NULL) {
138 if(child_node ==
NULL) {
141 if(child_node ==
NULL) {
144 child_node->parent =
NULL;
150 child_node->dag = dag;
151 child_node->lifetime = lifetime;
152 memcpy(child_node->link_identifier, ((
const unsigned char *)child) + 8, 8);
155 if(rpl_ns_is_node_reachable(dag, child)) {
156 old_parent_node = child_node->parent;
158 child_node->parent = parent_node;
160 if(!rpl_ns_is_node_reachable(dag, child)) {
164 child_node->parent = old_parent_node;
167 child_node->parent = parent_node;
182 rpl_ns_node_head(
void)
188 rpl_ns_node_next(rpl_ns_node_t *item)
194 rpl_ns_get_node_global_addr(uip_ipaddr_t *addr, rpl_ns_node_t *node)
197 memcpy(addr, &node->dag->dag_id, 8);
198 memcpy(((
unsigned char *)addr) + 8, &node->link_identifier, 8);
203 rpl_ns_periodic(
void)
209 if(l->lifetime != 0xffffffff && l->lifetime > 0) {
215 if(l->lifetime == 0) {
218 if(l2->parent == l) {
void list_remove(list_t list, void *item)
Remove a specific element from a list.
#define LIST(name)
Declare a linked list.
static uip_ds6_addr_t * addr
Pointer to a router list entry.
Header file for IPv6-related data structures.
#define MEMB(name, structure, num)
Declare a memory block.
void * list_item_next(void *item)
Get the next item following this item.
void list_init(list_t list)
Initialize a list.
Header for the Contiki/uIP interface.
void memb_init(struct memb *m)
Initialize a memory block that was declared with MEMB().
void * list_head(list_t list)
Get a pointer to the first element of a list.
#define NULL
The null pointer.
Header file for ICMPv6 message and error handing (RFC 4443)
void list_add(list_t list, void *item)
Add an item at the end of a list.
Linked list manipulation routines.
Header file for the uIP TCP/IP stack.
Memory block allocation routines.
A set of debugging macros for the IP stack
RPL non-storing mode specific functions.
void * memb_alloc(struct memb *m)
Allocate a memory block from a block of memory declared with MEMB().
char memb_free(struct memb *m, void *ptr)
Deallocate a memory block from a memory block previously declared with MEMB().