@@ -366,30 +366,11 @@ static void ws_bbr_slaac_remove(protocol_interface_info_entry_t *cur, uint8_t *u
366
366
addr_policy_table_delete_entry (ula_prefix , 64 );
367
367
}
368
368
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
-
388
369
/*
389
370
* 0 static non rooted self generated own address
390
371
* 1 static address with backbone connectivity
391
372
*/
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 )
393
374
{
394
375
395
376
/* 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)
400
381
protocol_interface_info_entry_t * bb_interface = protocol_stack_interface_info_get_by_id (backbone_interface_id );
401
382
402
383
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
+ }
405
392
}
406
393
}
407
- return ;
394
+ return NULL ;
408
395
}
409
396
410
397
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
+
411
424
static void ws_bbr_dodag_get (uint8_t * local_prefix_ptr , uint8_t * global_prefix_ptr )
412
425
{
413
426
uint8_t global_address [16 ];
0 commit comments