Skip to content

Commit

Permalink
rpl: remove rpl_get_my_dodag() dependency in rpl_delete_all_parents()
Browse files Browse the repository at this point in the history
  • Loading branch information
cgundogan committed Mar 17, 2015
1 parent cce3edb commit 33a77e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion sys/net/include/rpl/rpl_dodag.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bool rpl_equal_id(ipv6_addr_t *id1, ipv6_addr_t *id2);
ipv6_addr_t *rpl_get_my_preferred_parent(void);
void rpl_delete_parent(rpl_parent_t *parent);
void rpl_delete_worst_parent(void);
void rpl_delete_all_parents(void);
void rpl_delete_all_parents(rpl_dodag_t *dodag);
rpl_parent_t *rpl_find_preferred_parent(void);
void rpl_parent_update(rpl_parent_t *parent);
void rpl_global_repair(rpl_dodag_t *dodag, ipv6_addr_t *p_addr, uint16_t rank);
Expand Down
28 changes: 12 additions & 16 deletions sys/net/routing/rpl/rpl_dodag.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void rpl_leave_dodag(rpl_dodag_t *dodag)
{
dodag->joined = 0;
dodag->my_preferred_parent = NULL;
rpl_delete_all_parents();
rpl_delete_all_parents(dodag);
trickle_stop(&dodag->trickle);
vtimer_remove(&dodag->dao_timer);
}
Expand Down Expand Up @@ -207,13 +207,9 @@ rpl_parent_t *rpl_find_parent(ipv6_addr_t *address)

void rpl_delete_parent(rpl_parent_t *parent)
{
rpl_dodag_t *my_dodag = rpl_get_my_dodag();

if ((my_dodag != NULL) && rpl_equal_id(&my_dodag->my_preferred_parent->addr,
&parent->addr)) {
my_dodag->my_preferred_parent = NULL;
if (parent == parent->dodag->my_preferred_parent) {
parent->dodag->my_preferred_parent = NULL;
}

memset(parent, 0, sizeof(*parent));
}

Expand All @@ -238,16 +234,16 @@ void rpl_delete_worst_parent(void)

}

void rpl_delete_all_parents(void)
void rpl_delete_all_parents(rpl_dodag_t *dodag)
{
rpl_dodag_t *my_dodag = rpl_get_my_dodag();

if (my_dodag != NULL) {
my_dodag->my_preferred_parent = NULL;
}

dodag->my_preferred_parent = NULL;
for (int i = 0; i < RPL_MAX_PARENTS; i++) {
memset(&parents[i], 0, sizeof(parents[i]));
if (dodag->instance->id == parents[i].dodag->instance->id &&
!memcmp(&dodag->dodag_id,
&parents[i].dodag->dodag_id, sizeof(ipv6_addr_t))) {
memset(&parents[i], 0, sizeof(parents[i]));
}
}
}

Expand Down Expand Up @@ -404,7 +400,7 @@ void rpl_global_repair(rpl_dodag_t *dodag, ipv6_addr_t *p_addr, uint16_t rank)
return;
}

rpl_delete_all_parents();
rpl_delete_all_parents(dodag);
my_dodag->version = dodag->version;
my_dodag->dtsn++;
my_dodag->my_preferred_parent = rpl_new_parent(my_dodag, p_addr, rank);
Expand Down Expand Up @@ -438,7 +434,7 @@ void rpl_local_repair(void)

my_dodag->my_rank = INFINITE_RANK;
my_dodag->dtsn++;
rpl_delete_all_parents();
rpl_delete_all_parents(my_dodag);
trickle_reset_timer(&my_dodag->trickle);

}
Expand Down

0 comments on commit 33a77e6

Please sign in to comment.