@@ -97,7 +97,6 @@ static void ws_bootstrap_pan_version_increment(protocol_interface_info_entry_t *
97
97
static ws_nud_table_entry_t * ws_nud_entry_discover (protocol_interface_info_entry_t * cur , void * neighbor );
98
98
static void ws_nud_entry_remove (protocol_interface_info_entry_t * cur , mac_neighbor_table_entry_t * entry_ptr );
99
99
static bool ws_neighbor_entry_nud_notify (mac_neighbor_table_entry_t * entry_ptr , void * user_data );
100
- static bool ws_rpl_dio_new_parent_accept (struct protocol_interface_info_entry * interface );
101
100
102
101
103
102
static void ws_bootstrap_candidate_table_reset (protocol_interface_info_entry_t * cur );
@@ -321,12 +320,16 @@ static void ws_nud_entry_remove(protocol_interface_info_entry_t *cur, mac_neighb
321
320
}
322
321
}
323
322
324
- static bool ws_nud_message_build (protocol_interface_info_entry_t * cur , mac_neighbor_table_entry_t * neighbor )
323
+ static bool ws_nud_message_build (protocol_interface_info_entry_t * cur , mac_neighbor_table_entry_t * neighbor , bool nud_process )
325
324
{
326
325
//Send NS
327
326
uint8_t ll_target [16 ];
328
327
ws_bootsrap_create_ll_address (ll_target , neighbor -> mac64 );
329
- tr_info ("NUD generate NS %u" , neighbor -> index );
328
+ if (nud_process ) {
329
+ tr_info ("NUD generate NS %u" , neighbor -> index );
330
+ } else {
331
+ tr_info ("Probe generate NS %u" , neighbor -> index );
332
+ }
330
333
buffer_t * buffer = icmpv6_build_ns (cur , ll_target , NULL , true, false, NULL );
331
334
if (buffer ) {
332
335
protocol_push (buffer );
@@ -368,7 +371,7 @@ void ws_nud_active_timer(protocol_interface_info_entry_t *cur, uint16_t ticks)
368
371
369
372
} else {
370
373
//Random TX wait period is over
371
- entry -> wait_response = ws_nud_message_build (cur , entry -> neighbor_info );
374
+ entry -> wait_response = ws_nud_message_build (cur , entry -> neighbor_info , entry -> nud_process );
372
375
if (!entry -> wait_response ) {
373
376
if (entry -> nud_process && entry -> retry_count < 2 ) {
374
377
entry -> timer = randLIB_get_random_in_range (1 , 900 );
@@ -1591,25 +1594,6 @@ static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_en
1591
1594
return true;
1592
1595
}
1593
1596
1594
- static bool ws_rpl_dio_new_parent_accept (struct protocol_interface_info_entry * interface )
1595
- {
1596
- uint16_t parent_candidate_size = rpl_control_parent_candidate_list_size (interface , false);
1597
- //TODO check bootstarap state for review
1598
- //if we have enough candidates at list do not accept new multicast neighbours
1599
- if (parent_candidate_size > interface -> ws_info -> rpl_parent_candidate_max ) {
1600
- return false;
1601
- }
1602
-
1603
- parent_candidate_size = rpl_control_parent_candidate_list_size (interface , true);
1604
- //If we have already enough parent selected Candidates count is bigger than configured
1605
- if (parent_candidate_size >= interface -> ws_info -> rpl_selected_parent_max ) {
1606
- return false;
1607
- }
1608
-
1609
- return true;
1610
- }
1611
-
1612
-
1613
1597
static void ws_neighbor_entry_remove_notify (mac_neighbor_table_entry_t * entry_ptr , void * user_data )
1614
1598
{
1615
1599
@@ -1647,7 +1631,7 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
1647
1631
}
1648
1632
1649
1633
uint8_t ll_address [16 ];
1650
-
1634
+ bool nud_proces = false;
1651
1635
if (time_from_start > WS_NEIGHBOR_NUD_TIMEOUT ) {
1652
1636
1653
1637
ws_bootsrap_create_ll_address (ll_address , entry_ptr -> mac64 );
@@ -1668,6 +1652,7 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
1668
1652
activate_nud = true;
1669
1653
}
1670
1654
}
1655
+ nud_proces = activate_nud ;
1671
1656
} else if (etx_entry -> etx_samples < WS_NEIGBOR_ETX_SAMPLE_MAX ) {
1672
1657
//Take Random number for trig a prope.
1673
1658
//ETX Sample 0: random 1-8
@@ -1679,7 +1664,7 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
1679
1664
} else {
1680
1665
1681
1666
ws_bootsrap_create_ll_address (ll_address , entry_ptr -> mac64 );
1682
- if (!rpl_control_is_dodag_parent_candidate (cur , ll_address , WS_NEIGHBOUR_MAX_CANDIDATE_PROBE )) {
1667
+ if (!rpl_control_probe_parent_candidate (cur , ll_address )) {
1683
1668
return false;
1684
1669
}
1685
1670
@@ -1712,10 +1697,8 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
1712
1697
ws_neighbor -> accelerated_etx_probe = false;
1713
1698
entry -> timer = 1 ;
1714
1699
}
1700
+ entry -> nud_process = nud_proces ;
1715
1701
1716
- if (etx_entry -> etx_samples >= WS_NEIGBOR_ETX_SAMPLE_MAX ) {
1717
- entry -> nud_process = true;
1718
- }
1719
1702
return true;
1720
1703
}
1721
1704
@@ -2150,34 +2133,70 @@ static void ws_rpl_prefix_callback(prefix_entry_t *prefix, void *handle, uint8_t
2150
2133
}
2151
2134
}
2152
2135
2153
- static bool ws_rpl_new_parent_callback_t (uint8_t * ll_parent_address , void * handle )
2136
+ static bool ws_rpl_new_parent_callback (uint8_t * ll_parent_address , void * handle , struct rpl_instance * instance , uint16_t candidate_rank )
2154
2137
{
2155
2138
2156
2139
protocol_interface_info_entry_t * cur = handle ;
2157
2140
if (!cur -> rpl_domain || cur -> interface_mode != INTERFACE_UP ) {
2158
2141
return false;
2159
2142
}
2160
2143
2144
+ if (blacklist_reject (ll_parent_address )) {
2145
+ // Rejected by blacklist
2146
+ return false;
2147
+ }
2148
+
2149
+ uint8_t replacing [16 ];
2161
2150
uint8_t mac64 [8 ];
2162
- memcpy ( mac64 , ll_parent_address + 8 , 8 ) ;
2163
- mac64 [ 0 ] ^= 2 ;
2151
+ bool replace_ok = false ;
2152
+ bool create_ok = false ;
2164
2153
llc_neighbour_req_t neigh_buffer ;
2154
+ if (rpl_control_candidate_list_size (cur , instance ) < cur -> ws_info -> rpl_parent_candidate_max ) {
2155
+ //Not reach max value yet accept then all go to create neigh table
2156
+ goto neigh_create ;
2157
+ }
2158
+
2159
+
2160
+ if (!rpl_control_find_worst_neighbor (cur , instance , replacing )) {
2161
+ return false;
2162
+ }
2163
+
2164
+ // if not yet probed, return false
2165
+ memcpy (mac64 , replacing + 8 , 8 );
2166
+ mac64 [0 ] ^= 2 ;
2167
+
2165
2168
if (ws_bootstrap_neighbor_info_request (cur , mac64 , & neigh_buffer , false)) {
2166
- return true;
2169
+ //Verify that we have proped min 1 time
2170
+ etx_storage_t * etx_entry = etx_storage_entry_get (cur -> id , neigh_buffer .neighbor -> index );
2171
+ if (etx_entry && etx_entry -> etx_samples == 0 ) {
2172
+ return false;
2173
+ }
2167
2174
}
2168
2175
2169
- if (!ws_rpl_dio_new_parent_accept (cur )) {
2176
+ // Accept now only better one's when max candidates slected and max candidate list size is reached
2177
+ if (!rpl_possible_better_candidate (cur , instance , replacing , candidate_rank )) {
2170
2178
return false;
2171
2179
}
2180
+ //TODO if replacing has poor ETX, put it in blacklist as "poor ETX" to prevent reselection
2181
+ //Mark That We can try remove replaced link
2182
+ replace_ok = true;
2172
2183
2173
- //Discover Multicast temporary entry
2184
+ neigh_create :
2185
+
2186
+ memcpy (mac64 , ll_parent_address + 8 , 8 );
2187
+ mac64 [0 ] ^= 2 ;
2188
+ if (ws_bootstrap_neighbor_info_request (cur , mac64 , & neigh_buffer , false)) {
2189
+ create_ok = true;
2190
+ goto neigh_create_ok ;
2191
+ }
2174
2192
2193
+ //Discover Multicast temporary entry
2175
2194
ws_neighbor_temp_class_t * entry = ws_llc_get_multicast_temp_entry (cur , mac64 );
2176
2195
if (!entry ) {
2177
2196
return false;
2178
2197
}
2179
2198
//Create entry
2180
- bool create_ok = ws_bootstrap_neighbor_info_request (cur , mac64 , & neigh_buffer , true);
2199
+ create_ok = ws_bootstrap_neighbor_info_request (cur , mac64 , & neigh_buffer , true);
2181
2200
if (create_ok ) {
2182
2201
ws_neighbor_class_entry_t * ws_neigh = neigh_buffer .ws_neighbor ;
2183
2202
//Copy fhss temporary data
@@ -2188,7 +2207,13 @@ static bool ws_rpl_new_parent_callback_t(uint8_t *ll_parent_address, void *handl
2188
2207
}
2189
2208
ws_llc_free_multicast_temp_entry (cur , entry );
2190
2209
2210
+ neigh_create_ok :
2191
2211
2212
+ if (create_ok && replace_ok ) {
2213
+ //Try remove here when accepted new better one possible
2214
+ tr_debug ("Remove %s by %s" , trace_ipv6 (replacing ), trace_ipv6 (ll_parent_address ));
2215
+ rpl_control_neighbor_delete_from_instance (cur , instance , replacing );
2216
+ }
2192
2217
return create_ok ;
2193
2218
}
2194
2219
@@ -2200,7 +2225,7 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
2200
2225
2201
2226
addr_add_router_groups (cur );
2202
2227
rpl_control_set_domain_on_interface (cur , protocol_6lowpan_rpl_domain , downstream );
2203
- rpl_control_set_callback (protocol_6lowpan_rpl_domain , ws_bootstrap_rpl_callback , ws_rpl_prefix_callback , ws_rpl_new_parent_callback_t , cur );
2228
+ rpl_control_set_callback (protocol_6lowpan_rpl_domain , ws_bootstrap_rpl_callback , ws_rpl_prefix_callback , ws_rpl_new_parent_callback , cur );
2204
2229
// If i am router I Do this
2205
2230
rpl_control_force_leaf (protocol_6lowpan_rpl_domain , leaf );
2206
2231
rpl_control_request_parent_link_confirmation (true);
0 commit comments