@@ -297,6 +297,61 @@ static bool thread_border_router_local_network_data_prefix_match(thread_network_
297
297
return true;
298
298
}
299
299
300
+ static void thread_border_router_child_network_data_clean (uint8_t interface_id , uint16_t child_id )
301
+ {
302
+ uint8_t addr16_buf [2 ];
303
+
304
+ common_write_16_bit (child_id , addr16_buf );
305
+ if (mle_class_get_by_link_address (interface_id , addr16_buf , ADDR_802_15_4_SHORT )) {
306
+ /* Child is available in mle, do nothing */
307
+ return ;
308
+ }
309
+
310
+ // Child is not our child => network data contains data from lost children, remove it
311
+ tr_debug ("Remove nwk data from lost child: %04x" , child_id );
312
+ thread_management_client_network_data_unregister (interface_id , child_id );
313
+ }
314
+
315
+ static void thread_border_router_lost_children_nwk_data_validate (protocol_interface_info_entry_t * cur , uint16_t router_short_addr )
316
+ {
317
+
318
+ tr_debug ("thread_border_router_lost_children_nwk_data_validate() %x" , router_short_addr );
319
+ if (!thread_is_router_addr (router_short_addr )) {
320
+ // not validating children nwk data
321
+ return ;
322
+ }
323
+
324
+ thread_network_data_cache_entry_t * network_data = & cur -> thread_info -> networkDataStorage ;
325
+
326
+ ns_list_foreach (thread_network_data_prefix_cache_entry_t , curLP , & network_data -> localPrefixList ) {
327
+ /* Go throgh all routes */
328
+ ns_list_foreach (thread_network_server_data_entry_t , curRoute , & curLP -> routeList ) {
329
+ if (thread_addr_is_child (router_short_addr , curRoute -> routerID )) {
330
+ // Router children found
331
+ thread_border_router_child_network_data_clean (cur -> id , curRoute -> routerID );
332
+ }
333
+ }
334
+
335
+ /* Go through all BR's */
336
+ ns_list_foreach (thread_network_server_data_entry_t , curBR , & curLP -> borderRouterList ) {
337
+ if (thread_addr_is_child (router_short_addr , curBR -> routerID )) {
338
+ // Router children found
339
+ thread_border_router_child_network_data_clean (cur -> id , curBR -> routerID );
340
+ }
341
+ }
342
+ }
343
+
344
+ /* Go throgh all services */
345
+ ns_list_foreach (thread_network_data_service_cache_entry_t , service , & network_data -> service_list ) {
346
+ ns_list_foreach (thread_network_data_service_server_entry_t , server , & service -> server_list ) {
347
+ if (thread_addr_is_child (router_short_addr , server -> router_id )) {
348
+ // Router children found
349
+ thread_border_router_child_network_data_clean (cur -> id , server -> router_id );
350
+ }
351
+ }
352
+ }
353
+ }
354
+
300
355
static bool thread_border_router_local_network_data_service_match (thread_network_local_data_cache_entry_t * local_data , thread_network_data_service_cache_entry_t * service , uint16_t router_id )
301
356
{
302
357
bool instance_found = false;
@@ -372,6 +427,8 @@ static bool thread_border_router_local_srv_data_in_network_data_check(protocol_i
372
427
}
373
428
}
374
429
430
+ thread_border_router_lost_children_nwk_data_validate (cur , router_id );
431
+
375
432
return true;
376
433
}
377
434
0 commit comments