Skip to content

Commit

Permalink
rpl: update routing table information for all dodags
Browse files Browse the repository at this point in the history
  • Loading branch information
cgundogan committed Mar 31, 2015
1 parent 140a76f commit 95a28f9
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions sys/net/routing/rpl/rpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,34 +278,35 @@ void *rpl_process(void *arg)

void _rpl_update_routing_table(void)
{
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
rpl_routing_entry_t *rt;
rpl_dodag_t *my_dodag;
rpl_dodag_t *end;
rpl_routing_entry_t *rt = rpl_get_routing_table();

if (my_dodag != NULL) {
rt = rpl_get_routing_table();
for (uint8_t i = 0; i < rpl_max_routing_entries; i++) {
if (rt[i].used) {
if (rt[i].lifetime <= 1) {
memset(&rt[i], 0, sizeof(rt[i]));
}
else {
rt[i].lifetime = rt[i].lifetime - RPL_LIFETIME_STEP;
}
}
}

for (uint8_t i = 0; i < rpl_max_routing_entries; i++) {
if (rt[i].used) {
if (rt[i].lifetime <= 1) {
memset(&rt[i], 0, sizeof(rt[i]));
for (my_dodag = rpl_dodags, end = my_dodag + RPL_MAX_DODAGS; my_dodag < end; my_dodag++) {
if (my_dodag->used) {
/* Parent is NULL for root too */
if (my_dodag->my_preferred_parent != NULL) {
if (my_dodag->my_preferred_parent->lifetime <= 1) {
DEBUGF("parent lifetime timeout\n");
rpl_parent_update(NULL);
}
else {
rt[i].lifetime = rt[i].lifetime - RPL_LIFETIME_STEP;
my_dodag->my_preferred_parent->lifetime =
my_dodag->my_preferred_parent->lifetime - RPL_LIFETIME_STEP;
}
}
}

/* Parent is NULL for root too */
if (my_dodag->my_preferred_parent != NULL) {
if (my_dodag->my_preferred_parent->lifetime <= 1) {
DEBUGF("parent lifetime timeout\n");
rpl_parent_update(NULL);
}
else {
my_dodag->my_preferred_parent->lifetime =
my_dodag->my_preferred_parent->lifetime - RPL_LIFETIME_STEP;
}
}
}

vtimer_remove(&rt_timer);
Expand Down

0 comments on commit 95a28f9

Please sign in to comment.