Skip to content

Commit

Permalink
Merge pull request #2625 from cgundogan/rpl_remove_global_root_indica…
Browse files Browse the repository at this point in the history
…tion

rpl: remove global variable indicating the root node
  • Loading branch information
OlegHahm committed Apr 29, 2015
2 parents 0275b2e + b557000 commit 51ff5e0
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions sys/net/routing/rpl/rpl_control_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ static char addr_str[IPV6_MAX_ADDR_STR_LEN];
#endif
#include "debug.h"

/* Identification variables */
static char i_am_root;

/* in send buffer we need space for LL_HDR */
static uint8_t rpl_send_buffer[BUFFER_SIZE];

Expand Down Expand Up @@ -244,17 +241,26 @@ void rpl_init_root(rpl_options_t *rpl_opts)
return;
}

i_am_root = 1;
trickle_start(rpl_process_pid, &dodag->trickle, RPL_MSG_TYPE_TRICKLE_INTERVAL,
RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min), dodag->dio_interval_doubling,
dodag->dio_redundancy);
DEBUGF("ROOT INIT FINISHED\n");

}

/* TODO: this function is used by the ip layer for source routing (non-storing mode)
* to determine if the node is root and change the dodag direction (upwards -> downwards).
* This is a hack and needs to be refactored when the new network stack is ready.
*/
uint8_t rpl_is_root(void)
{
return i_am_root;
rpl_dodag_t *dodag, *end;
for (dodag = rpl_dodags, end = dodag + RPL_MAX_DODAGS; dodag < end; dodag++) {
if (dodag->node_status == ROOT_NODE) {
return 1;
}
}
return 0;
}

void rpl_send_DIO(rpl_dodag_t *mydodag, ipv6_addr_t *destination)
Expand Down Expand Up @@ -345,12 +351,12 @@ void rpl_send_DAO(rpl_dodag_t *my_dodag, ipv6_addr_t *destination, uint8_t lifet

#endif

if (i_am_root) {
if (my_dodag == NULL) {
DEBUGF("send_DAO: I have no my_dodag\n");
return;
}

if (my_dodag == NULL) {
DEBUGF("send_DAO: I have no my_dodag\n");
if (my_dodag->node_status == ROOT_NODE) {
return;
}

Expand Down Expand Up @@ -754,13 +760,9 @@ void rpl_recv_DIO(void)
void rpl_recv_DAO(void)
{
#if RPL_DEFAULT_MOP == RPL_MOP_NON_STORING_MODE

if (!i_am_root) {
DEBUGF("[Error] something went wrong - got a DAO.\n");
return;
}

#endif
DEBUGF("[Error] something went wrong - got a DAO.\n");
return;
#else
ipv6_buf = get_rpl_ipv6_buf();
rpl_dao_buf = get_rpl_dao_buf();
DEBUG("instance %04X ", rpl_dao_buf->rpl_instanceid);
Expand Down Expand Up @@ -854,6 +856,7 @@ void rpl_recv_DAO(void)
RPL_COUNTER_INCREMENT(my_dodag->dao_seq);
rpl_delay_dao(my_dodag);
}
#endif
}

void rpl_recv_DIS(void)
Expand Down

0 comments on commit 51ff5e0

Please sign in to comment.