Skip to content

Commit 9a10d66

Browse files
author
Arto Kinnunen
authored
Fix global address detection (ARMmbed#2392)
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.
1 parent f27fe86 commit 9a10d66

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
#define TRACE_GROUP "wsbs"
7777

7878

79-
8079
static void ws_bootstrap_event_handler(arm_event_s *event);
8180
static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp_state_t nwk_bootstrap_state);
8281
static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *cur);
@@ -221,11 +220,11 @@ static void ws_address_reregister_trig(struct protocol_interface_info_entry *int
221220

222221
static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_entry *interface, const struct if_address_entry *addr, if_address_callback_t reason)
223222
{
224-
225223
/* No need for LL address registration */
226224
if (addr->source == ADDR_SOURCE_UNKNOWN || !interface->ws_info) {
227225
return;
228226
}
227+
229228
if (reason == ADDR_CALLBACK_DAD_COMPLETE) {
230229
//If address is generated manually we need to force registration
231230
if (addr->source != ADDR_SOURCE_DHCP) {
@@ -235,7 +234,10 @@ static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_
235234
ws_address_registration_update(interface, addr->address);
236235
}
237236
ws_address_reregister_trig(interface);
238-
237+
}
238+
if (addr_ipv6_scope(addr->address, interface) > IPV6_SCOPE_LINK_LOCAL) {
239+
// at least ula address available inside mesh.
240+
interface->global_address_available = true;
239241
}
240242
} else if (reason == ADDR_CALLBACK_DELETED) {
241243
// What to do?
@@ -248,17 +250,17 @@ static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_
248250
}
249251
//Discover prefix policy
250252
addr_policy_remove_by_label(WS_NON_PREFFRED_LABEL);
251-
}
252253

253-
// Check the Address status if we have global address available.
254-
interface->global_address_available = false;
255-
ns_list_foreach(if_address_entry_t, addr_str, &interface->ip_addresses) {
256-
if (addr_ipv6_scope(addr_str->address, interface) > IPV6_SCOPE_LINK_LOCAL) {
257-
// at least ula address available inside mesh.
258-
interface->global_address_available = true;
259-
break;
254+
interface->global_address_available = false;
255+
ns_list_foreach(if_address_entry_t, addr_str, &interface->ip_addresses) {
256+
if (addr_ipv6_scope(addr_str->address, interface) > IPV6_SCOPE_LINK_LOCAL) {
257+
// at least ula address available inside mesh.
258+
interface->global_address_available = true;
259+
break;
260+
}
260261
}
261262
}
263+
262264
// Addressing in Wi-SUN interface was changed for Border router send new event so Application can update the state
263265
if (interface->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER &&
264266
interface->nwk_bootstrap_state == ER_BOOTSRAP_DONE) {

0 commit comments

Comments
 (0)