Skip to content

Commit

Permalink
REED and FED links removed (ARMmbed#1796)
Browse files Browse the repository at this point in the history
Removed old partition links from REED and FED
when moving to new partition.
  • Loading branch information
deepakvenugopal authored Aug 28, 2018
1 parent b162d7b commit f39312b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
25 changes: 25 additions & 0 deletions source/6LoWPAN/Thread/thread_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,31 @@ void thread_neighbor_list_clean(struct protocol_interface_info_entry *cur)
}
}

void thread_reed_fed_neighbour_links_clean(struct protocol_interface_info_entry *cur)
{
mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list;

if (thread_i_am_router(cur)) {
return;
}

if (thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_END_DEVICE ||
thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) {
return;
}

if (!thread_info(cur)->thread_endnode_parent) {
return;
}
ns_list_foreach_safe(mac_neighbor_table_entry_t, cur_entry, mac_table_list) {
// do not remove parent entry
if (memcmp(cur_entry->mac64, thread_info(cur)->thread_endnode_parent->mac64, 8) != 0) {
tr_debug("Free short addr: %x", cur_entry->mac16);
mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), cur_entry);
}
}
}

void thread_clean_old_16_bit_address_based_addresses(protocol_interface_info_entry_t *cur)
{
uint8_t static_address[16];
Expand Down
3 changes: 3 additions & 0 deletions source/6LoWPAN/Thread/thread_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ void thread_general_mle_receive_cb(int8_t interface_id, mle_message_t *mle_msg,
void thread_bootstrap_ready(struct protocol_interface_info_entry *cur);
int thread_bootstrap_reset(struct protocol_interface_info_entry *cur);
void thread_neighbor_list_clean(struct protocol_interface_info_entry *cur);

/* Function to remove linked neighbours for REEDs and FEDs */
void thread_reed_fed_neighbour_links_clean(struct protocol_interface_info_entry *cur);
bool thread_bootstrap_request_network_data(struct protocol_interface_info_entry *cur, struct thread_leader_data_s *leaderData, uint16_t short_address);
bool thread_check_is_this_my_parent(struct protocol_interface_info_entry *cur, struct mac_neighbor_table_entry *entry_temp);
void thread_clean_old_16_bit_address_based_addresses(struct protocol_interface_info_entry *cur);
Expand Down
3 changes: 3 additions & 0 deletions source/6LoWPAN/Thread/thread_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,9 @@ void thread_partition_data_purge(protocol_interface_info_entry_t *cur)
/* Flush address cache */
ipv6_neighbour_cache_flush(&cur->ipv6_neighbour_cache);

/* Remove linked neighbours for REEDs and FEDs */
thread_reed_fed_neighbour_links_clean(cur);

}

bool thread_partition_match(protocol_interface_info_entry_t *cur, thread_leader_data_t *leaderData)
Expand Down
2 changes: 1 addition & 1 deletion source/6LoWPAN/Thread/thread_host_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ static void thread_network_data_clean(protocol_interface_info_entry_t *cur)

static void thread_merge_prepare(protocol_interface_info_entry_t *cur)
{
thread_partition_data_purge(cur);
thread_clean_old_16_bit_address_based_addresses(cur);
mpl_clear_realm_scope_seeds(cur);
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD_PROXIED_HOST, NULL);
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD_PROXIED_DUA_HOST, NULL);
thread_partition_data_purge(cur);
thread_network_data_clean(cur);
cur->nwk_mode = ARM_NWK_GP_IP_MODE;
}
Expand Down
3 changes: 3 additions & 0 deletions test/nanostack/unittest/stub/thread_bootstrap_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ void thread_clean_old_16_bit_address_based_addresses(protocol_interface_info_ent
{
}

void thread_reed_fed_neighbour_links_clean(struct protocol_interface_info_entry *cur)
{
}

void thread_bootstrap_ready(protocol_interface_info_entry_t *cur)
{
Expand Down

0 comments on commit f39312b

Please sign in to comment.