Skip to content

Commit

Permalink
Wi-sun BBR, bootsrap and RPL Prefix calback update
Browse files Browse the repository at this point in the history
RPL Prefix callback update indicate Prefix invalidation when Parent
address parameter is NULL.

Wi-SUN BBR not delete seprate own client RPL prefix invalidation handle
this automatically.

Wi-SUN bootsrap support new RPL Prefix invalidation for DHCPv6 client
for deprecate address and clean client.
  • Loading branch information
Juha Heiskanen committed Apr 18, 2019
1 parent 669b325 commit 14a244d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 28 deletions.
7 changes: 2 additions & 5 deletions source/6LoWPAN/ws/ws_bbr_api.c
Expand Up @@ -302,9 +302,6 @@ static void ws_bbr_dhcp_server_stop(protocol_interface_info_entry_t *cur, uint8_
tr_debug("DHCP server deactivate %s", trace_ipv6(global_id));
DHCPv6_server_service_delete(cur->id, global_id, false);

// Set old addresses to deferred and timeout
ws_dhcp_client_address_delete(cur, global_id);

}

static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
Expand Down Expand Up @@ -342,9 +339,9 @@ static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
tr_info("RPL GUA deactivate %s", trace_ipv6(global_dodag_id));

// Old backbone information is deleted after 120 seconds
rpl_control_update_dodag_route(protocol_6lowpan_rpl_root_dodag, NULL, 0, 0, 120, true);
rpl_control_update_dodag_route(protocol_6lowpan_rpl_root_dodag, NULL, 0, 0, 0, true);
rpl_control_update_dodag_prefix(protocol_6lowpan_rpl_root_dodag, global_dodag_id, 64, 0, 0, 0, true);
rpl_control_update_dodag_route(protocol_6lowpan_rpl_root_dodag, global_dodag_id, 64, 0, 120, true);
rpl_control_update_dodag_route(protocol_6lowpan_rpl_root_dodag, global_dodag_id, 64, 0, 0, true);
ipv6_route_add_with_info(global_dodag_id, 64, backbone_interface_id, NULL, ROUTE_THREAD_BBR, NULL, 0, 120, 0);

ws_bbr_dhcp_server_stop(cur, global_dodag_id);
Expand Down
32 changes: 9 additions & 23 deletions source/6LoWPAN/ws/ws_bootstrap.c
Expand Up @@ -1813,31 +1813,11 @@ static void ws_dhcp_client_global_adress_cb(int8_t interface, uint8_t dhcp_addr[
tr_debug("DHCPv6 %s status %u", trace_ipv6(dhcp_addr), register_status);
}

static bool ws_address_entry_available(uint8_t *prefixPtr, if_address_list_t *list)
{
bool addressReady = false;
ns_list_foreach(if_address_entry_t, entry, list) {
if (prefixPtr) {
if (memcmp(entry->address, prefixPtr, 8) == 0) {
addressReady = true;
break;
}
} else {
if (entry->source == ADDR_SOURCE_DHCP) {
addressReady = true;
break;
}
}
}
return addressReady;
}

void ws_dhcp_client_address_request(protocol_interface_info_entry_t *cur, uint8_t *prefix, uint8_t *parent_link_local)
{
if (!ws_address_entry_available(prefix, &cur->ip_addresses)) {
if (dhcp_client_get_global_address(cur->id, parent_link_local, prefix, cur->mac, DHCPV6_DUID_HARDWARE_IEEE_802_NETWORKS_TYPE, ws_dhcp_client_global_adress_cb) != 0) {
tr_error("DHCPp client request fail");
}
if (dhcp_client_get_global_address(cur->id, parent_link_local, prefix, cur->mac, DHCPV6_DUID_HARDWARE_IEEE_802_NETWORKS_TYPE, ws_dhcp_client_global_adress_cb) != 0) {
tr_error("DHCPp client request fail");
}
}

Expand Down Expand Up @@ -1876,7 +1856,13 @@ static void ws_rpl_prefix_callback(prefix_entry_t *prefix, void *handle, uint8_t
}
} else if (prefix->prefix_len) {
// Create new address using DHCP
ws_dhcp_client_address_request(cur, prefix->prefix, parent_link_local);
if (parent_link_local) {
ws_dhcp_client_address_request(cur, prefix->prefix, parent_link_local);
} else {
/* Deprecate address and remove client */
tr_debug("Prefix invalidation %s", trace_ipv6(prefix->prefix));
dhcp_client_global_address_delete(cur->id, NULL, prefix->prefix);
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions source/RPL/rpl_upward.c
Expand Up @@ -993,6 +993,12 @@ prefix_entry_t *rpl_dodag_update_dio_prefix(rpl_dodag_t *dodag, const uint8_t *p

void rpl_dodag_delete_dio_prefix(rpl_dodag_t *dodag, prefix_entry_t *prefix)
{
rpl_instance_t *instance = dodag->instance;

if (instance && instance->domain->prefix_cb) {
instance->domain->prefix_cb(prefix, instance->domain->cb_handle, NULL);
}

ns_list_remove(&dodag->prefixes, prefix);
ns_dyn_mem_free(prefix);
}
Expand Down

0 comments on commit 14a244d

Please sign in to comment.