45 #include "net/rpl/rpl-private.h"
48 #define DEBUG DEBUG_NONE
55 rpl_stats_t rpl_stats;
62 rpl_purge_routes(
void)
66 for(i = 0; i < UIP_DS6_ROUTE_NB; i++) {
67 if(uip_ds6_routing_table[i].isused) {
68 if(uip_ds6_routing_table[i].state.lifetime <= 1) {
69 uip_ds6_route_rm(&uip_ds6_routing_table[i]);
71 uip_ds6_routing_table[i].state.lifetime--;
78 rpl_remove_routes(rpl_dag_t *dag)
82 for(i = 0; i < UIP_DS6_ROUTE_NB; i++) {
83 if(uip_ds6_routing_table[i].state.dag == dag) {
84 uip_ds6_route_rm(&uip_ds6_routing_table[i]);
90 rpl_add_route(rpl_dag_t *dag,
uip_ipaddr_t *prefix,
int prefix_len,
95 rep = uip_ds6_route_lookup(prefix);
97 if((rep = uip_ds6_route_add(prefix, prefix_len, next_hop, 0)) ==
NULL) {
98 PRINTF(
"RPL: No space for more route entries\n");
102 PRINTF(
"RPL: Updated the next hop for prefix ");
105 PRINT6ADDR(next_hop);
109 rep->state.dag = dag;
110 rep->state.lifetime = RPL_LIFETIME(dag, dag->default_lifetime);
111 rep->state.learned_from = RPL_ROUTE_FROM_INTERNAL;
113 PRINTF(
"RPL: Added a route to ");
115 PRINTF(
"/%d via ", prefix_len);
116 PRINT6ADDR(next_hop);
123 rpl_link_neighbor_callback(
const rimeaddr_t *addr,
int known,
int etx)
127 rpl_parent_t *parent;
131 PRINTF(
"RPL: Neighbor ");
133 PRINTF(
" is %sknown. ETX = %u\n", known ?
"" :
"no longer ", NEIGHBOR_INFO_FIX2ETX(etx));
135 dag = rpl_get_dag(RPL_DEFAULT_INSTANCE);
140 parent = rpl_find_parent(dag, &ipaddr);
143 PRINTF(
"RPL: Deleting routes installed by DAOs received from ");
146 uip_ds6_route_rm_by_nexthop(&ipaddr);
154 parent->link_metric = etx;
156 if(dag->of->parent_state_callback !=
NULL) {
157 dag->of->parent_state_callback(parent, known, etx);
161 PRINTF(
"RPL: Removing parent ");
162 PRINT6ADDR(&parent->addr);
163 PRINTF(
" because of bad connectivity (ETX %d)\n", etx);
164 parent->rank = INFINITE_RANK;
175 dag = rpl_get_dag(RPL_ANY_INSTANCE);
181 if(dag->def_route !=
NULL &&
183 dag->def_route =
NULL;
187 PRINTF(
"RPL: Removing neighbor ");
188 PRINT6ADDR(&nbr->ipaddr);
190 p = rpl_find_parent(dag, &nbr->ipaddr);
192 p->rank = INFINITE_RANK;
203 PRINTF(
"RPL started\n");
205 rpl_reset_periodic_timer();
209 uip_create_linklocal_rplnodes_mcast(&rplmaddr);
210 uip_ds6_maddr_add(&rplmaddr);
213 memset(&rpl_stats, 0,
sizeof(rpl_stats));