2012-01-19 17:35:50 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include "of0.h"
|
|
|
|
|
|
|
|
rpl_of_t rpl_of0 = {
|
2012-02-14 22:22:01 +01:00
|
|
|
0x0,
|
2012-01-19 17:35:50 +01:00
|
|
|
calc_rank,
|
|
|
|
which_parent,
|
|
|
|
which_dodag,
|
|
|
|
reset,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2012-01-26 20:26:55 +01:00
|
|
|
rpl_of_t *rpl_get_of0(){
|
|
|
|
return &rpl_of0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void reset(rpl_dodag_t *dodag){
|
2012-01-19 17:35:50 +01:00
|
|
|
//Nothing to do in OF0
|
|
|
|
}
|
|
|
|
|
2012-01-26 20:26:55 +01:00
|
|
|
uint16_t calc_rank(rpl_parent_t * parent, uint16_t base_rank){
|
2012-01-19 17:35:50 +01:00
|
|
|
if(base_rank == 0) {
|
|
|
|
if(parent == NULL) {
|
|
|
|
return INFINITE_RANK;
|
|
|
|
}
|
|
|
|
base_rank = parent->rank;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t add;
|
|
|
|
if(parent != NULL){
|
|
|
|
add = parent->dodag->minhoprankincrease;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
add = DEFAULT_MIN_HOP_RANK_INCREASE;
|
|
|
|
}
|
|
|
|
if( base_rank + add < base_rank ){
|
|
|
|
return INFINITE_RANK;
|
|
|
|
}
|
|
|
|
return base_rank + add;
|
|
|
|
}
|
|
|
|
|
2012-02-26 19:30:48 +01:00
|
|
|
//We simply return the Parent with lower rank
|
2012-01-26 20:26:55 +01:00
|
|
|
rpl_parent_t * which_parent(rpl_parent_t *p1, rpl_parent_t *p2){
|
2012-02-26 19:30:48 +01:00
|
|
|
if(p1->rank < p2->rank){
|
|
|
|
return p1;
|
|
|
|
}
|
|
|
|
return p2;
|
2012-01-19 17:35:50 +01:00
|
|
|
}
|
|
|
|
|
2012-11-26 17:03:08 +01:00
|
|
|
//Not used yet, as the implementation only makes use of one dodag for now.
|
2012-01-26 20:26:55 +01:00
|
|
|
rpl_dodag_t * which_dodag(rpl_dodag_t *d1, rpl_dodag_t *d2){
|
2012-01-19 17:35:50 +01:00
|
|
|
return d1;
|
|
|
|
}
|