@@ -81,7 +81,7 @@ static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp
81
81
static bool ws_bootstrap_state_discovery (struct protocol_interface_info_entry * cur );
82
82
static 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 );
83
83
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 );
85
85
static uint16_t ws_bootstrap_routing_cost_calculate (protocol_interface_info_entry_t * cur );
86
86
static uint16_t ws_bootstrap_rank_get (protocol_interface_info_entry_t * cur );
87
87
static 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 *
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 );
100
101
101
102
typedef enum {
102
103
WS_PARENT_SOFT_SYNCH = 0 , /**< let FHSS make decision if synchronization is needed*/
103
104
WS_PARENT_HARD_SYNCH , /**< Synch FHSS with latest synch information*/
104
105
WS_EAPOL_PARENT_SYNCH , /**< Broadcast synch with EAPOL parent*/
105
106
} ws_parent_synch_e ;
106
107
108
+
107
109
static void ws_bootsrap_create_ll_address (uint8_t * ll_address , const uint8_t * mac64 )
108
110
{
109
111
memcpy (ll_address , ADDR_LINK_LOCAL_PREFIX , 8 );
@@ -925,7 +927,7 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
925
927
// Save route cost for all neighbours
926
928
llc_neighbour_req_t neighbor_info ;
927
929
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)) {
929
931
neighbor_info .ws_neighbor -> routing_cost = pan_information .routing_cost ;
930
932
}
931
933
@@ -1080,10 +1082,10 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
1080
1082
1081
1083
if (cur -> ws_info -> configuration_learned || cur -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER ) {
1082
1084
//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);
1084
1086
1085
1087
} 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);
1087
1089
if (!neighbour_pointer_valid ) {
1088
1090
return ;
1089
1091
}
@@ -1169,7 +1171,7 @@ static void ws_bootstrap_pan_config_solicit_analyse(struct protocol_interface_in
1169
1171
*/
1170
1172
1171
1173
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)) {
1173
1175
etx_lqi_dbm_update (cur -> id , data -> mpduLinkQuality , data -> signal_dbm , neighbor_info .neighbor -> index );
1174
1176
ws_neighbor_class_neighbor_unicast_time_info_update (neighbor_info .ws_neighbor , ws_utt , data -> timestamp );
1175
1177
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
1366
1368
}
1367
1369
}
1368
1370
1369
- uint32_t link_min_timeout ;
1370
1371
//Read current timestamp
1371
1372
uint32_t time_from_last_unicast_shedule = ws_time_from_last_unicast_traffic (current_time_stamp , ws_neighbor );
1372
1373
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 ) {
1382
1375
//Accept only Enough Old Device
1383
1376
if (!neighbor_entry_ptr ) {
1384
1377
//Accept first compare
@@ -1399,8 +1392,9 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
1399
1392
1400
1393
}
1401
1394
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 )
1403
1396
{
1397
+ neighbor_buffer -> ws_neighbor = NULL ;
1404
1398
neighbor_buffer -> neighbor = mac_neighbor_table_address_discover (mac_neighbor_info (interface ), mac_64 , ADDR_802_15_4_LONG );
1405
1399
if (neighbor_buffer -> neighbor ) {
1406
1400
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
1421
1415
return false;
1422
1416
}
1423
1417
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
-
1445
1418
ws_bootstrap_neighbor_table_clean (interface );
1446
1419
1447
1420
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
1458
1431
return true;
1459
1432
}
1460
1433
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
+
1461
1452
1462
1453
static void ws_neighbor_entry_remove_notify (mac_neighbor_table_entry_t * entry_ptr , void * user_data )
1463
1454
{
@@ -2010,6 +2001,48 @@ static void ws_rpl_prefix_callback(prefix_entry_t *prefix, void *handle, uint8_t
2010
2001
}
2011
2002
}
2012
2003
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
+
2013
2046
static void ws_bootstrap_rpl_activate (protocol_interface_info_entry_t * cur )
2014
2047
{
2015
2048
tr_debug ("RPL Activate" );
@@ -2018,7 +2051,7 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
2018
2051
2019
2052
addr_add_router_groups (cur );
2020
2053
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 );
2022
2055
// If i am router I Do this
2023
2056
rpl_control_force_leaf (protocol_6lowpan_rpl_domain , leaf );
2024
2057
rpl_control_request_parent_link_confirmation (true);
@@ -2493,6 +2526,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
2493
2526
cur -> ws_info -> trickle_pas_running = false;
2494
2527
cur -> ws_info -> trickle_pcs_running = false;
2495
2528
2529
+ // Indicate PAE controller that bootstrap is ready
2530
+ ws_pae_controller_bootstrap_done (cur );
2531
+
2496
2532
ws_bootstrap_advertise_start (cur );
2497
2533
ws_bootstrap_state_change (cur , ER_BOOTSRAP_DONE );
2498
2534
break ;
@@ -2520,7 +2556,7 @@ void ws_bootstrap_network_scan_process(protocol_interface_info_entry_t *cur)
2520
2556
2521
2557
// Add EAPOL neighbour
2522
2558
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)) {
2524
2560
return ;
2525
2561
}
2526
2562
0 commit comments