45 #include "net/routing/rpl-lite/rpl.h" 46 #include "net/nbr-table.h" 50 #define LOG_MODULE "RPL" 51 #define LOG_LEVEL LOG_LEVEL_RPL 63 static int num_parents;
65 static const linkaddr_t *worst_rank_nbr_lladdr;
66 static rpl_rank_t worst_rank;
78 worst_rank_nbr_lladdr = NULL;
82 while(ds6_nbr != NULL) {
93 if(rpl_nbr != curr_instance.dag.preferred_parent
94 && nbr_rank > worst_rank) {
96 worst_rank = nbr_rank;
97 worst_rank_nbr_lladdr = nbr_lladdr;
104 num_free = NBR_TABLE_MAX_NEIGHBORS - num_used;
106 LOG_DBG(
"nbr-policy: free: %d, parents: %d\n", num_free, num_parents);
109 static const linkaddr_t *
110 find_worst_rank_nbr_lladdr(
void)
113 return worst_rank_nbr_lladdr;
116 static const linkaddr_t *
117 find_removable_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
121 if(!curr_instance.used || curr_instance.instance_id != dio->instance_id) {
122 LOG_WARN(
"nbr-policy: did not find instance id: %d\n", dio->instance_id);
127 if(dio->rank + curr_instance.min_hoprankinc < worst_rank - curr_instance.min_hoprankinc / 2) {
129 LOG_DBG(
"nbr-policy: DIO rank %u, worst_rank %u -- add to cache\n",
130 dio->rank, worst_rank);
131 return worst_rank_nbr_lladdr;
134 LOG_DBG(
"nbr-policy: DIO rank %u, worst_rank %u -- do not add to cache\n",
135 dio->rank, worst_rank);
140 rpl_nbr_policy_find_removable(nbr_table_reason_t reason,
void *data)
145 case NBR_TABLE_REASON_RPL_DIO:
146 return find_removable_dio(&
UIP_IP_BUF->srcipaddr, data);
147 case NBR_TABLE_REASON_RPL_DIS:
148 return find_worst_rank_nbr_lladdr();
149 case NBR_TABLE_REASON_IPV6_ND_AUTOFILL:
150 return find_worst_rank_nbr_lladdr();
#define UIP_IP_BUF
Direct access to IPv6 header.
uip_ds6_nbr_t * uip_ds6_nbr_head(void)
Get the first neighbor cache in nbr_table.
int rpl_neighbor_is_parent(rpl_nbr_t *nbr)
Tells whether a neighbor is in the parent set.
All information related to a RPL neighbor.
uip_ds6_nbr_t * uip_ds6_nbr_next(uip_ds6_nbr_t *nbr)
Get the next neighbor cache of a specified one.
const uip_lladdr_t * uip_ds6_nbr_get_ll(const uip_ds6_nbr_t *nbr)
Get the link-layer address associated with a specified nbr cache.
rpl_rank_t rpl_neighbor_rank_via_nbr(rpl_nbr_t *nbr)
Returns our rank if selecting a given parent as preferred parent.
Header file for the logging system
rpl_nbr_t * rpl_neighbor_get_from_lladdr(uip_lladdr_t *addr)
Returns a neighbor from its link-layer address.
The default nbr_table entry (when UIP_DS6_NBR_MULTI_IPV6_ADDRS is disabled), that implements nbr cach...