@@ -1295,6 +1295,16 @@ static void ws_bootstrap_asynch_confirm(struct protocol_interface_info_entry *in
12951295 (void )interface ;
12961296 (void )asynch_message ;
12971297}
1298+
1299+ uint32_t ws_time_from_last_unicast_traffic (uint32_t current_time_stamp , ws_neighbor_class_entry_t * ws_neighbor )
1300+ {
1301+ uint32_t time_from_last_unicast_shedule = current_time_stamp ;
1302+ //Time from last RX unicast in us
1303+ time_from_last_unicast_shedule -= ws_neighbor -> fhss_data .uc_timing_info .utt_rx_timestamp ;
1304+ time_from_last_unicast_shedule /= 1000000 ; //Convert to seconds
1305+ return time_from_last_unicast_shedule ;
1306+ }
1307+
12981308static void ws_bootstrap_neighbor_table_clean (struct protocol_interface_info_entry * interface )
12991309{
13001310 uint8_t ll_target [16 ];
@@ -1305,6 +1315,9 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13051315 }
13061316 memcpy (ll_target , ADDR_LINK_LOCAL_PREFIX , 8 );
13071317
1318+ uint32_t current_time_stamp = 0 ;
1319+ ns_sw_mac_read_current_timestamp (interface -> mac_api , & current_time_stamp );
1320+
13081321 mac_neighbor_table_entry_t * neighbor_entry_ptr = NULL ;
13091322 ns_list_foreach_safe (mac_neighbor_table_entry_t , cur , & mac_neighbor_info (interface )-> neighbour_list ) {
13101323 ws_neighbor_class_entry_t * ws_neighbor = ws_neighbor_class_entry_get (& interface -> ws_info -> neighbor_storage , cur -> index );
@@ -1340,14 +1353,29 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
13401353 }
13411354 }
13421355
1356+ uint32_t link_min_timeout ;
1357+ //Read current timestamp
1358+ uint32_t time_from_last_unicast_shedule = ws_time_from_last_unicast_traffic (current_time_stamp , ws_neighbor );
13431359
13441360
13451361 if (cur -> trusted_device ) {
1346- neighbor_entry_ptr = cur ;
1362+ link_min_timeout = WS_NEIGHBOR_TRUSTED_LINK_MIN_TIMEOUT ;
13471363 } else {
1348- if (cur -> link_lifetime - cur -> lifetime > WS_NEIGHBOR_NOT_TRUSTED_LINK_TIMEOUT ) {
1349- //Accept only Enough Old not trusted Device
1364+
1365+ link_min_timeout = WS_NEIGHBOR_NOT_TRUSTED_LINK_MIN_TIMEOUT ;
1366+ }
1367+
1368+ if (time_from_last_unicast_shedule > link_min_timeout ) {
1369+ //Accept only Enough Old Device
1370+ if (!neighbor_entry_ptr ) {
1371+ //Accept first compare
13501372 neighbor_entry_ptr = cur ;
1373+ } else {
1374+ uint32_t compare_neigh_time = ws_time_from_last_unicast_traffic (current_time_stamp , ws_neighbor_class_entry_get (& interface -> ws_info -> neighbor_storage , neighbor_entry_ptr -> index ));
1375+ if (compare_neigh_time < time_from_last_unicast_shedule ) {
1376+ //Accept older RX timeout allways
1377+ neighbor_entry_ptr = cur ;
1378+ }
13511379 }
13521380 }
13531381 }
0 commit comments