@@ -81,7 +81,7 @@ static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp
8181static bool ws_bootstrap_state_discovery (struct protocol_interface_info_entry * cur );
8282static int8_t ws_bootsrap_event_trig (ws_bootsrap_event_type_e event_type , int8_t interface_id , arm_library_event_priority_e priority , void * event_data );
8383
84- static bool ws_bootstrap_neighbor_info_request (struct protocol_interface_info_entry * interface , const uint8_t * mac_64 , llc_neighbour_req_t * neighbor_buffer , bool request_new , bool multicast );
84+ static bool ws_bootstrap_neighbor_info_request (struct protocol_interface_info_entry * interface , const uint8_t * mac_64 , llc_neighbour_req_t * neighbor_buffer , bool request_new );
8585static uint16_t ws_bootstrap_routing_cost_calculate (protocol_interface_info_entry_t * cur );
8686static uint16_t ws_bootstrap_rank_get (protocol_interface_info_entry_t * cur );
8787static uint16_t ws_bootstrap_min_rank_inc_get (protocol_interface_info_entry_t * cur );
@@ -97,13 +97,15 @@ static void ws_bootstrap_pan_version_increment(protocol_interface_info_entry_t *
9797static ws_nud_table_entry_t * ws_nud_entry_discover (protocol_interface_info_entry_t * cur , void * neighbor );
9898static void ws_nud_entry_remove (protocol_interface_info_entry_t * cur , mac_neighbor_table_entry_t * entry_ptr );
9999static 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 );
100101
101102typedef enum {
102103 WS_PARENT_SOFT_SYNCH = 0 , /**< let FHSS make decision if synchronization is needed*/
103104 WS_PARENT_HARD_SYNCH , /**< Synch FHSS with latest synch information*/
104105 WS_EAPOL_PARENT_SYNCH , /**< Broadcast synch with EAPOL parent*/
105106} ws_parent_synch_e ;
106107
108+
107109static void ws_bootsrap_create_ll_address (uint8_t * ll_address , const uint8_t * mac64 )
108110{
109111 memcpy (ll_address , ADDR_LINK_LOCAL_PREFIX , 8 );
@@ -925,7 +927,7 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
925927 // Save route cost for all neighbours
926928 llc_neighbour_req_t neighbor_info ;
927929 neighbor_info .neighbor = NULL ;
928- if (ws_bootstrap_neighbor_info_request (cur , data -> SrcAddr , & neighbor_info , false, false )) {
930+ if (ws_bootstrap_neighbor_info_request (cur , data -> SrcAddr , & neighbor_info , false)) {
929931 neighbor_info .ws_neighbor -> routing_cost = pan_information .routing_cost ;
930932 }
931933
@@ -1080,10 +1082,10 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
10801082
10811083 if (cur -> ws_info -> configuration_learned || cur -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER ) {
10821084 //If we are border router or learned configuration we only update already learned neighbours.
1083- neighbour_pointer_valid = ws_bootstrap_neighbor_info_request (cur , data -> SrcAddr , & neighbor_info , false, true );
1085+ neighbour_pointer_valid = ws_bootstrap_neighbor_info_request (cur , data -> SrcAddr , & neighbor_info , false);
10841086
10851087 } else {
1086- neighbour_pointer_valid = ws_bootstrap_neighbor_info_request (cur , data -> SrcAddr , & neighbor_info , true, true );
1088+ neighbour_pointer_valid = ws_bootstrap_neighbor_info_request (cur , data -> SrcAddr , & neighbor_info , true);
10871089 if (!neighbour_pointer_valid ) {
10881090 return ;
10891091 }
@@ -1169,7 +1171,7 @@ static void ws_bootstrap_pan_config_solicit_analyse(struct protocol_interface_in
11691171 */
11701172
11711173 llc_neighbour_req_t neighbor_info ;
1172- if (ws_bootstrap_neighbor_info_request (cur , data -> SrcAddr , & neighbor_info , false, false )) {
1174+ if (ws_bootstrap_neighbor_info_request (cur , data -> SrcAddr , & neighbor_info , false)) {
11731175 etx_lqi_dbm_update (cur -> id , data -> mpduLinkQuality , data -> signal_dbm , neighbor_info .neighbor -> index );
11741176 ws_neighbor_class_neighbor_unicast_time_info_update (neighbor_info .ws_neighbor , ws_utt , data -> timestamp );
11751177 ws_neighbor_class_neighbor_unicast_schedule_set (neighbor_info .ws_neighbor , ws_us );
@@ -1366,19 +1368,10 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13661368 }
13671369 }
13681370
1369- uint32_t link_min_timeout ;
13701371 //Read current timestamp
13711372 uint32_t time_from_last_unicast_shedule = ws_time_from_last_unicast_traffic (current_time_stamp , ws_neighbor );
13721373
1373-
1374- if (cur -> trusted_device ) {
1375- link_min_timeout = WS_NEIGHBOR_TRUSTED_LINK_MIN_TIMEOUT ;
1376- } else {
1377-
1378- link_min_timeout = WS_NEIGHBOR_NOT_TRUSTED_LINK_MIN_TIMEOUT ;
1379- }
1380-
1381- if (time_from_last_unicast_shedule > link_min_timeout || !ws_neighbor -> unicast_data_rx ) {
1374+ if (time_from_last_unicast_shedule > WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT || !ws_neighbor -> unicast_data_rx ) {
13821375 //Accept only Enough Old Device
13831376 if (!neighbor_entry_ptr ) {
13841377 //Accept first compare
@@ -1399,8 +1392,9 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13991392
14001393}
14011394
1402- static bool ws_bootstrap_neighbor_info_request (struct protocol_interface_info_entry * interface , const uint8_t * mac_64 , llc_neighbour_req_t * neighbor_buffer , bool request_new , bool multicast )
1395+ static bool ws_bootstrap_neighbor_info_request (struct protocol_interface_info_entry * interface , const uint8_t * mac_64 , llc_neighbour_req_t * neighbor_buffer , bool request_new )
14031396{
1397+ neighbor_buffer -> ws_neighbor = NULL ;
14041398 neighbor_buffer -> neighbor = mac_neighbor_table_address_discover (mac_neighbor_info (interface ), mac_64 , ADDR_802_15_4_LONG );
14051399 if (neighbor_buffer -> neighbor ) {
14061400 neighbor_buffer -> ws_neighbor = ws_neighbor_class_entry_get (& interface -> ws_info -> neighbor_storage , neighbor_buffer -> neighbor -> index );
@@ -1421,27 +1415,6 @@ static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_en
14211415 return false;
14221416 }
14231417
1424- if (multicast ) {
1425- //for multicast neighbour we must limit if we have already enough information
1426- if (interface -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER ) {
1427- //Border router never allocate neighbors by multicast
1428- return false;
1429- }
1430-
1431- uint16_t parent_candidate_size = rpl_control_parent_candidate_list_size (interface , false);
1432-
1433- //if we have enough candidates at list do not accept new multicast neighbours
1434- if (parent_candidate_size >= 4 ) {
1435- return false;
1436- }
1437-
1438- parent_candidate_size = rpl_control_parent_candidate_list_size (interface , true);
1439- //If we have already enough parent selected Candidates count is bigger tahn 4
1440- if (parent_candidate_size >= 2 ) {
1441- return false;
1442- }
1443- }
1444-
14451418 ws_bootstrap_neighbor_table_clean (interface );
14461419
14471420 neighbor_buffer -> neighbor = ws_bootstrap_mac_neighbor_add (interface , mac_64 );
@@ -1458,6 +1431,24 @@ static bool ws_bootstrap_neighbor_info_request(struct protocol_interface_info_en
14581431 return true;
14591432}
14601433
1434+ static bool ws_rpl_dio_new_parent_accept (struct protocol_interface_info_entry * interface )
1435+ {
1436+ uint16_t parent_candidate_size = rpl_control_parent_candidate_list_size (interface , false);
1437+ //TODO check bootstarap state for review
1438+ //if we have enough candidates at list do not accept new multicast neighbours
1439+ if (parent_candidate_size > WS_NEIGHBOUR_MAX_CANDIDATE_PROBE ) {
1440+ return false;
1441+ }
1442+
1443+ parent_candidate_size = rpl_control_parent_candidate_list_size (interface , true);
1444+ //If we have already enough parent selected Candidates count is bigger tahn 4
1445+ if (parent_candidate_size >= 2 ) {
1446+ return false;
1447+ }
1448+
1449+ return true;
1450+ }
1451+
14611452
14621453static void ws_neighbor_entry_remove_notify (mac_neighbor_table_entry_t * entry_ptr , void * user_data )
14631454{
@@ -2010,6 +2001,48 @@ static void ws_rpl_prefix_callback(prefix_entry_t *prefix, void *handle, uint8_t
20102001 }
20112002}
20122003
2004+ static bool ws_rpl_new_parent_callback_t (uint8_t * ll_parent_address , void * handle )
2005+ {
2006+
2007+ protocol_interface_info_entry_t * cur = handle ;
2008+ if (!cur -> rpl_domain || cur -> interface_mode != INTERFACE_UP ) {
2009+ return false;
2010+ }
2011+
2012+ uint8_t mac64 [8 ];
2013+ memcpy (mac64 , ll_parent_address + 8 , 8 );
2014+ mac64 [0 ] ^= 2 ;
2015+ llc_neighbour_req_t neigh_buffer ;
2016+ if (ws_bootstrap_neighbor_info_request (cur , mac64 , & neigh_buffer , false)) {
2017+ return true;
2018+ }
2019+
2020+ if (!ws_rpl_dio_new_parent_accept (cur )) {
2021+ return false;
2022+ }
2023+
2024+ //Discover Multicast temporary entry
2025+
2026+ ws_neighbor_temp_class_t * entry = ws_llc_get_multicast_temp_entry (cur , mac64 );
2027+ if (!entry ) {
2028+ return false;
2029+ }
2030+ //Create entry
2031+ bool create_ok = ws_bootstrap_neighbor_info_request (cur , mac64 , & neigh_buffer , true);
2032+ if (create_ok ) {
2033+ ws_neighbor_class_entry_t * ws_neigh = neigh_buffer .ws_neighbor ;
2034+ //Copy fhss temporary data
2035+ * ws_neigh = entry -> neigh_info_list ;
2036+ //ETX Create here
2037+ etx_lqi_dbm_update (cur -> id , entry -> mpduLinkQuality , entry -> signal_dbm , neigh_buffer .neighbor -> index );
2038+ mac_neighbor_table_trusted_neighbor (mac_neighbor_info (cur ), neigh_buffer .neighbor , true);
2039+ }
2040+ ws_llc_free_multicast_temp_entry (cur , entry );
2041+
2042+
2043+ return create_ok ;
2044+ }
2045+
20132046static void ws_bootstrap_rpl_activate (protocol_interface_info_entry_t * cur )
20142047{
20152048 tr_debug ("RPL Activate" );
@@ -2018,7 +2051,7 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
20182051
20192052 addr_add_router_groups (cur );
20202053 rpl_control_set_domain_on_interface (cur , protocol_6lowpan_rpl_domain , downstream );
2021- rpl_control_set_callback (protocol_6lowpan_rpl_domain , ws_bootstrap_rpl_callback , ws_rpl_prefix_callback , cur );
2054+ rpl_control_set_callback (protocol_6lowpan_rpl_domain , ws_bootstrap_rpl_callback , ws_rpl_prefix_callback , ws_rpl_new_parent_callback_t , cur );
20222055 // If i am router I Do this
20232056 rpl_control_force_leaf (protocol_6lowpan_rpl_domain , leaf );
20242057 rpl_control_request_parent_link_confirmation (true);
@@ -2493,6 +2526,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
24932526 cur -> ws_info -> trickle_pas_running = false;
24942527 cur -> ws_info -> trickle_pcs_running = false;
24952528
2529+ // Indicate PAE controller that bootstrap is ready
2530+ ws_pae_controller_bootstrap_done (cur );
2531+
24962532 ws_bootstrap_advertise_start (cur );
24972533 ws_bootstrap_state_change (cur , ER_BOOTSRAP_DONE );
24982534 break ;
@@ -2520,7 +2556,7 @@ void ws_bootstrap_network_scan_process(protocol_interface_info_entry_t *cur)
25202556
25212557 // Add EAPOL neighbour
25222558 llc_neighbour_req_t neighbor_info ;
2523- if (!ws_bootstrap_neighbor_info_request (cur , cur -> ws_info -> parent_info .addr , & neighbor_info , true, false )) {
2559+ if (!ws_bootstrap_neighbor_info_request (cur , cur -> ws_info -> parent_info .addr , & neighbor_info , true)) {
25242560 return ;
25252561 }
25262562
0 commit comments