@@ -52,7 +52,6 @@ static uint8_t current_instance_id = RPL_INSTANCE_ID;
52
52
53
53
#define WS_ULA_LIFETIME 24*3600
54
54
#define WS_ROUTE_LIFETIME WS_ULA_LIFETIME
55
- #define WS_DHCP_ADDRESS_LIFETIME 2*3600
56
55
#define BBR_CHECK_INTERVAL 60
57
56
#define BBR_BACKUP_ULA_DELAY 300
58
57
@@ -68,7 +67,7 @@ static uint8_t static_dodag_prefix[8] = {0xfd, 0x00, 0x72, 0x83, 0x7e};
68
67
static uint8_t static_dodag_id_prefix [8 ] = {0xfd , 0x00 , 0x61 , 0x72 , 0x6d };
69
68
static uint8_t current_dodag_id [16 ] = {0 };
70
69
static uint8_t current_local_prefix [8 ] = {0 };
71
- static uint8_t current_global_prefix [8 ] = {0 };
70
+ static uint8_t current_global_prefix [16 ] = {0 }; // DHCP requires 16 bytes prefix
72
71
static uint32_t bbr_delay_timer = BBR_CHECK_INTERVAL ; // initial delay.
73
72
static uint32_t global_prefix_unavailable_timer = 0 ; // initial delay.
74
73
@@ -137,6 +136,15 @@ void ws_bbr_rpl_config(protocol_interface_info_entry_t *cur, uint8_t imin, uint8
137
136
}
138
137
}
139
138
139
+ void ws_bbr_dhcp_address_lifetime_set (protocol_interface_info_entry_t * cur , uint32_t dhcp_address_lifetime )
140
+ {
141
+ if (!cur ) {
142
+ return ;
143
+ }
144
+ // Change the setting if the border router is active
145
+ DHCPv6_server_service_set_address_validlifetime (cur -> id , current_global_prefix , dhcp_address_lifetime );
146
+ }
147
+
140
148
static void ws_bbr_rpl_root_start (protocol_interface_info_entry_t * cur , uint8_t * dodag_id )
141
149
{
142
150
tr_info ("RPL root start" );
@@ -328,7 +336,7 @@ static bool wisun_dhcp_address_add_cb(int8_t interfaceId, dhcp_address_cache_upd
328
336
return true;
329
337
}
330
338
331
- static void ws_bbr_dhcp_server_start (protocol_interface_info_entry_t * cur , uint8_t * global_id )
339
+ static void ws_bbr_dhcp_server_start (protocol_interface_info_entry_t * cur , uint8_t * global_id , uint32_t dhcp_address_lifetime )
332
340
{
333
341
uint8_t ll [16 ];
334
342
memcpy (ll , ADDR_LINK_LOCAL_PREFIX , 8 );
@@ -344,7 +352,7 @@ static void ws_bbr_dhcp_server_start(protocol_interface_info_entry_t *cur, uint8
344
352
DHCPv6_server_service_callback_set (cur -> id , global_id , NULL , wisun_dhcp_address_add_cb );
345
353
//Enable SLAAC mode to border router
346
354
DHCPv6_server_service_set_address_autonous_flag (cur -> id , global_id , true, false);
347
- DHCPv6_server_service_set_address_validlifetime (cur -> id , global_id , WS_DHCP_ADDRESS_LIFETIME );
355
+ DHCPv6_server_service_set_address_validlifetime (cur -> id , global_id , dhcp_address_lifetime );
348
356
//SEt max value for not limiting address allocation
349
357
DHCPv6_server_service_set_max_clients_accepts_count (cur -> id , global_id , MAX_SUPPORTED_ADDRESS_LIST_SIZE );
350
358
@@ -506,7 +514,7 @@ static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
506
514
return ;
507
515
}
508
516
}
509
- ws_bbr_dhcp_server_start (cur , global_prefix );
517
+ ws_bbr_dhcp_server_start (cur , global_prefix , cur -> ws_info -> cfg -> bbr . dhcp_address_lifetime );
510
518
rpl_control_update_dodag_prefix (protocol_6lowpan_rpl_root_dodag , global_prefix , 64 , 0 , 0 , 0 , false);
511
519
// no check for failure should have
512
520
@@ -782,8 +790,8 @@ int ws_bbr_rpl_parameters_set(int8_t interface_id, uint8_t dio_interval_min, uin
782
790
#ifdef HAVE_WS_BORDER_ROUTER
783
791
protocol_interface_info_entry_t * cur = protocol_stack_interface_info_get_by_id (interface_id );
784
792
785
- ws_rpl_cfg_t cfg ;
786
- if (ws_cfg_rpl_get (& cfg , NULL ) < 0 ) {
793
+ ws_bbr_cfg_t cfg ;
794
+ if (ws_cfg_bbr_get (& cfg , NULL ) < 0 ) {
787
795
return -1 ;
788
796
}
789
797
@@ -797,7 +805,7 @@ int ws_bbr_rpl_parameters_set(int8_t interface_id, uint8_t dio_interval_min, uin
797
805
cfg .dio_redundancy_constant = dio_redundancy_constant ;
798
806
}
799
807
800
- if (ws_cfg_rpl_set (cur , NULL , & cfg , 0 ) < 0 ) {
808
+ if (ws_cfg_bbr_set (cur , NULL , & cfg , 0 ) < 0 ) {
801
809
return -2 ;
802
810
}
803
811
@@ -818,8 +826,8 @@ int ws_bbr_rpl_parameters_get(int8_t interface_id, uint8_t *dio_interval_min, ui
818
826
return -1 ;
819
827
}
820
828
821
- ws_rpl_cfg_t cfg ;
822
- if (ws_cfg_rpl_get (& cfg , NULL ) < 0 ) {
829
+ ws_bbr_cfg_t cfg ;
830
+ if (ws_cfg_bbr_get (& cfg , NULL ) < 0 ) {
823
831
return -2 ;
824
832
}
825
833
@@ -840,8 +848,8 @@ int ws_bbr_rpl_parameters_validate(int8_t interface_id, uint8_t dio_interval_min
840
848
{
841
849
(void ) interface_id ;
842
850
#ifdef HAVE_WS_BORDER_ROUTER
843
- ws_rpl_cfg_t cfg ;
844
- if (ws_cfg_rpl_get (& cfg , NULL ) < 0 ) {
851
+ ws_bbr_cfg_t cfg ;
852
+ if (ws_cfg_bbr_get (& cfg , NULL ) < 0 ) {
845
853
return -2 ;
846
854
}
847
855
@@ -855,7 +863,7 @@ int ws_bbr_rpl_parameters_validate(int8_t interface_id, uint8_t dio_interval_min
855
863
cfg .dio_redundancy_constant = dio_redundancy_constant ;
856
864
}
857
865
858
- if (ws_cfg_rpl_validate (NULL , & cfg ) < 0 ) {
866
+ if (ws_cfg_bbr_validate (NULL , & cfg ) < 0 ) {
859
867
return -3 ;
860
868
}
861
869
0 commit comments