Skip to content

Commit 3d07365

Browse files
author
Arto Kinnunen
committed
Review corrections to network data clearing
-review corrections -Update thread_addr_is_child, now it fails if checking router address
1 parent 22a0375 commit 3d07365

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

source/6LoWPAN/Thread/thread_border_router_api.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -297,22 +297,19 @@ static bool thread_border_router_local_network_data_prefix_match(thread_network_
297297
return true;
298298
}
299299

300-
static void thread_border_router_children_network_data_check_and_clean(uint8_t interface_id, uint16_t child_id)
300+
static void thread_border_router_child_network_data_clean(uint8_t interface_id, uint16_t child_id)
301301
{
302302
uint8_t addr16_buf[2];
303303

304-
if (thread_is_router_addr(child_id)) {
305-
// Do not check routers
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 */
306307
return;
307308
}
308309

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-
}
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);
316313
}
317314

318315
static void thread_border_router_lost_children_nwk_data_validate(protocol_interface_info_entry_t *cur, uint16_t router_short_addr)
@@ -331,15 +328,15 @@ static void thread_border_router_lost_children_nwk_data_validate(protocol_interf
331328
ns_list_foreach(thread_network_server_data_entry_t, curRoute, &curLP->routeList) {
332329
if (thread_addr_is_child(router_short_addr, curRoute->routerID)) {
333330
// Router children found
334-
thread_border_router_children_network_data_check_and_clean(cur->id, curRoute->routerID);
331+
thread_border_router_child_network_data_clean(cur->id, curRoute->routerID);
335332
}
336333
}
337334

338335
/* Go through all BR's */
339336
ns_list_foreach(thread_network_server_data_entry_t, curBR, &curLP->borderRouterList) {
340337
if (thread_addr_is_child(router_short_addr, curBR->routerID)) {
341338
// Router children found
342-
thread_border_router_children_network_data_check_and_clean(cur->id, curBR->routerID);
339+
thread_border_router_child_network_data_clean(cur->id, curBR->routerID);
343340
}
344341
}
345342
}
@@ -349,7 +346,7 @@ static void thread_border_router_lost_children_nwk_data_validate(protocol_interf
349346
ns_list_foreach(thread_network_data_service_server_entry_t, server, &service->server_list) {
350347
if (thread_addr_is_child(router_short_addr, server->router_id)) {
351348
// Router children found
352-
thread_border_router_children_network_data_check_and_clean(cur->id, server->router_id);
349+
thread_border_router_child_network_data_clean(cur->id, server->router_id);
353350
}
354351
}
355352
}

source/6LoWPAN/Thread/thread_router_bootstrap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ static bool thread_child_id_request(protocol_interface_info_entry_t *cur, mle_ne
11941194
}
11951195

11961196
//allocate child address if current is router, 0xffff or not our child
1197-
if (!thread_addr_is_equal_or_child(mac_helper_mac16_address_get(cur), entry_temp->short_adr)) {
1197+
if (!thread_addr_is_child(mac_helper_mac16_address_get(cur), entry_temp->short_adr)) {
11981198
entry_temp->short_adr = thread_router_bootstrap_child_address_generate(cur);
11991199
}
12001200

source/6LoWPAN/Thread/thread_routing.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ THREAD_ROUTING_FN bool thread_is_router_addr(uint16_t addr)
163163
/* Return true if b is a child of a */
164164
THREAD_ROUTING_FN bool thread_addr_is_child(uint16_t a, uint16_t b)
165165
{
166+
if (thread_is_router_addr(b)) {
167+
return false;
168+
}
166169
return thread_router_addr_from_addr(b) == a;
167170
}
168171

0 commit comments

Comments
 (0)