fixed of0 to respect min hop rank increase

This commit is contained in:
Joakim Eriksson 2011-02-13 11:25:53 +01:00
parent 20171985c6
commit 48fb9dda9e

View file

@ -69,6 +69,7 @@ reset(rpl_dag_t *dag)
static rpl_rank_t
calculate_rank(rpl_parent_t *p, rpl_rank_t base_rank)
{
rpl_rank_t increment;
if(base_rank == 0) {
if(p == NULL) {
return INFINITE_RANK;
@ -76,12 +77,14 @@ calculate_rank(rpl_parent_t *p, rpl_rank_t base_rank)
base_rank = p->rank;
}
if((rpl_rank_t)(base_rank + DEFAULT_RANK_INCREMENT) < base_rank) {
increment = p != NULL ? p->dag->min_hoprankinc : DEFAULT_RANK_INCREMENT;
if((rpl_rank_t)(base_rank + increment) < base_rank) {
PRINTF("RPL: OF0 rank %d incremented to infinite rank due to wrapping\n",
base_rank);
return INFINITE_RANK;
}
return base_rank + DEFAULT_RANK_INCREMENT;
return base_rank + increment;
}