Skip to content

Commit

Permalink
Detection of duplicate address entries updated (ARMmbed#1686)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakvenugopal authored May 2, 2018
1 parent f28cce8 commit a573bc4
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
43 changes: 33 additions & 10 deletions source/6LoWPAN/Thread/thread_extension_bbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ typedef struct {
uint8_t ml_eid[8];
uint8_t target_eid[16];
uint16_t ttl;
uint8_t dua_dad_repeat;
ns_list_link_t link;
} duplicate_dua_tr_t;

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

/*
0 – Successful registration
Expand Down Expand Up @@ -164,7 +167,8 @@ static duplicate_dua_tr_t *thread_border_router_dup_tr_create(int8_t interface_i
memcpy(this->target_eid, target_eid_ptr,16);
memcpy(this->source_address, source_addr_ptr, 16);
memcpy(this->ml_eid, ml_eid_ptr,8);
this->ttl = 2;
this->dua_dad_repeat = THREAD_BBR_DUA_DAD_REPEATS;
this->ttl = THREAD_BBR_DUA_DAD_QUERY_TIMEOUT;
return this;
}

Expand Down Expand Up @@ -1062,6 +1066,31 @@ bool thread_extension_bbr_nd_query_process(protocol_interface_info_entry_t *cur,

}

static void thread_extension_bbr_dad_process(protocol_interface_info_entry_t *cur, thread_pbbr_t *this, uint32_t seconds)
{
ns_list_foreach_safe(duplicate_dua_tr_t, cur_dup_tr, &duplicate_dua_tr_list) {
if (cur_dup_tr->interface_id != cur->id) {
continue;
}
if (cur_dup_tr->ttl > seconds) {
cur_dup_tr->ttl -= seconds;
} else {
cur_dup_tr->dua_dad_repeat--;
// repeat dad for one more time
if (cur_dup_tr->dua_dad_repeat > 0) {
cur_dup_tr->ttl = THREAD_BBR_DUA_DAD_QUERY_TIMEOUT;
thread_border_router_bb_qry_send(this,cur_dup_tr->target_eid,NULL);
return;
} else {
// dad completed
// send PRO_BB.ntf and delete dad entry
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);
thread_border_router_dup_tr_delete(cur_dup_tr);
}
}
}
}

void thread_extension_bbr_route_update(protocol_interface_info_entry_t *cur)
{
// if we have DUA prefix in settings
Expand Down Expand Up @@ -1095,6 +1124,7 @@ void thread_extension_bbr_route_update(protocol_interface_info_entry_t *cur)
}
}


void thread_extension_bbr_seconds_timer(int8_t interface_id, uint32_t seconds)
{
thread_pbbr_t *this = thread_bbr_find_by_interface(interface_id);
Expand Down Expand Up @@ -1146,15 +1176,8 @@ void thread_extension_bbr_seconds_timer(int8_t interface_id, uint32_t seconds)
// Check secondary state if we need to drop

// Check pending dua registrations
ns_list_foreach_safe(duplicate_dua_tr_t, cur_dup_tr, &duplicate_dua_tr_list) {
if (cur_dup_tr->interface_id == interface_id && cur_dup_tr->ttl > seconds) {
cur_dup_tr->ttl -= seconds;
// TODO Repeat the ANS 2 times.
} else {
// Timeout Remmove the duplicate detection timer
thread_border_router_dup_tr_delete(cur_dup_tr);
}
}
thread_extension_bbr_dad_process(cur, this, seconds);

if (this->dua_timer_ticks) {
if (this->dua_timer_ticks > seconds) {
this->dua_timer_ticks -= seconds;
Expand Down
9 changes: 9 additions & 0 deletions source/6LoWPAN/Thread/thread_joiner_application.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,15 @@ link_configuration_s *thread_joiner_application_get_config(int8_t interface_id)
return this->configuration_ptr;
}

uint8_t *thread_joiner_application_network_name_get(int8_t interface_id)
{
thread_joiner_t *this = thread_joiner_find(interface_id);
if (!this) {
return NULL;
}
return this->configuration_ptr->name;
}

static int thread_joiner_application_nvm_link_config_read(thread_joiner_t *this) {

// read config from NVM, in case of failure current settings are unchanged.
Expand Down
1 change: 1 addition & 0 deletions source/6LoWPAN/Thread/thread_joiner_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct link_configuration *thread_joiner_application_get_config(int8_t interface
uint64_t thread_joiner_application_active_timestamp_get(int8_t interface_id);
uint8_t thread_joiner_application_security_policy_get(int8_t interface_id);
void thread_joiner_application_active_timestamp_set(int8_t interface_id, uint64_t timestamp);
uint8_t *thread_joiner_application_network_name_get(int8_t interface_id);
uint8_t *thread_joiner_application_active_config_tlv_list_get(uint8_t interface_id, uint16_t *length);

uint8_t *thread_joiner_application_active_config_params_get(uint8_t interface_id, uint16_t *length);
Expand Down

0 comments on commit a573bc4

Please sign in to comment.