Skip to content

Commit a573bc4

Browse files
Detection of duplicate address entries updated (#1686)
1 parent f28cce8 commit a573bc4

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed

source/6LoWPAN/Thread/thread_extension_bbr.c

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ typedef struct {
9191
uint8_t ml_eid[8];
9292
uint8_t target_eid[16];
9393
uint16_t ttl;
94+
uint8_t dua_dad_repeat;
9495
ns_list_link_t link;
9596
} duplicate_dua_tr_t;
9697

@@ -101,6 +102,8 @@ static NS_LIST_DEFINE(duplicate_dua_tr_list, duplicate_dua_tr_t, link);
101102
#define THREAD_BBR_DUA_REGISTRATION_TIMEOUT 3600
102103
#define THREAD_BBR_DUA_REGISTRATION_DELAY 5000 // 5 seconds in ms
103104
#define THREAD_BBR_BACKBONE_PORT 5683 //<* Backbone border router
105+
#define THREAD_BBR_DUA_DAD_QUERY_TIMEOUT 1 // wait period for Duplicate Address Detection
106+
#define THREAD_BBR_DUA_DAD_REPEATS 2 // multicast repeated as part of DUA
104107

105108
/*
106109
0 – Successful registration
@@ -164,7 +167,8 @@ static duplicate_dua_tr_t *thread_border_router_dup_tr_create(int8_t interface_i
164167
memcpy(this->target_eid, target_eid_ptr,16);
165168
memcpy(this->source_address, source_addr_ptr, 16);
166169
memcpy(this->ml_eid, ml_eid_ptr,8);
167-
this->ttl = 2;
170+
this->dua_dad_repeat = THREAD_BBR_DUA_DAD_REPEATS;
171+
this->ttl = THREAD_BBR_DUA_DAD_QUERY_TIMEOUT;
168172
return this;
169173
}
170174

@@ -1062,6 +1066,31 @@ bool thread_extension_bbr_nd_query_process(protocol_interface_info_entry_t *cur,
10621066

10631067
}
10641068

1069+
static void thread_extension_bbr_dad_process(protocol_interface_info_entry_t *cur, thread_pbbr_t *this, uint32_t seconds)
1070+
{
1071+
ns_list_foreach_safe(duplicate_dua_tr_t, cur_dup_tr, &duplicate_dua_tr_list) {
1072+
if (cur_dup_tr->interface_id != cur->id) {
1073+
continue;
1074+
}
1075+
if (cur_dup_tr->ttl > seconds) {
1076+
cur_dup_tr->ttl -= seconds;
1077+
} else {
1078+
cur_dup_tr->dua_dad_repeat--;
1079+
// repeat dad for one more time
1080+
if (cur_dup_tr->dua_dad_repeat > 0) {
1081+
cur_dup_tr->ttl = THREAD_BBR_DUA_DAD_QUERY_TIMEOUT;
1082+
thread_border_router_bb_qry_send(this,cur_dup_tr->target_eid,NULL);
1083+
return;
1084+
} else {
1085+
// dad completed
1086+
// send PRO_BB.ntf and delete dad entry
1087+
thread_border_router_bb_ans_send(this, this->pbbr_multicast_address, cur_dup_tr->target_eid, cur_dup_tr->ml_eid, 0, thread_joiner_application_network_name_get(cur->id), NULL);
1088+
thread_border_router_dup_tr_delete(cur_dup_tr);
1089+
}
1090+
}
1091+
}
1092+
}
1093+
10651094
void thread_extension_bbr_route_update(protocol_interface_info_entry_t *cur)
10661095
{
10671096
// if we have DUA prefix in settings
@@ -1095,6 +1124,7 @@ void thread_extension_bbr_route_update(protocol_interface_info_entry_t *cur)
10951124
}
10961125
}
10971126

1127+
10981128
void thread_extension_bbr_seconds_timer(int8_t interface_id, uint32_t seconds)
10991129
{
11001130
thread_pbbr_t *this = thread_bbr_find_by_interface(interface_id);
@@ -1146,15 +1176,8 @@ void thread_extension_bbr_seconds_timer(int8_t interface_id, uint32_t seconds)
11461176
// Check secondary state if we need to drop
11471177

11481178
// Check pending dua registrations
1149-
ns_list_foreach_safe(duplicate_dua_tr_t, cur_dup_tr, &duplicate_dua_tr_list) {
1150-
if (cur_dup_tr->interface_id == interface_id && cur_dup_tr->ttl > seconds) {
1151-
cur_dup_tr->ttl -= seconds;
1152-
// TODO Repeat the ANS 2 times.
1153-
} else {
1154-
// Timeout Remmove the duplicate detection timer
1155-
thread_border_router_dup_tr_delete(cur_dup_tr);
1156-
}
1157-
}
1179+
thread_extension_bbr_dad_process(cur, this, seconds);
1180+
11581181
if (this->dua_timer_ticks) {
11591182
if (this->dua_timer_ticks > seconds) {
11601183
this->dua_timer_ticks -= seconds;

source/6LoWPAN/Thread/thread_joiner_application.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,15 @@ link_configuration_s *thread_joiner_application_get_config(int8_t interface_id)
917917
return this->configuration_ptr;
918918
}
919919

920+
uint8_t *thread_joiner_application_network_name_get(int8_t interface_id)
921+
{
922+
thread_joiner_t *this = thread_joiner_find(interface_id);
923+
if (!this) {
924+
return NULL;
925+
}
926+
return this->configuration_ptr->name;
927+
}
928+
920929
static int thread_joiner_application_nvm_link_config_read(thread_joiner_t *this) {
921930

922931
// read config from NVM, in case of failure current settings are unchanged.

source/6LoWPAN/Thread/thread_joiner_application.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct link_configuration *thread_joiner_application_get_config(int8_t interface
6969
uint64_t thread_joiner_application_active_timestamp_get(int8_t interface_id);
7070
uint8_t thread_joiner_application_security_policy_get(int8_t interface_id);
7171
void thread_joiner_application_active_timestamp_set(int8_t interface_id, uint64_t timestamp);
72+
uint8_t *thread_joiner_application_network_name_get(int8_t interface_id);
7273
uint8_t *thread_joiner_application_active_config_tlv_list_get(uint8_t interface_id, uint16_t *length);
7374

7475
uint8_t *thread_joiner_application_active_config_params_get(uint8_t interface_id, uint16_t *length);

0 commit comments

Comments
 (0)