Skip to content

Commit

Permalink
Fix global address detection (ARMmbed#2392)
Browse files Browse the repository at this point in the history
Detect global address availability when DAD is completed. The new
address is not yet in the ip_addresses list and therefore detecting
address scope by looping the IP addresses does not work here.
  • Loading branch information
Arto Kinnunen authored Jun 24, 2020
1 parent f27fe86 commit 9a10d66
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
#define TRACE_GROUP "wsbs"



static void ws_bootstrap_event_handler(arm_event_s *event);
static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp_state_t nwk_bootstrap_state);
static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *cur);
Expand Down Expand Up @@ -221,11 +220,11 @@ static void ws_address_reregister_trig(struct protocol_interface_info_entry *int

static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_entry *interface, const struct if_address_entry *addr, if_address_callback_t reason)
{

/* No need for LL address registration */
if (addr->source == ADDR_SOURCE_UNKNOWN || !interface->ws_info) {
return;
}

if (reason == ADDR_CALLBACK_DAD_COMPLETE) {
//If address is generated manually we need to force registration
if (addr->source != ADDR_SOURCE_DHCP) {
Expand All @@ -235,7 +234,10 @@ static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_
ws_address_registration_update(interface, addr->address);
}
ws_address_reregister_trig(interface);

}
if (addr_ipv6_scope(addr->address, interface) > IPV6_SCOPE_LINK_LOCAL) {
// at least ula address available inside mesh.
interface->global_address_available = true;
}
} else if (reason == ADDR_CALLBACK_DELETED) {
// What to do?
Expand All @@ -248,17 +250,17 @@ static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_
}
//Discover prefix policy
addr_policy_remove_by_label(WS_NON_PREFFRED_LABEL);
}

// Check the Address status if we have global address available.
interface->global_address_available = false;
ns_list_foreach(if_address_entry_t, addr_str, &interface->ip_addresses) {
if (addr_ipv6_scope(addr_str->address, interface) > IPV6_SCOPE_LINK_LOCAL) {
// at least ula address available inside mesh.
interface->global_address_available = true;
break;
interface->global_address_available = false;
ns_list_foreach(if_address_entry_t, addr_str, &interface->ip_addresses) {
if (addr_ipv6_scope(addr_str->address, interface) > IPV6_SCOPE_LINK_LOCAL) {
// at least ula address available inside mesh.
interface->global_address_available = true;
break;
}
}
}

// Addressing in Wi-SUN interface was changed for Border router send new event so Application can update the state
if (interface->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER &&
interface->nwk_bootstrap_state == ER_BOOTSRAP_DONE) {
Expand Down

0 comments on commit 9a10d66

Please sign in to comment.