diff --git a/source/6LoWPAN/Thread/thread_common.c b/source/6LoWPAN/Thread/thread_common.c index 1ef5e4e60d9..afd6552f765 100644 --- a/source/6LoWPAN/Thread/thread_common.c +++ b/source/6LoWPAN/Thread/thread_common.c @@ -1712,7 +1712,8 @@ uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_ // Maximum length of address registrations continue; } - if (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_GLOBAL) { + if (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_GLOBAL || (addr_ipv6_scope(e->address, cur) == IPV6_SCOPE_REALM_LOCAL + && !thread_addr_is_mesh_local_16(e->address, cur))) { ctx = lowpan_context_get_by_address(&cur->lowpan_contexts, e->address); if (ctx) { //Write TLV to list @@ -1725,7 +1726,6 @@ uint8_t *thread_address_registration_tlv_write(uint8_t *ptr, protocol_interface_ memcpy(ptr, e->address, 16); ptr += 16; *address_len_ptr += 17; - } } } diff --git a/source/6LoWPAN/Thread/thread_host_bootstrap.c b/source/6LoWPAN/Thread/thread_host_bootstrap.c index 9f5e5bd5dc1..4a471c92fe7 100644 --- a/source/6LoWPAN/Thread/thread_host_bootstrap.c +++ b/source/6LoWPAN/Thread/thread_host_bootstrap.c @@ -88,7 +88,6 @@ static int thread_parent_request_build(protocol_interface_info_entry_t *cur); static int thread_attach_child_id_request_build(protocol_interface_info_entry_t *cur); static int thread_end_device_synch_response_validate(protocol_interface_info_entry_t *cur, uint8_t *ptr, uint16_t data_length, uint8_t linkMargin, uint8_t *src_address, mle_security_header_t *securityHeader); -static uint8_t *thread_single_address_registration_tlv_write(uint8_t *ptr, lowpan_context_t *ctx, uint8_t *addressPtr); static int8_t thread_end_device_synch_start(protocol_interface_info_entry_t *cur); @@ -1028,25 +1027,6 @@ static bool thread_child_id_req_timeout(int8_t interface_id, uint16_t msgId, boo return false; } -static uint8_t *thread_single_address_registration_tlv_write(uint8_t *ptr, lowpan_context_t *ctx, uint8_t *addressPtr) -{ - *ptr++ = MLE_TYPE_ADDRESS_REGISTRATION; - if (ctx) { - *ptr++ = 9; - //Write TLV to list - *ptr++ = (ctx->cid | 0x80); - memcpy(ptr, addressPtr + 8, 8); - ptr += 8; - } else { - *ptr++ = 17; - //Write TLV to list - *ptr++ = 0; - memcpy(ptr, addressPtr, 16); - ptr += 16; - } - return ptr; -} - static int thread_attach_child_id_request_build(protocol_interface_info_entry_t *cur) { uint8_t *ptr, *address_ptr; @@ -1069,8 +1049,6 @@ static int thread_attach_child_id_request_build(protocol_interface_info_entry_t thread_management_get_current_keysequence(cur->id, &keySequence); mle_service_msg_update_security_params(buf_id, 5, 2, keySequence); - lowpan_context_t *ctx; - uint8_t ml64[16]; uint8_t request_tlv_list[3]; uint8_t macShort[2]; uint8_t reqTlvCnt; @@ -1088,15 +1066,10 @@ static int thread_attach_child_id_request_build(protocol_interface_info_entry_t ptr = mle_tlv_write_response(ptr, scan_parent->challengeData, scan_parent->chal_len); //Add ML-EID - memcpy(ml64, thread_info(cur)->threadPrivatePrefixInfo.ulaPrefix, 8); - memcpy(&ml64[8], cur->iid_slaac, 8); if ((mode & MLE_FFD_DEV) == 0) { - ctx = lowpan_context_get_by_address(&cur->lowpan_contexts, ml64); - if (ctx) { - //Write TLV to list - ptr = thread_single_address_registration_tlv_write(ptr, ctx, ml64); - } + ptr = thread_address_registration_tlv_write(ptr, cur); } + reqTlvCnt = 2; request_tlv_list[0] = MLE_TYPE_NETWORK_DATA;