Skip to content

Commit

Permalink
Wi-SUN Border router uses Static address as DODAGID
Browse files Browse the repository at this point in the history
If border router is configured with static backbone prefix
address generated for that prefix is used as RPL DODAGID
  • Loading branch information
Mika Tervonen authored and Mika Tervonen committed Feb 18, 2021
1 parent 7a3c833 commit dd39963
Showing 1 changed file with 36 additions and 23 deletions.
59 changes: 36 additions & 23 deletions source/6LoWPAN/ws/ws_bbr_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,30 +366,11 @@ static void ws_bbr_slaac_remove(protocol_interface_info_entry_t *cur, uint8_t *u
addr_policy_table_delete_entry(ula_prefix, 64);
}


static int ws_bbr_static_dodagid_create(protocol_interface_info_entry_t *cur)
{
if (memcmp(current_dodag_id, ADDR_UNSPECIFIED, 16) != 0) {
// address generated
return 0;
}
// This address is only used if no other address available.
if_address_entry_t *add_entry = ws_bbr_slaac_generate(cur, static_dodag_id_prefix);
if (!add_entry) {
tr_err("dodagid create failed");
return -1;
}
memcpy(current_dodag_id, add_entry->address, 16);
tr_info("BBR generate DODAGID %s", trace_ipv6(current_dodag_id));

return 0;
}

/*
* 0 static non rooted self generated own address
* 1 static address with backbone connectivity
*/
static void ws_bbr_bb_static_prefix_get(uint8_t *dodag_id_ptr)
static uint8_t *ws_bbr_bb_static_prefix_get(uint8_t *dodag_id_ptr)
{

/* Get static ULA prefix if we have configuration in backbone and there is address we use that.
Expand All @@ -400,14 +381,46 @@ static void ws_bbr_bb_static_prefix_get(uint8_t *dodag_id_ptr)
protocol_interface_info_entry_t *bb_interface = protocol_stack_interface_info_get_by_id(backbone_interface_id);

if (bb_interface && bb_interface->ipv6_configure->ipv6_stack_mode == NET_IPV6_BOOTSTRAP_STATIC) {
if (protocol_address_prefix_cmp(bb_interface, bb_interface->ipv6_configure->static_prefix64, 64)) {
memcpy(dodag_id_ptr, bb_interface->ipv6_configure->static_prefix64, 8);
ns_list_foreach(if_address_entry_t, addr, &bb_interface->ip_addresses) {
if (bitsequal(addr->address, bb_interface->ipv6_configure->static_prefix64, 64)) {
// static address available in interface copy the prefix and return the address
if (dodag_id_ptr) {
memcpy(dodag_id_ptr, bb_interface->ipv6_configure->static_prefix64, 8);
}
return addr->address;
}
}
}
return;
return NULL;
}


static int ws_bbr_static_dodagid_create(protocol_interface_info_entry_t *cur)
{
if (memcmp(current_dodag_id, ADDR_UNSPECIFIED, 16) != 0) {
// address generated
return 0;
}

uint8_t *static_address_ptr = ws_bbr_bb_static_prefix_get(NULL);
if (static_address_ptr) {
memcpy(current_dodag_id, static_address_ptr, 16);
tr_info("BBR Static DODAGID %s", trace_ipv6(current_dodag_id));
return 0;
}

// This address is only used if no other address available.
if_address_entry_t *add_entry = ws_bbr_slaac_generate(cur, static_dodag_id_prefix);
if (!add_entry) {
tr_err("dodagid create failed");
return -1;
}
memcpy(current_dodag_id, add_entry->address, 16);
tr_info("BBR generate DODAGID %s", trace_ipv6(current_dodag_id));

return 0;
}

static void ws_bbr_dodag_get(uint8_t *local_prefix_ptr, uint8_t *global_prefix_ptr)
{
uint8_t global_address[16];
Expand Down

0 comments on commit dd39963

Please sign in to comment.