1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

rpl: remove get_my_dodag dependency by passing the dodag as parameter

This commit is contained in:
Cenk Gündoğan 2015-03-19 18:43:46 +01:00
parent 52017a967a
commit 1ab4f7c975
4 changed files with 17 additions and 18 deletions

View File

@ -45,10 +45,10 @@ 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);
rpl_parent_t *rpl_find_preferred_parent(void);
void rpl_parent_update(rpl_parent_t *parent);
rpl_parent_t *rpl_find_preferred_parent(rpl_dodag_t *dodag);
void rpl_parent_update(rpl_dodag_t *dodag, rpl_parent_t *parent);
void rpl_global_repair(rpl_dodag_t *dodag, ipv6_addr_t *p_addr, uint16_t rank);
void rpl_local_repair(void);
void rpl_local_repair(rpl_dodag_t *dodag);
uint16_t rpl_calc_rank(uint16_t abs_rank, uint16_t minhoprankincrease);
#ifdef __cplusplus

View File

@ -299,7 +299,7 @@ void _rpl_update_routing_table(void)
if (my_dodag->my_preferred_parent != NULL) {
if (my_dodag->my_preferred_parent->lifetime <= 1) {
DEBUGF("parent lifetime timeout\n");
rpl_parent_update(NULL);
rpl_parent_update(my_dodag, NULL);
}
else {
my_dodag->my_preferred_parent->lifetime =

View File

@ -707,7 +707,8 @@ void rpl_recv_DIO(void)
}
else {
DEBUGF("my dodag has no preferred_parent yet - seems to be odd since I have a parent.\n");
rpl_global_repair(&dio_dodag, &ipv6_buf->srcaddr, byteorder_ntohs(rpl_dio_buf->rank));
my_dodag->version = dio_dodag.version;
rpl_global_repair(my_dodag, &ipv6_buf->srcaddr, byteorder_ntohs(rpl_dio_buf->rank));
}
return;
@ -753,7 +754,7 @@ void rpl_recv_DIO(void)
/* update parent rank */
parent->rank = byteorder_ntohs(rpl_dio_buf->rank);
rpl_parent_update(parent);
rpl_parent_update(my_dodag, parent);
if (my_dodag->my_preferred_parent == NULL) {
DEBUGF("My dodag has no preferred_parent yet - seems to be odd since I have a parent...\n");

View File

@ -248,10 +248,9 @@ void rpl_delete_all_parents(void)
}
}
rpl_parent_t *rpl_find_preferred_parent(void)
rpl_parent_t *rpl_find_preferred_parent(rpl_dodag_t *my_dodag)
{
rpl_parent_t *best = NULL;
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
if (my_dodag == NULL) {
DEBUG("Not part of a dodag\n");
@ -259,7 +258,10 @@ rpl_parent_t *rpl_find_preferred_parent(void)
}
for (uint8_t i = 0; i < RPL_MAX_PARENTS; i++) {
if (parents[i].used) {
if (parents[i].used
&& (parents[i].dodag->instance->id == my_dodag->instance->id)
&& (!memcmp(&parents[i].dodag->dodag_id,
&my_dodag->dodag_id, sizeof(ipv6_addr_t)))) {
if ((parents[i].rank == INFINITE_RANK) || (parents[i].lifetime <= 1)) {
DEBUG("Infinite rank, bad parent\n");
continue;
@ -300,9 +302,8 @@ rpl_parent_t *rpl_find_preferred_parent(void)
return best;
}
void rpl_parent_update(rpl_parent_t *parent)
void rpl_parent_update(rpl_dodag_t *my_dodag, rpl_parent_t *parent)
{
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
uint16_t old_rank;
if (my_dodag == NULL) {
@ -317,8 +318,8 @@ void rpl_parent_update(rpl_parent_t *parent)
parent->lifetime = my_dodag->default_lifetime * my_dodag->lifetime_unit;
}
if (rpl_find_preferred_parent() == NULL) {
rpl_local_repair();
if (rpl_find_preferred_parent(my_dodag) == NULL) {
rpl_local_repair(my_dodag);
}
if (rpl_calc_rank(old_rank, my_dodag->minhoprankincrease) !=
@ -391,10 +392,9 @@ void rpl_join_dodag(rpl_dodag_t *dodag, ipv6_addr_t *parent, uint16_t parent_ran
rpl_delay_dao(my_dodag);
}
void rpl_global_repair(rpl_dodag_t *dodag, ipv6_addr_t *p_addr, uint16_t rank)
void rpl_global_repair(rpl_dodag_t *my_dodag, ipv6_addr_t *p_addr, uint16_t rank)
{
DEBUGF("[INFO] Global repair started\n");
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
if (my_dodag == NULL) {
DEBUGF("[Error] - no global repair possible, if not part of a DODAG\n");
@ -402,7 +402,6 @@ void rpl_global_repair(rpl_dodag_t *dodag, ipv6_addr_t *p_addr, uint16_t rank)
}
rpl_delete_all_parents();
my_dodag->version = dodag->version;
my_dodag->dtsn++;
my_dodag->my_preferred_parent = rpl_new_parent(my_dodag, p_addr, rank);
@ -423,10 +422,9 @@ void rpl_global_repair(rpl_dodag_t *dodag, ipv6_addr_t *p_addr, uint16_t rank)
my_dodag->my_rank);
}
void rpl_local_repair(void)
void rpl_local_repair(rpl_dodag_t *my_dodag)
{
DEBUGF("[INFO] Local Repair started\n");
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
if (my_dodag == NULL) {
DEBUGF("[Error] - no local repair possible, if not part of a DODAG\n");