Skip to content

Commit

Permalink
Merge pull request #2610 from cgundogan/rpl_remove_get_my_dodag_for_d…
Browse files Browse the repository at this point in the history
…io_dao

rpl: remove some usages of rpl_get_my_dodag
  • Loading branch information
cgundogan committed Mar 20, 2015
2 parents f2b9b51 + 27f0c2f commit 743f529
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 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 @@ -33,7 +33,7 @@ rpl_instance_t *rpl_new_instance(uint8_t instanceid);
rpl_instance_t *rpl_get_instance(uint8_t instanceid);
rpl_instance_t *rpl_get_my_instance(void);
rpl_dodag_t *rpl_new_dodag(rpl_instance_t *inst, ipv6_addr_t *id);
rpl_dodag_t *rpl_get_dodag(ipv6_addr_t *id);
rpl_dodag_t *rpl_get_joined_dodag(uint8_t instanceid);
rpl_dodag_t *rpl_get_my_dodag(void);
void rpl_join_dodag(rpl_dodag_t *dodag, ipv6_addr_t *parent, uint16_t parent_rank);
void rpl_del_dodag(rpl_dodag_t *dodag);
Expand Down
22 changes: 11 additions & 11 deletions sys/net/routing/rpl/rpl_control_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ void rpl_recv_DIO(void)
}

/* handle packet content... */
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
rpl_dodag_t *my_dodag = rpl_get_joined_dodag(dio_inst->id);

if (my_dodag == NULL) {
if (!has_dodag_conf_opt) {
Expand Down Expand Up @@ -769,13 +769,6 @@ void rpl_recv_DIO(void)

void rpl_recv_DAO(void)
{
rpl_dodag_t *my_dodag = rpl_get_my_dodag();

if (my_dodag == NULL) {
DEBUG("[Error] got DAO although not a DODAG\n");
return;
}

#if RPL_DEFAULT_MOP == RPL_MOP_NON_STORING_MODE

if (!i_am_root) {
Expand All @@ -789,6 +782,13 @@ void rpl_recv_DAO(void)
DEBUG("instance %04X ", rpl_dao_buf->rpl_instanceid);
DEBUG("sequence %04X\n", rpl_dao_buf->dao_sequence);

rpl_dodag_t *my_dodag = rpl_get_joined_dodag(rpl_dao_buf->rpl_instanceid);

if (my_dodag == NULL) {
DEBUG("[Error] got DAO although not a DODAG\n");
return;
}

int len = DAO_BASE_LEN;
uint8_t increment_seq = 0;

Expand Down Expand Up @@ -941,14 +941,14 @@ void rpl_recv_DIS(void)

void rpl_recv_DAO_ACK(void)
{
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
rpl_dao_ack_buf = get_rpl_dao_ack_buf();

rpl_dodag_t *my_dodag = rpl_get_joined_dodag(rpl_dao_ack_buf->rpl_instanceid);

if (my_dodag == NULL) {
return;
}

rpl_dao_ack_buf = get_rpl_dao_ack_buf();

if (rpl_dao_ack_buf->rpl_instanceid != my_dodag->instance->id) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions sys/net/routing/rpl/rpl_dodag.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ rpl_dodag_t *rpl_new_dodag(rpl_instance_t *inst, ipv6_addr_t *dodagid)

}

rpl_dodag_t *rpl_get_dodag(ipv6_addr_t *id)
rpl_dodag_t *rpl_get_joined_dodag(uint8_t instanceid)
{
for (int i = 0; i < RPL_MAX_DODAGS; i++) {
if (rpl_dodags[i].used && (rpl_equal_id(&rpl_dodags[i].dodag_id, id))) {
if (rpl_dodags[i].joined && rpl_dodags[i].instance->id == instanceid) {
return &rpl_dodags[i];
}
}
Expand Down

0 comments on commit 743f529

Please sign in to comment.