@@ -85,7 +85,27 @@ static rpl_dodag_conf_t rpl_conf = {
8585 .dio_redundancy_constant = WS_RPL_DIO_REDUNDANCY
8686};
8787
88- void ws_bbr_rpl_config (uint8_t imin , uint8_t doubling , uint8_t redundancy , uint16_t dag_max_rank_increase , uint16_t min_hop_rank_increase )
88+ static void ws_bbr_rpl_version_timer_start (protocol_interface_info_entry_t * cur , uint8_t version )
89+ {
90+ // Set the next timeout value for version update
91+ if (version < 128 ) {
92+ //stable version for RPL so slow timer update is ok
93+ cur -> ws_info -> rpl_version_timer = RPL_VERSION_LIFETIME ;
94+ } else {
95+ cur -> ws_info -> rpl_version_timer = RPL_VERSION_LIFETIME_RESTART ;
96+ }
97+ }
98+
99+ static void ws_bbr_rpl_version_increase (protocol_interface_info_entry_t * cur )
100+ {
101+ if (!protocol_6lowpan_rpl_root_dodag ) {
102+ return ;
103+ }
104+ ws_bbr_rpl_version_timer_start (cur , rpl_control_increment_dodag_version (protocol_6lowpan_rpl_root_dodag ));
105+ }
106+
107+
108+ void ws_bbr_rpl_config (protocol_interface_info_entry_t * cur , uint8_t imin , uint8_t doubling , uint8_t redundancy , uint16_t dag_max_rank_increase , uint16_t min_hop_rank_increase )
89109{
90110 if (imin == 0 || doubling == 0 ) {
91111 // use default values
@@ -111,11 +131,11 @@ void ws_bbr_rpl_config(uint8_t imin, uint8_t doubling, uint8_t redundancy, uint1
111131
112132 if (protocol_6lowpan_rpl_root_dodag ) {
113133 rpl_control_update_dodag_config (protocol_6lowpan_rpl_root_dodag , & rpl_conf );
114- rpl_control_increment_dodag_version ( protocol_6lowpan_rpl_root_dodag );
134+ ws_bbr_rpl_version_increase ( cur );
115135 }
116136}
117137
118- static void ws_bbr_rpl_root_start (uint8_t * dodag_id )
138+ static void ws_bbr_rpl_root_start (protocol_interface_info_entry_t * cur , uint8_t * dodag_id )
119139{
120140 tr_info ("RPL root start" );
121141 rpl_data_init_root ();
@@ -132,6 +152,10 @@ static void ws_bbr_rpl_root_start(uint8_t *dodag_id)
132152 }
133153 // RPL memory limits set larger for Border router
134154 rpl_control_set_memory_limits (64 * 1024 , 0 );
155+
156+ // Initial version number for RPL start is 240 from RPL RFC
157+ ws_bbr_rpl_version_timer_start (cur , 240 );
158+
135159}
136160
137161static void ws_bbr_rpl_root_stop (void )
@@ -350,7 +374,7 @@ static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
350374 if (!protocol_6lowpan_rpl_root_dodag ) {
351375 // Generate DODAGID
352376 if (ws_bbr_static_dodagid_create (cur ) == 0 ) {
353- ws_bbr_rpl_root_start (current_dodag_id );
377+ ws_bbr_rpl_root_start (cur , current_dodag_id );
354378 }
355379 }
356380
@@ -465,7 +489,8 @@ static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
465489
466490 }
467491 memcpy (current_global_prefix , global_prefix , 8 );
468- rpl_control_increment_dodag_version (protocol_6lowpan_rpl_root_dodag );
492+ ws_bbr_rpl_version_increase (cur );
493+
469494 nd_proxy_downstream_interface_register (cur -> id , ws_border_router_proxy_validate , ws_border_router_proxy_state_update );
470495 } else if (memcmp (current_global_prefix , ADDR_UNSPECIFIED , 8 ) != 0 ) {
471496 /*
@@ -526,7 +551,7 @@ void ws_bbr_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds
526551 if (cur -> ws_info -> pan_version_timer > seconds ) {
527552 cur -> ws_info -> pan_version_timer -= seconds ;
528553 } else {
529- // Border router has timed out
554+ // PAN version number update
530555 tr_debug ("Border router version number update" );
531556 cur -> ws_info -> pan_version_timer = ws_common_version_lifetime_get (cur -> ws_info -> network_size_config );
532557 cur -> ws_info -> pan_information .pan_version ++ ;
@@ -537,9 +562,13 @@ void ws_bbr_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds
537562 ws_common_network_size_configure (cur , cur -> ws_info -> pan_information .pan_size );
538563 }
539564 }
540-
565+ if (cur -> ws_info -> rpl_version_timer > seconds ) {
566+ cur -> ws_info -> rpl_version_timer -= seconds ;
567+ } else {
568+ // RPL version update needed
569+ ws_bbr_rpl_version_increase (cur );
570+ }
541571 }
542-
543572}
544573
545574uint16_t test_pan_size_override = 0xffff ;
0 commit comments