Skip to content

Commit e4630a4

Browse files
author
Mika Tervonen
committed
Wi-SUN interface now informs address changes as interface events
When addressing changes in Border router Wi-SUN interface it also informs the application which can then check the available addresses and act accordingly if address is changed Allow arm_net_address_get function to return Link Local address even if the interface does not have global address available
1 parent 2174374 commit e4630a4

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -221,25 +221,22 @@ static void ws_address_reregister_trig(struct protocol_interface_info_entry *int
221221

222222
static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_entry *interface, const struct if_address_entry *addr, if_address_callback_t reason)
223223
{
224+
224225
/* No need for LL address registration */
225226
if (addr->source == ADDR_SOURCE_UNKNOWN || !interface->ws_info) {
226227
return;
227228
}
228229
if (reason == ADDR_CALLBACK_DAD_COMPLETE) {
229-
//Trig Address Registartion only when Bootstrap is ready
230+
//If address is generated manually we need to force registration
230231
if (addr->source != ADDR_SOURCE_DHCP) {
232+
//Trigger Address Registration only when Bootstrap is ready
231233
if (interface->nwk_bootstrap_state == ER_BOOTSRAP_DONE) {
232234
tr_debug("Address registration %s", trace_ipv6(addr->address));
233235
ws_address_registration_update(interface, addr->address);
234236
}
235237
ws_address_reregister_trig(interface);
236238

237239
}
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;
241-
}
242-
243240
} else if (reason == ADDR_CALLBACK_DELETED) {
244241
// What to do?
245242
// Go through address list and check if there is global address still available
@@ -251,14 +248,22 @@ static void ws_bootstrap_address_notification_cb(struct protocol_interface_info_
251248
}
252249
//Discover prefix policy
253250
addr_policy_remove_by_label(WS_NON_PREFFRED_LABEL);
251+
}
254252

255-
interface->global_address_available = false;
256-
ns_list_foreach(if_address_entry_t, addr_str, &interface->ip_addresses) {
257-
if (addr_ipv6_scope(addr_str->address, interface) > IPV6_SCOPE_LINK_LOCAL) {
258-
// at least ula address available inside mesh.
259-
interface->global_address_available = true;
260-
break;
261-
}
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;
260+
}
261+
}
262+
// Addressing in Wi-SUN interface was changed for Border router send new event so Application can update the state
263+
if (interface->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER &&
264+
interface->nwk_bootstrap_state == ER_BOOTSRAP_DONE) {
265+
if (interface->bootsrap_state_machine_cnt == 0) {
266+
interface->bootsrap_state_machine_cnt = 10; //Re trigger state check
262267
}
263268
}
264269
}
@@ -3222,11 +3227,7 @@ void ws_bootstrap_configure_process(protocol_interface_info_entry_t *cur)
32223227

32233228
if (cur->ws_info->configuration_learned) {
32243229
ws_bootstrap_network_configuration_learn(cur);
3225-
3226-
32273230
ws_bootstrap_event_operation_start(cur);
3228-
3229-
32303231
return;
32313232
}
32323233
return;

source/libNET/src/ns_net.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ int8_t arm_net_address_get(int8_t interface_id, net_address_t addr_id, uint8_t *
425425
return -1;
426426
}
427427

428-
if (!cur->global_address_available) { //Should also check Check Bootstrap state
428+
if (!cur->global_address_available && addr_id != ADDR_IPV6_LL) {
429+
//Should also check Check Bootstrap state
429430
return -1;
430431
}
431432

0 commit comments

Comments
 (0)