Skip to content

Commit dd39963

Browse files
Mika TervonenMika Tervonen
authored andcommitted
Wi-SUN Border router uses Static address as DODAGID
If border router is configured with static backbone prefix address generated for that prefix is used as RPL DODAGID
1 parent 7a3c833 commit dd39963

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -366,30 +366,11 @@ static void ws_bbr_slaac_remove(protocol_interface_info_entry_t *cur, uint8_t *u
366366
addr_policy_table_delete_entry(ula_prefix, 64);
367367
}
368368

369-
370-
static int ws_bbr_static_dodagid_create(protocol_interface_info_entry_t *cur)
371-
{
372-
if (memcmp(current_dodag_id, ADDR_UNSPECIFIED, 16) != 0) {
373-
// address generated
374-
return 0;
375-
}
376-
// This address is only used if no other address available.
377-
if_address_entry_t *add_entry = ws_bbr_slaac_generate(cur, static_dodag_id_prefix);
378-
if (!add_entry) {
379-
tr_err("dodagid create failed");
380-
return -1;
381-
}
382-
memcpy(current_dodag_id, add_entry->address, 16);
383-
tr_info("BBR generate DODAGID %s", trace_ipv6(current_dodag_id));
384-
385-
return 0;
386-
}
387-
388369
/*
389370
* 0 static non rooted self generated own address
390371
* 1 static address with backbone connectivity
391372
*/
392-
static void ws_bbr_bb_static_prefix_get(uint8_t *dodag_id_ptr)
373+
static uint8_t *ws_bbr_bb_static_prefix_get(uint8_t *dodag_id_ptr)
393374
{
394375

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

402383
if (bb_interface && bb_interface->ipv6_configure->ipv6_stack_mode == NET_IPV6_BOOTSTRAP_STATIC) {
403-
if (protocol_address_prefix_cmp(bb_interface, bb_interface->ipv6_configure->static_prefix64, 64)) {
404-
memcpy(dodag_id_ptr, bb_interface->ipv6_configure->static_prefix64, 8);
384+
ns_list_foreach(if_address_entry_t, addr, &bb_interface->ip_addresses) {
385+
if (bitsequal(addr->address, bb_interface->ipv6_configure->static_prefix64, 64)) {
386+
// static address available in interface copy the prefix and return the address
387+
if (dodag_id_ptr) {
388+
memcpy(dodag_id_ptr, bb_interface->ipv6_configure->static_prefix64, 8);
389+
}
390+
return addr->address;
391+
}
405392
}
406393
}
407-
return;
394+
return NULL;
408395
}
409396

410397

398+
static int ws_bbr_static_dodagid_create(protocol_interface_info_entry_t *cur)
399+
{
400+
if (memcmp(current_dodag_id, ADDR_UNSPECIFIED, 16) != 0) {
401+
// address generated
402+
return 0;
403+
}
404+
405+
uint8_t *static_address_ptr = ws_bbr_bb_static_prefix_get(NULL);
406+
if (static_address_ptr) {
407+
memcpy(current_dodag_id, static_address_ptr, 16);
408+
tr_info("BBR Static DODAGID %s", trace_ipv6(current_dodag_id));
409+
return 0;
410+
}
411+
412+
// This address is only used if no other address available.
413+
if_address_entry_t *add_entry = ws_bbr_slaac_generate(cur, static_dodag_id_prefix);
414+
if (!add_entry) {
415+
tr_err("dodagid create failed");
416+
return -1;
417+
}
418+
memcpy(current_dodag_id, add_entry->address, 16);
419+
tr_info("BBR generate DODAGID %s", trace_ipv6(current_dodag_id));
420+
421+
return 0;
422+
}
423+
411424
static void ws_bbr_dodag_get(uint8_t *local_prefix_ptr, uint8_t *global_prefix_ptr)
412425
{
413426
uint8_t global_address[16];

0 commit comments

Comments
 (0)