Skip to content

Commit

Permalink
Merge branch 'master' into koli
Browse files Browse the repository at this point in the history
* master:
  entry keep alive flag set to true if entry already exists. (ARMmbed#1675)
  Extra Thread-specific address check handling
  Tighten core "for us" check for unicast addresses
  address query logic implemented(ARMmbed#1667)
  Fix for Router advertisement process in REED (ARMmbed#1658)
  Thread DHCP address allocation fix (ARMmbed#1657)
  removed the dependence of AE message relay on DUA prefix (ARMmbed#1655)
  REED parser refactoring for MLE advertisement (ARMmbed#1654)
  Clear data request flag in child_id_req timeout (ARMmbed#1649)
  • Loading branch information
Jarkko Paso committed Apr 25, 2018
2 parents f578c26 + 073f7e8 commit 3f9b34d
Show file tree
Hide file tree
Showing 17 changed files with 218 additions and 164 deletions.
26 changes: 14 additions & 12 deletions source/6LoWPAN/Thread/thread_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,7 @@ int thread_bootstrap_partition_process(protocol_interface_info_entry_t *cur, uin
tr_debug("Dropping advertisement from old partition without sequence number increase");
return -2;
}
if (heard_partition_routers == 0 && active_routers == 1) {
//heard a REED and I am in a singleton partition so merge
tr_debug("Heard a REED and I am a singleton - merge");
return 2;
}

/*Rule 0: If we are going to form Higher partition than heard we dont try to attach to lower ones
*/
if (thread_extension_enabled(cur) &&
Expand All @@ -351,6 +347,12 @@ int thread_bootstrap_partition_process(protocol_interface_info_entry_t *cur, uin
}
}

if ((heard_partition_routers == 0 && active_routers == 1) && thread_am_router(cur)) {
//heard a REED and I am a lonely router in a singleton partition, so merge
tr_debug("Heard a REED and I am a singleton - merge");
return 2;
}

//Rule 1: A non-singleton Thread Network Partition always has higher priority than a singleton Thread Network Partition
if (heard_partition_routers > 1 && active_routers == 1) {
tr_debug("Heard a nonsingleton and i am a singleton");
Expand Down Expand Up @@ -1815,7 +1817,7 @@ static void thread_dhcp_client_gua_error_cb(int8_t interface, uint8_t dhcp_addr[
}
}

static bool thread_dhcpv6_address_valid(uint8_t *prefixPtr, if_address_list_t *list)
bool thread_dhcpv6_address_entry_available(uint8_t *prefixPtr, if_address_list_t *list)
{
bool addressReady = false;
ns_list_foreach(if_address_entry_t, entry, list) {
Expand Down Expand Up @@ -2509,8 +2511,8 @@ int thread_bootstrap_network_data_process(protocol_interface_info_entry_t *cur,
memcpy(addr, cur->thread_info->threadPrivatePrefixInfo.ulaPrefix, 8);
memcpy(&addr[8], ADDR_SHORT_ADR_SUFFIC, 6);
common_write_16_bit(genericService.routerID, &addr[14]);
thread_dhcp_client_global_address_delete(cur->id, addr, prefixTlv.Prefix);
tr_debug("Delete DHCPv6 given address");
thread_dhcp_client_global_address_delete(cur->id, addr, prefixTlv.Prefix);
}
}

Expand Down Expand Up @@ -2737,7 +2739,7 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
bool validToLearnRoutes, validToLearOnMeshRoute;
thread_network_server_data_entry_t *weHostService = NULL;
uint16_t routerId;
tr_debug("Network Data:");
tr_debug("Network Data process:");
routerId = cur->mac_parameters->mac_short_address;
thread_network_data_cache_entry_t *networkData;
networkData = &cur->thread_info->networkDataStorage;
Expand Down Expand Up @@ -2800,14 +2802,14 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
}
}

if (!thread_dhcpv6_address_valid(curPrefix->servicesPrefix, &cur->ip_addresses)) {
if (!thread_dhcpv6_address_entry_available(curPrefix->servicesPrefix, &cur->ip_addresses)) {
thread_addr_write_mesh_local_16(addr, curBorderRouter->routerID, cur->thread_info);

/* Do not allow multiple DHCP solicits from one prefix => delete previous */
thread_dhcp_client_global_address_delete(cur->id, NULL, curPrefix->servicesPrefix);
if (thread_dhcp_client_get_global_address(cur->id, addr, curPrefix->servicesPrefix, cur->mac, thread_dhcp_client_gua_error_cb) == 0) {
tr_debug("GP Address Requested");
}
}

} else {
/* All end device types perform RLOC16 -> 0xfffe
replacement if stable network data was requested. */
Expand All @@ -2820,7 +2822,7 @@ void thread_bootstrap_network_prefixes_process(protocol_interface_info_entry_t *
}

if (curBorderRouter->P_preferred) {
if (!thread_dhcpv6_address_valid(curPrefix->servicesPrefix, &cur->ip_addresses)) {
if (!thread_dhcpv6_address_entry_available(curPrefix->servicesPrefix, &cur->ip_addresses)) {
icmpv6_slaac_address_add(cur, curPrefix->servicesPrefix, curPrefix->servicesPrefixLen, 0xffffffff, 0xffffffff, true, SLAAC_IID_DEFAULT);
}
}
Expand Down
35 changes: 26 additions & 9 deletions source/6LoWPAN/Thread/thread_dhcpv6_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ int dhcp_solicit_resp_cb(uint16_t instance_id, void *ptr, uint8_t msg_name, uin
tr_error("Sol Not include all Options");
goto error_exit;
}

if (libdhcpv6_nonTemporal_entry_get_by_iaid(dhcp_ia_non_temporal_params.iaId) != srv_data_ptr) {
/* Validate server data availability */
tr_error("Valid instance not found");
goto error_exit;
}

if (srv_data_ptr->IAID != dhcp_ia_non_temporal_params.iaId) {
tr_error("Wrong IAID");
goto error_exit;
Expand Down Expand Up @@ -181,7 +188,9 @@ int thread_dhcp_client_get_global_address(int8_t interface, uint8_t dhcp_addr[st
tr_error("Invalid parameters");
return -1;
}

srv_data_ptr = libdhcvp6_nontemporalAddress_server_data_allocate(interface, dhcp_client.libDhcp_instance, mac64, DHCPV6_DUID_HARDWARE_EUI64_TYPE, prefix, dhcp_addr);

payload_len = libdhcpv6_solication_message_length(DHCPV6_DUID_HARDWARE_EUI64_TYPE, true, 0);
payload_ptr = ns_dyn_mem_temporary_alloc(payload_len);

Expand All @@ -207,6 +216,7 @@ int thread_dhcp_client_get_global_address(int8_t interface, uint8_t dhcp_addr[st
srv_data_ptr->transActionId = dhcp_service_send_req(dhcp_client.service_instance, 0, srv_data_ptr , dhcp_addr, payload_ptr, payload_len, dhcp_solicit_resp_cb);
return srv_data_ptr->transActionId ? 0 : -1;
}

void thread_dhcp_client_global_address_renew(int8_t interface)
{
// only prepared for changes in thread specifications
Expand All @@ -219,15 +229,23 @@ void thread_dhcp_client_global_address_delete(int8_t interface, uint8_t dhcp_add
protocol_interface_info_entry_t *cur;
dhcpv6_client_server_data_t *srv_data_ptr;
(void) dhcp_addr;

srv_data_ptr = libdhcpv6_nonTemporal_entry_get_by_prefix(interface, prefix);
cur = protocol_stack_interface_info_get_by_id(interface);
if (cur == NULL || srv_data_ptr == NULL) {
tr_error("Not valid prefix");
return;
}
dhcp_service_req_remove(srv_data_ptr->transActionId);// remove all pending retransmissions
addr_delete(cur, srv_data_ptr->iaNontemporalAddress.addressPrefix);
libdhcvp6_nontemporalAddress_server_data_free(srv_data_ptr);

do {
if (cur == NULL || srv_data_ptr == NULL) {
return;
}
dhcp_service_req_remove(srv_data_ptr->transActionId);// remove all pending retransmissions
tr_debug("Deleting address: %s", trace_ipv6(srv_data_ptr->iaNontemporalAddress.addressPrefix));

addr_delete(cur, srv_data_ptr->iaNontemporalAddress.addressPrefix);

libdhcvp6_nontemporalAddress_server_data_free(srv_data_ptr);
srv_data_ptr = libdhcpv6_nonTemporal_entry_get_by_prefix(interface, prefix);
} while (srv_data_ptr);

return;
}

Expand Down Expand Up @@ -306,7 +324,7 @@ void thread_dhcpv6_client_set_address(int8_t interface_id, dhcpv6_client_server_

if (address_entry == NULL) {
tr_error("Address add failed");
return ;
return;
}
if (renewTimer) {
// translate seconds to 100ms ticks
Expand All @@ -316,7 +334,6 @@ void thread_dhcpv6_client_set_address(int8_t interface_id, dhcpv6_client_server_
renewTimer = 0xfffffffe;
}
}
tr_debug("Added new address");
address_entry->state_timer = renewTimer;
address_entry->cb = thread_dhcpv6_renew;
}
Expand Down
Loading

0 comments on commit 3f9b34d

Please sign in to comment.