From 7dbad5e8cc844f3f5cf96966dc6f2ee5de9a702c Mon Sep 17 00:00:00 2001 From: Arto Kinnunen Date: Tue, 4 Sep 2018 13:19:53 +0300 Subject: [PATCH] Parent sends full network data in response to data request (#1806) - Parent sends full network data to children in response to data request if Thread neighbor table is uninitialized. - Fix Cppcheck warning by moving trace --- source/6LoWPAN/Thread/thread_router_bootstrap.c | 16 ++++++++++++++-- source/Service_Libs/mdns/ns_fnet_port.c | 3 +-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/source/6LoWPAN/Thread/thread_router_bootstrap.c b/source/6LoWPAN/Thread/thread_router_bootstrap.c index 2365aed998ab..46aa212365ca 100644 --- a/source/6LoWPAN/Thread/thread_router_bootstrap.c +++ b/source/6LoWPAN/Thread/thread_router_bootstrap.c @@ -1991,10 +1991,22 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t * if (!entry_temp || !mle_tlv_read_tlv(MLE_TYPE_TLV_REQUEST, mle_msg->data_ptr, mle_msg->data_length, &requestTlv)) { return; } + + uint8_t mode = mle_mode_write_from_mac_entry(entry_temp); + /* check if thread neighbor class is not initialized */ + if ((thread_neighbor_entry_linkmargin_get(&cur->thread_info->neighbor_class, entry_temp->index) == 0) && + (thread_neighbor_last_communication_time_get(&cur->thread_info->neighbor_class, entry_temp->index) == 0)) { + /* + * Thread neighbor class is not yet initialized and we receive data_request from such child. + * Always send full network data in this case + */ + mode |= MLE_THREAD_REQ_FULL_DATA_SET | MLE_THREAD_SECURED_DATA_REQUEST; + } else { + mode |= thread_neighbor_class_mode_write_from_entry(&cur->thread_info->neighbor_class, entry_temp->index); + } + thread_neighbor_class_update_link(&cur->thread_info->neighbor_class, entry_temp->index,linkMargin, false); thread_neighbor_last_communication_time_update(&cur->thread_info->neighbor_class, entry_temp->index); - uint8_t mode = mle_mode_write_from_mac_entry(entry_temp); - mode |= thread_neighbor_class_mode_write_from_entry(&cur->thread_info->neighbor_class, entry_temp->index); mle_build_and_send_data_response_msg(cur, mle_msg->packet_src_address, mle_msg->data_ptr, mle_msg->data_length, &requestTlv, mode); } break; diff --git a/source/Service_Libs/mdns/ns_fnet_port.c b/source/Service_Libs/mdns/ns_fnet_port.c index 63e904b1911c..346f6f3f8b4f 100644 --- a/source/Service_Libs/mdns/ns_fnet_port.c +++ b/source/Service_Libs/mdns/ns_fnet_port.c @@ -72,10 +72,9 @@ fnet_bool_t fnet_netif_get_ip6_addr (fnet_netif_desc_t netif_desc, fnet_index_t addr_info->type = FNET_NETIF_IP_ADDR_TYPE_AUTOCONFIGURABLE; /* How the address was acquired.*/ result = FNET_TRUE; } + FNET_DEBUG("fnet_netif_get_ip6_addr(), if=%d: %s", (int8_t)netif->scope_id, trace_ipv6(addr_info->address.addr)); } - FNET_DEBUG("fnet_netif_get_ip6_addr(), if=%d: %s", (int8_t)netif->scope_id, trace_ipv6(addr_info->address.addr)); - return result; }