Skip to content

Commit b862823

Browse files
author
Mika Tervonen
committed
Fixed interop findings for DUA handling
Save parent version number if attached to parent that does not support DUA start own registration timers
1 parent a91a2b4 commit b862823

8 files changed

+54
-6
lines changed

source/6LoWPAN/Thread/thread_address_registration_client.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "thread_management_if.h"
4242
#include "thread_tmfcop_lib.h"
4343
#include "coap_service_api.h"
44+
#include "6LoWPAN/Thread/thread_extension_constants.h"
4445
#include "6LoWPAN/Thread/thread_management_internal.h"
4546
#include "6LoWPAN/Thread/thread_joiner_application.h"
4647
#include "6LoWPAN/Thread/thread_network_data_lib.h"
@@ -67,6 +68,11 @@ void thread_address_registration_init()
6768
mlr_timer = 0;
6869
}
6970

71+
bool thread_address_registration_running()
72+
{
73+
return enabled;
74+
}
75+
7076
void thread_address_registration_deinit()
7177
{
7278
enabled = false;
@@ -87,9 +93,19 @@ void thread_address_registration_timer(protocol_interface_info_entry_t *interfac
8793
{
8894
uint32_t mlr_timeout;
8995
uint32_t delay_timer;
90-
if (!enabled || !thread_extension_version_check(interface->thread_info->version)) {
96+
if (!enabled || interface->thread_info->version < THREAD_VERSION_1_2) {
9197
return;
9298
}
99+
if (thread_bootstrap_should_register_address(interface)) {
100+
if (!interface->thread_info->thread_endnode_parent) {
101+
// We dont have parent so skip
102+
return;
103+
}
104+
if (interface->thread_info->thread_endnode_parent->version >= THREAD_VERSION_1_2) {
105+
// Parent supports all features
106+
return;
107+
}
108+
}
93109

94110
if (0 != thread_extension_primary_bbr_get(interface, NULL, NULL, &mlr_timeout, &delay_timer)) {
95111
// BBR not present

source/6LoWPAN/Thread/thread_address_registration_client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
#ifdef HAVE_THREAD_V2
3535

3636
void thread_address_registration_init(void);
37+
bool thread_address_registration_running(void);
3738
void thread_address_registration_deinit(void);
3839

3940
void thread_address_registration_timer_set(protocol_interface_info_entry_t *interface, uint16_t dua_delay_seconds, uint16_t mlr_refresh_seconds);
4041
void thread_address_registration_timer(protocol_interface_info_entry_t *interface, uint16_t seconds);
4142
#else
4243

4344
#define thread_address_registration_init(void)
45+
#define thread_address_registration_running(void)
4446
#define thread_address_registration_deinit(void)
4547

4648
#define thread_address_registration_timer_set(interface, dua_delay_seconds, mlr_refresh_seconds);

source/6LoWPAN/Thread/thread_common.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -988,11 +988,7 @@ void thread_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t ticks)
988988
thread_resolution_client_timer(cur->id, ticks);
989989
thread_key_switch_timer(cur, ticks);
990990
thread_child_update_req_timer(cur, ticks);
991-
992-
if (!thread_bootstrap_should_register_address(cur)) {
993-
/* Only FTD refreshes the address registration timer */
994-
thread_address_registration_timer(cur, ticks);
995-
}
991+
thread_address_registration_timer(cur, ticks);
996992

997993
if (thread_attach_ready(cur) != 0) {
998994
return;

source/6LoWPAN/Thread/thread_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ typedef struct thread_connectivity_s {
192192
typedef struct thread_parent_info_s {
193193
uint8_t mac64[8];
194194
uint16_t shortAddress;
195+
uint16_t version;
195196
uint8_t router_id;
196197
uint8_t pathCostToLeader;
197198
bool childUpdatePending: 1;

source/6LoWPAN/Thread/thread_extension.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,35 @@ void thread_extension_address_registration(struct protocol_interface_info_entry
642642
#endif
643643
}
644644

645+
void thread_extension_child_address_registration_response_process(struct protocol_interface_info_entry *interface)
646+
{
647+
// if we are version 3 and parent is lower we need to send registrations for them
648+
649+
if (interface->thread_info->version < THREAD_VERSION_1_2) {
650+
thread_address_registration_deinit();
651+
return;
652+
}
653+
if (!interface->thread_info->thread_endnode_parent) {
654+
// We dont have parent return
655+
thread_address_registration_deinit();
656+
return;
657+
}
658+
if (interface->thread_info->thread_endnode_parent->version >= THREAD_VERSION_1_2) {
659+
//parent supports 1.2
660+
thread_address_registration_deinit();
661+
return;
662+
}
663+
// We will start address registration timers
664+
665+
if (!thread_address_registration_running()) {
666+
uint32_t dua_delay = randLIB_get_random_in_range(1, 5);
667+
thread_extension_primary_bbr_get(interface, NULL, NULL, NULL, &dua_delay);
668+
669+
thread_address_registration_init();
670+
thread_address_registration_timer_set(interface, 1 + randLIB_get_random_in_range(0, dua_delay / 1000), randLIB_get_random_in_range(1, 5));
671+
}
672+
}
673+
645674
void thread_extension_dua_address_generate(protocol_interface_info_entry_t *cur, const uint8_t *domain_prefix, uint8_t domain_prefix_len)
646675
{
647676
if_address_entry_t *def_address = NULL;

source/6LoWPAN/Thread/thread_extension.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void thread_extension_mtd_service_register(protocol_interface_info_entry_t *cur)
4949
void thread_extension_network_data_process(struct protocol_interface_info_entry *cur);
5050
int thread_extension_primary_bbr_get(struct protocol_interface_info_entry *cur, uint8_t *addr_ptr, uint8_t *seq_ptr, uint32_t *timer1_ptr, uint32_t *timer2_ptr);
5151
void thread_extension_address_registration(struct protocol_interface_info_entry *interface, const uint8_t *addr, const uint8_t *child_mac64, bool refresh_child_entry, bool duplicate_child_detected);
52+
void thread_extension_child_address_registration_response_process(struct protocol_interface_info_entry *interface);
5253
void thread_extension_dua_address_generate(protocol_interface_info_entry_t *cur, const uint8_t *domain_prefix, uint8_t domain_prefix_len);
5354
void thread_extension_aloc_generate(struct protocol_interface_info_entry *cur);
5455
bool thread_extension_aloc_map(protocol_interface_info_entry_t *cur, uint16_t *addr16);
@@ -80,6 +81,7 @@ uint8_t *thread_extension_discover_response_write(protocol_interface_info_entry_
8081
#define thread_extension_network_data_process(cur) ((void) 0)
8182
#define thread_extension_primary_bbr_get(cur,addr_ptr,seq_ptr,timer1_ptr, timer2_ptr) (-1)
8283
#define thread_extension_address_registration(interface,addr,child_mac64,refresh_child_entry,duplicate_child_detected) ((void) 0)
84+
#define thread_extension_child_address_registration_response_process(interface) ((void) 0)
8385
#define thread_extension_aloc_generate(cur) ((void) 0)
8486
#define thread_extension_aloc_map(cur, addr16) (false)
8587
#define thread_extension_mcast_subscrition_change(interface) ((void) 0)

source/6LoWPAN/Thread/thread_host_bootstrap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ static void thread_mle_child_request_receive_cb(int8_t interface_id, mle_message
897897
parent->shortAddress = scan_result->shortAddress;
898898
parent->router_id = (scan_result->shortAddress >> 10);
899899
memcpy(parent->mac64, scan_result->mac64, 8);
900+
parent->version = scan_result->version;
900901
//Check Network Data TLV
901902
if (networkDataTlv.tlvType == MLE_TYPE_NETWORK_DATA) {
902903
thread_bootstrap_network_data_save(cur, &leaderData, networkDataTlv.dataPtr, networkDataTlv.tlvLen);

source/6LoWPAN/Thread/thread_mle_message_handler.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ static bool thread_address_registration_tlv_check(protocol_interface_info_entry_
744744
}
745745
}
746746
}
747+
thread_extension_child_address_registration_response_process(cur);
747748

748749
return ret_val;
749750
}

0 commit comments

Comments
 (0)