46 #include "net/ipv6/uip-ds6.h"
48 #include "net/rpl/rpl-private.h"
51 #define DEBUG DEBUG_NONE
60 rpl_stats_t rpl_stats;
63 static enum rpl_mode mode = RPL_MODE_MESH;
78 if(m == RPL_MODE_MESH) {
84 PRINTF(
"RPL: switching to mesh mode\n");
87 if(default_instance !=
NULL) {
88 rpl_schedule_dao_immediately(default_instance);
90 }
else if(m == RPL_MODE_FEATHER) {
92 PRINTF(
"RPL: switching to feather mode\n");
94 if(default_instance !=
NULL) {
95 rpl_cancel_dao(default_instance);
106 rpl_purge_routes(
void)
111 #if RPL_CONF_MULTICAST
119 if(r->state.lifetime >= 1) {
134 if(r->state.lifetime < 1) {
140 PRINTF(
"No more routes to ");
142 dag = default_instance->current_dag;
144 if(dag->rank != ROOT_RANK(default_instance)) {
145 PRINTF(
" -> generate No-Path DAO\n");
146 dao_output_target(dag->preferred_parent, &prefix, RPL_ZERO_LIFETIME);
156 #if RPL_CONF_MULTICAST
157 mcast_route = uip_mcast6_route_list_head();
159 while(mcast_route !=
NULL) {
160 if(mcast_route->lifetime <= 1) {
161 uip_mcast6_route_rm(mcast_route);
162 mcast_route = uip_mcast6_route_list_head();
164 mcast_route->lifetime--;
175 #if RPL_CONF_MULTICAST
182 if(r->state.dag == dag) {
190 #if RPL_CONF_MULTICAST
191 mcast_route = uip_mcast6_route_list_head();
193 while(mcast_route !=
NULL) {
194 if(mcast_route->dag == dag) {
195 uip_mcast6_route_rm(mcast_route);
196 mcast_route = uip_mcast6_route_list_head();
205 rpl_remove_routes_by_nexthop(uip_ipaddr_t *nexthop,
rpl_dag_t *dag)
212 if(uip_ipaddr_cmp(uip_ds6_route_nexthop(r), nexthop) &&
213 r->state.dag == dag) {
220 ANNOTATE(
"#L %u 0\n", nexthop->u8[
sizeof(uip_ipaddr_t) - 1]);
224 rpl_add_route(
rpl_dag_t *dag, uip_ipaddr_t *prefix,
int prefix_len,
225 uip_ipaddr_t *next_hop)
230 PRINTF(
"RPL: No space for more route entries\n");
234 rep->state.dag = dag;
235 rep->state.lifetime = RPL_LIFETIME(dag->instance, dag->instance->default_lifetime);
236 rep->state.learned_from = RPL_ROUTE_FROM_INTERNAL;
238 PRINTF(
"RPL: Added a route to ");
240 PRINTF(
"/%d via ", prefix_len);
241 PRINT6ADDR(next_hop);
248 rpl_link_neighbor_callback(
const linkaddr_t *addr,
int status,
int numtx)
251 rpl_parent_t *parent;
258 for(instance = &instance_table[0], end = instance + RPL_MAX_INSTANCES; instance < end; ++instance) {
259 if(instance->used == 1 ) {
260 parent = rpl_find_parent_any_dag(instance, &ipaddr);
263 PRINTF(
"RPL: rpl_link_neighbor_callback triggering update\n");
280 PRINTF(
"RPL: Removing neighbor ");
281 PRINT6ADDR(&nbr->ipaddr);
283 for(instance = &instance_table[0], end = instance + RPL_MAX_INSTANCES; instance < end; ++instance) {
284 if(instance->used == 1 ) {
285 p = rpl_find_parent_any_dag(instance, &nbr->ipaddr);
287 p->rank = INFINITE_RANK;
289 PRINTF(
"RPL: rpl_ipv6_neighbor_callback infinite rank\n");
299 uip_ipaddr_t rplmaddr;
300 PRINTF(
"RPL started\n");
301 default_instance =
NULL;
304 rpl_reset_periodic_timer();
307 uip_create_linklocal_rplnodes_mcast(&rplmaddr);
308 uip_ds6_maddr_add(&rplmaddr);
311 memset(&rpl_stats, 0,
sizeof(rpl_stats));