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 *
|
static rpl_dag_t *
|
||||||
best_dag(rpl_dag_t *d1, rpl_dag_t *d2)
|
best_dag(rpl_dag_t *d1, rpl_dag_t *d2)
|
||||||
{
|
{
|
||||||
if(d1->grounded) {
|
if(d1->grounded != d2->grounded) {
|
||||||
if (!d2->grounded) {
|
return d1->grounded ? d1 : d2;
|
||||||
return d1;
|
|
||||||
}
|
|
||||||
} else if(d2->grounded) {
|
|
||||||
return d2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(d1->preference < d2->preference) {
|
if(d1->preference != d2->preference) {
|
||||||
return d2;
|
return d1->preference > d2->preference ? d1 : d2;
|
||||||
} else {
|
|
||||||
if(d1->preference > d2->preference) {
|
|
||||||
return d1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(d2->rank < d1->rank) {
|
return d1->rank < d2->rank ? d1 : d2;
|
||||||
return d2;
|
|
||||||
} else {
|
|
||||||
return d1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static rpl_parent_t *
|
static rpl_parent_t *
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** \brief Is IPv6 address addr the link-local, all-RPL-nodes
|
/** \brief Is IPv6 address addr the link-local, all-RPL-nodes
|
||||||
multicast address? */
|
multicast address? */
|
||||||
#define uip_is_addr_linklocal_rplnodes_mcast(a) \
|
#define uip_is_addr_linklocal_rplnodes_mcast(addr) \
|
||||||
((addr)->u8[0] == 0xff) && \
|
((addr)->u8[0] == 0xff) && \
|
||||||
((addr)->u8[1] == 0x02) && \
|
((addr)->u8[1] == 0x02) && \
|
||||||
((addr)->u16[1] == 0) && \
|
((addr)->u16[1] == 0) && \
|
||||||
|
|
Loading…
Reference in a new issue