49 #include "net/routing/rpl-classic/rpl-nbr-policy.h" 50 #include "net/routing/rpl-classic/rpl-private.h" 51 #include "net/nbr-table.h" 52 #include "net/link-stats.h" 56 #define LOG_MODULE "RPL-nbrpol" 57 #define LOG_LEVEL LOG_LEVEL_NONE 61 get_rank(
const linkaddr_t *lladdr)
63 rpl_parent_t *p = rpl_get_parent((uip_lladdr_t *)lladdr);
65 return RPL_INFINITE_RANK;
68 return instance != NULL ? instance->of->rank_via_parent(p) : RPL_INFINITE_RANK;
73 rpl_nbr_gc_get_worst(
const linkaddr_t *lladdr1,
const linkaddr_t *lladdr2)
75 return get_rank(lladdr2) > get_rank(lladdr1) ? lladdr2 : lladdr1;
79 can_accept_new_parent(
const linkaddr_t *candidate_for_removal, rpl_dio_t *dio)
81 rpl_rank_t rank_candidate;
83 if(candidate_for_removal == NULL
84 || (rank_candidate = get_rank(candidate_for_removal)) == RPL_INFINITE_RANK) {
88 rpl_rank_t new_path_rank;
90 if(instance == NULL || dio == NULL) {
94 new_path_rank = dio->rank + instance->min_hoprankinc;
95 return new_path_rank < rank_candidate - instance->min_hoprankinc / 2;
100 rpl_nbr_can_accept_new(
const linkaddr_t *
new,
const linkaddr_t *candidate_for_removal,
101 nbr_table_reason_t reason,
void *data)
105 case NBR_TABLE_REASON_RPL_DIO:
106 accept = can_accept_new_parent(candidate_for_removal, (rpl_dio_t *)data);
108 case NBR_TABLE_REASON_ROUTE:
109 case NBR_TABLE_REASON_RPL_DAO:
112 accept = rpl_nbr_policy_get_free_nexthop_neighbors() > 0;
114 case NBR_TABLE_REASON_RPL_DIS:
115 case NBR_TABLE_REASON_UNDEFINED:
116 case NBR_TABLE_REASON_IPV6_ND:
117 case NBR_TABLE_REASON_MAC:
118 case NBR_TABLE_REASON_LLSEC:
119 case NBR_TABLE_REASON_LINK_STATS:
120 case NBR_TABLE_REASON_IPV6_ND_AUTOFILL:
123 accept = (candidate_for_removal == NULL);
126 LOG_DBG(
"%s new neighbor ", accept ?
"accept" :
"reject");
128 LOG_DBG_(
", reason %u, worst is ", reason);
129 LOG_DBG_LLADDR(candidate_for_removal);
130 LOG_DBG_(
" (total free %u, free nexthop neighbors %u)\n",
131 NBR_TABLE_MAX_NEIGHBORS - nbr_table_count_entries(),
132 rpl_nbr_policy_get_free_nexthop_neighbors());
137 rpl_nbr_policy_get_free_nexthop_neighbors(
void)
139 return RPL_NBR_POLICY_MAX_NEXTHOP_NEIGHBORS - uip_ds6_route_count_nexthop_neighbors();
static uint8_t accept(uint8_t in)
Header file for routing table manipulation.
Header file for the logging system
rpl_instance_t * rpl_get_default_instance(void)
Returns pointer to the default instance (for compatibility with legagy RPL code)