@@ -1295,6 +1295,16 @@ static void ws_bootstrap_asynch_confirm(struct protocol_interface_info_entry *in
1295
1295
(void )interface ;
1296
1296
(void )asynch_message ;
1297
1297
}
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
+
1298
1308
static void ws_bootstrap_neighbor_table_clean (struct protocol_interface_info_entry * interface )
1299
1309
{
1300
1310
uint8_t ll_target [16 ];
@@ -1305,6 +1315,9 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
1305
1315
}
1306
1316
memcpy (ll_target , ADDR_LINK_LOCAL_PREFIX , 8 );
1307
1317
1318
+ uint32_t current_time_stamp = 0 ;
1319
+ ns_sw_mac_read_current_timestamp (interface -> mac_api , & current_time_stamp );
1320
+
1308
1321
mac_neighbor_table_entry_t * neighbor_entry_ptr = NULL ;
1309
1322
ns_list_foreach_safe (mac_neighbor_table_entry_t , cur , & mac_neighbor_info (interface )-> neighbour_list ) {
1310
1323
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
1340
1353
}
1341
1354
}
1342
1355
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 );
1343
1359
1344
1360
1345
1361
if (cur -> trusted_device ) {
1346
- neighbor_entry_ptr = cur ;
1362
+ link_min_timeout = WS_NEIGHBOR_TRUSTED_LINK_MIN_TIMEOUT ;
1347
1363
} 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
1350
1372
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
+ }
1351
1379
}
1352
1380
}
1353
1381
}
0 commit comments