Skip to content

Commit ebe0dad

Browse files
author
Mika Tervonen
committed
fixed bbr for ULA prefix to real prefix change
removed instances from domain to allow new instance with same dodagid changed ULA address to be different from ULA prefix
1 parent bb42fad commit ebe0dad

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545

4646
#define RPL_INSTANCE_ID 1
4747

48+
static uint8_t current_instance_id = RPL_INSTANCE_ID;
49+
4850
#ifdef HAVE_WS_BORDER_ROUTER
4951

5052
#define WS_ULA_LIFETIME 24*3600
@@ -60,7 +62,8 @@
6062
static int8_t backbone_interface_id = -1; // BBR backbone information
6163
static uint16_t configuration = 0;
6264

63-
static uint8_t static_dodag_prefix[8] = {0xfd, 0x00, 0x61, 0x72, 0x6d};
65+
static uint8_t static_dodag_prefix[8] = {0xfd, 0x00, 0x72, 0x83, 0x7e};
66+
static uint8_t static_dodag_id_prefix[8] = {0xfd, 0x00, 0x61, 0x72, 0x6d};
6467
static uint8_t current_dodag_id[16] = {0};
6568
static uint8_t current_local_prefix[8] = {0};
6669
static uint8_t current_global_prefix[8] = {0};
@@ -120,9 +123,10 @@ static void ws_bbr_rpl_root_start(uint8_t *dodag_id)
120123
if (protocol_6lowpan_rpl_root_dodag) {
121124
rpl_control_delete_dodag_root(protocol_6lowpan_rpl_domain, protocol_6lowpan_rpl_root_dodag);
122125
protocol_6lowpan_rpl_root_dodag = NULL;
126+
current_instance_id++;
123127
}
124128

125-
protocol_6lowpan_rpl_root_dodag = rpl_control_create_dodag_root(protocol_6lowpan_rpl_domain, RPL_INSTANCE_ID, dodag_id, &rpl_conf, rpl_conf.min_hop_rank_increase, RPL_GROUNDED | RPL_MODE_NON_STORING | RPL_DODAG_PREF(0));
129+
protocol_6lowpan_rpl_root_dodag = rpl_control_create_dodag_root(protocol_6lowpan_rpl_domain, current_instance_id, dodag_id, &rpl_conf, rpl_conf.min_hop_rank_increase, RPL_GROUNDED | RPL_MODE_NON_STORING | RPL_DODAG_PREF(0));
126130
if (!protocol_6lowpan_rpl_root_dodag) {
127131
tr_err("RPL dodag init failed");
128132
return;
@@ -137,6 +141,7 @@ static void ws_bbr_rpl_root_stop(void)
137141
if (protocol_6lowpan_rpl_root_dodag) {
138142
rpl_control_delete_dodag_root(protocol_6lowpan_rpl_domain, protocol_6lowpan_rpl_root_dodag);
139143
protocol_6lowpan_rpl_root_dodag = NULL;
144+
current_instance_id++;
140145
}
141146
memset(current_local_prefix, 0, 8);
142147
memset(current_global_prefix, 0, 8);
@@ -177,14 +182,14 @@ static int ws_bbr_static_dodagid_create(protocol_interface_info_entry_t *cur)
177182
return 0;
178183
}
179184
// This address is only used if no other address available.
180-
if_address_entry_t *add_entry = icmpv6_slaac_address_add(cur, static_dodag_prefix, 64, 0xffffffff, 0xffffffff, true, SLAAC_IID_FIXED);
185+
if_address_entry_t *add_entry = icmpv6_slaac_address_add(cur, static_dodag_id_prefix, 64, 0xffffffff, 0xffffffff, true, SLAAC_IID_FIXED);
181186
if (!add_entry) {
182187
tr_err("dodagid create failed");
183188
return -1;
184189
}
185190
memcpy(current_dodag_id, add_entry->address, 16);
186191
tr_info("BBR generate DODAGID %s", trace_ipv6(current_dodag_id));
187-
addr_policy_table_add_entry(static_dodag_prefix, 64, 2, WS_NON_PREFFRED_LABEL);
192+
addr_policy_table_add_entry(static_dodag_id_prefix, 64, 2, WS_NON_PREFFRED_LABEL);
188193

189194
return 0;
190195
}
@@ -219,7 +224,7 @@ static void ws_bbr_dodag_get(uint8_t *local_prefix_ptr, uint8_t *global_prefix_p
219224
memset(global_prefix_ptr, 0, 8);
220225

221226
// By default static dodagID prefix is used as local prefix
222-
memcpy(local_prefix_ptr, current_dodag_id, 8);
227+
memcpy(local_prefix_ptr, static_dodag_prefix, 8);
223228
ws_bbr_bb_static_prefix_get(local_prefix_ptr);
224229

225230
if (arm_net_address_get(backbone_interface_id, ADDR_IPV6_GP, global_address) != 0) {
@@ -523,7 +528,7 @@ uint16_t ws_bbr_pan_size(protocol_interface_info_entry_t *cur)
523528
prefix_ptr = current_local_prefix;
524529
}
525530

526-
rpl_control_get_instance_dao_target_count(cur->rpl_domain, RPL_INSTANCE_ID, NULL, prefix_ptr, &result);
531+
rpl_control_get_instance_dao_target_count(cur->rpl_domain, current_instance_id, NULL, prefix_ptr, &result);
527532
if (result > 0) {
528533
// remove the Border router from the PAN size
529534
result--;
@@ -594,6 +599,7 @@ void ws_bbr_stop(int8_t interface_id)
594599

595600
rpl_control_delete_dodag_root(protocol_6lowpan_rpl_domain, protocol_6lowpan_rpl_root_dodag);
596601
protocol_6lowpan_rpl_root_dodag = NULL;
602+
current_instance_id++;
597603

598604
#else
599605
(void)interface_id;
@@ -606,7 +612,7 @@ int ws_bbr_configure(int8_t interface_id, uint16_t options)
606612
(void)interface_id;
607613
if (protocol_6lowpan_rpl_root_dodag &&
608614
options != configuration) {
609-
//Configuration changed delete previus setup
615+
//Configuration changed delete previous setup
610616
ws_bbr_rpl_root_stop();
611617
}
612618
configuration = options;

0 commit comments

Comments
 (0)