Simplified best_dag function and fixed the previous incomplete commit.
This commit is contained in:
parent
f112fa99d5
commit
d89a4ef4fd
2 changed files with 6 additions and 18 deletions
|
@ -137,27 +137,15 @@ calculate_rank(rpl_parent_t *p, rpl_rank_t base_rank)
|
|||
static rpl_dag_t *
|
||||
best_dag(rpl_dag_t *d1, rpl_dag_t *d2)
|
||||
{
|
||||
if(d1->grounded) {
|
||||
if (!d2->grounded) {
|
||||
return d1;
|
||||
}
|
||||
} else if(d2->grounded) {
|
||||
return d2;
|
||||
if(d1->grounded != d2->grounded) {
|
||||
return d1->grounded ? d1 : d2;
|
||||
}
|
||||
|
||||
if(d1->preference < d2->preference) {
|
||||
return d2;
|
||||
} else {
|
||||
if(d1->preference > d2->preference) {
|
||||
return d1;
|
||||
}
|
||||
if(d1->preference != d2->preference) {
|
||||
return d1->preference > d2->preference ? d1 : d2;
|
||||
}
|
||||
|
||||
if(d2->rank < d1->rank) {
|
||||
return d2;
|
||||
} else {
|
||||
return d1;
|
||||
}
|
||||
return d1->rank < d2->rank ? d1 : d2;
|
||||
}
|
||||
|
||||
static rpl_parent_t *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue