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