4141
4242#ifdef HAVE_WS
4343
44+ static uint8_t static_dodag_prefix [8 ] = {0xfd ,0x00 ,0x61 , 0x72 , 0x6d };
45+ static uint8_t static_dodag_id [16 ] = {0 };
46+
4447static void ws_bbr_rpl_root_activate (uint8_t * dodag_prefix , uint8_t * dodag_id )
4548{
4649 tr_debug ("RPL root Activate" );
@@ -61,10 +64,18 @@ static void ws_bbr_rpl_root_activate(uint8_t *dodag_prefix, uint8_t *dodag_id)
6164 };
6265
6366 rpl_data_init_root ();
67+
68+ if (protocol_6lowpan_rpl_root_dodag ) {
69+ rpl_control_delete_dodag_root (protocol_6lowpan_rpl_domain , protocol_6lowpan_rpl_root_dodag );
70+ protocol_6lowpan_rpl_root_dodag = NULL ;
71+ }
72+
6473 protocol_6lowpan_rpl_root_dodag = rpl_control_create_dodag_root (protocol_6lowpan_rpl_domain , RPL_INSTANCE_ID , dodag_id , & new_conf , new_conf .min_hop_rank_increase , RPL_GROUNDED | RPL_MODE_NON_STORING | RPL_DODAG_PREF (0 ));
6574 if (!protocol_6lowpan_rpl_root_dodag ) {
6675 tr_err ("RPL dodag init failed" );
76+ return ;
6777 }
78+ memcpy (static_dodag_id ,dodag_id ,16 );
6879
6980 // RPL memory limits set larger for Border router
7081 rpl_control_set_memory_limits (64 * 1024 , 0 );
@@ -76,8 +87,6 @@ static void ws_bbr_rpl_root_activate(uint8_t *dodag_prefix, uint8_t *dodag_id)
7687 rpl_control_update_dodag_route (protocol_6lowpan_rpl_root_dodag , NULL , 0 , 0 , 0xffffffff , false);
7788}
7889
79- static uint8_t static_dodag_prefix [8 ] = {0xfd ,0x00 ,0x61 , 0x72 , 0x6d };
80-
8190static void ws_bbr_root_start (protocol_interface_info_entry_t * cur )
8291{
8392 uint8_t * bbr_prefix_ptr = NULL ;
@@ -119,6 +128,15 @@ void ws_bbr_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds
119128 return ;
120129 }
121130
131+ if (protocol_6lowpan_rpl_root_dodag ){
132+ // Border router is active
133+ if (0 != protocol_interface_address_compare (static_dodag_id )) {
134+ // Dodag has become invalid need to delete
135+ tr_info ("RPL dodag not valid anymore" );
136+ rpl_control_delete_dodag_root (protocol_6lowpan_rpl_domain , protocol_6lowpan_rpl_root_dodag );
137+ protocol_6lowpan_rpl_root_dodag = NULL ;
138+ }
139+ }
122140 if (!protocol_6lowpan_rpl_root_dodag ) {
123141 // RPL configured
124142 // 1. Wait for backend connection
0 commit comments