Skip to content

Commit 8436669

Browse files
author
Mika Tervonen
committed
Added configuration for DHCP lifetime value
Value is based on network size Changed medium size network limit to 800 like in the interface Moved the router configurations to generic settings
1 parent da732bc commit 8436669

File tree

10 files changed

+236
-184
lines changed

10 files changed

+236
-184
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ static uint8_t current_instance_id = RPL_INSTANCE_ID;
5252

5353
#define WS_ULA_LIFETIME 24*3600
5454
#define WS_ROUTE_LIFETIME WS_ULA_LIFETIME
55-
#define WS_DHCP_ADDRESS_LIFETIME 2*3600
5655
#define BBR_CHECK_INTERVAL 60
5756
#define BBR_BACKUP_ULA_DELAY 300
5857

@@ -68,7 +67,7 @@ static uint8_t static_dodag_prefix[8] = {0xfd, 0x00, 0x72, 0x83, 0x7e};
6867
static uint8_t static_dodag_id_prefix[8] = {0xfd, 0x00, 0x61, 0x72, 0x6d};
6968
static uint8_t current_dodag_id[16] = {0};
7069
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
7271
static uint32_t bbr_delay_timer = BBR_CHECK_INTERVAL; // initial delay.
7372
static uint32_t global_prefix_unavailable_timer = 0; // initial delay.
7473

@@ -137,6 +136,15 @@ void ws_bbr_rpl_config(protocol_interface_info_entry_t *cur, uint8_t imin, uint8
137136
}
138137
}
139138

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+
140148
static void ws_bbr_rpl_root_start(protocol_interface_info_entry_t *cur, uint8_t *dodag_id)
141149
{
142150
tr_info("RPL root start");
@@ -328,7 +336,7 @@ static bool wisun_dhcp_address_add_cb(int8_t interfaceId, dhcp_address_cache_upd
328336
return true;
329337
}
330338

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)
332340
{
333341
uint8_t ll[16];
334342
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
344352
DHCPv6_server_service_callback_set(cur->id, global_id, NULL, wisun_dhcp_address_add_cb);
345353
//Enable SLAAC mode to border router
346354
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);
348356
//SEt max value for not limiting address allocation
349357
DHCPv6_server_service_set_max_clients_accepts_count(cur->id, global_id, MAX_SUPPORTED_ADDRESS_LIST_SIZE);
350358

@@ -506,7 +514,7 @@ static void ws_bbr_rpl_status_check(protocol_interface_info_entry_t *cur)
506514
return;
507515
}
508516
}
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);
510518
rpl_control_update_dodag_prefix(protocol_6lowpan_rpl_root_dodag, global_prefix, 64, 0, 0, 0, false);
511519
// no check for failure should have
512520

@@ -782,8 +790,8 @@ int ws_bbr_rpl_parameters_set(int8_t interface_id, uint8_t dio_interval_min, uin
782790
#ifdef HAVE_WS_BORDER_ROUTER
783791
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
784792

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) {
787795
return -1;
788796
}
789797

@@ -797,7 +805,7 @@ int ws_bbr_rpl_parameters_set(int8_t interface_id, uint8_t dio_interval_min, uin
797805
cfg.dio_redundancy_constant = dio_redundancy_constant;
798806
}
799807

800-
if (ws_cfg_rpl_set(cur, NULL, &cfg, 0) < 0) {
808+
if (ws_cfg_bbr_set(cur, NULL, &cfg, 0) < 0) {
801809
return -2;
802810
}
803811

@@ -818,8 +826,8 @@ int ws_bbr_rpl_parameters_get(int8_t interface_id, uint8_t *dio_interval_min, ui
818826
return -1;
819827
}
820828

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) {
823831
return -2;
824832
}
825833

@@ -840,8 +848,8 @@ int ws_bbr_rpl_parameters_validate(int8_t interface_id, uint8_t dio_interval_min
840848
{
841849
(void) interface_id;
842850
#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) {
845853
return -2;
846854
}
847855

@@ -855,7 +863,7 @@ int ws_bbr_rpl_parameters_validate(int8_t interface_id, uint8_t dio_interval_min
855863
cfg.dio_redundancy_constant = dio_redundancy_constant;
856864
}
857865

858-
if (ws_cfg_rpl_validate(NULL, &cfg) < 0) {
866+
if (ws_cfg_bbr_validate(NULL, &cfg) < 0) {
859867
return -3;
860868
}
861869

source/6LoWPAN/ws/ws_bbr_api_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ uint16_t ws_bbr_pan_size(protocol_interface_info_entry_t *cur);
3131

3232
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);
3333

34+
void ws_bbr_dhcp_address_lifetime_set(protocol_interface_info_entry_t *cur, uint32_t dhcp_address_lifetime);
35+
3436
bool ws_bbr_ready_to_start(protocol_interface_info_entry_t *cur);
3537

3638

@@ -40,6 +42,7 @@ bool ws_bbr_ready_to_start(protocol_interface_info_entry_t *cur);
4042
#define ws_bbr_pan_version_increase(cur)
4143
#define ws_bbr_pan_size(cur) 0
4244
#define ws_bbr_rpl_config( cur, imin, doubling, redundancy, dag_max_rank_increase, min_hop_rank_increase)
45+
#define ws_bbr_dhcp_address_lifetime_set(cur, dhcp_address_lifetime)
4346
#define ws_bbr_ready_to_start(cur) true
4447

4548
#endif //HAVE_WS_BORDER_ROUTER

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,12 +2314,12 @@ static bool ws_rpl_candidate_soft_filtering(protocol_interface_info_entry_t *cur
23142314
}
23152315

23162316
//Already many candidates
2317-
if (rpl_control_candidate_list_size(cur, instance) > cur->ws_info->cfg->rpl.rpl_parent_candidate_max) {
2317+
if (rpl_control_candidate_list_size(cur, instance) > cur->ws_info->cfg->gen.rpl_parent_candidate_max) {
23182318
return false;
23192319
}
23202320

23212321
//Already enough selected candidates
2322-
if (rpl_control_selected_parent_count(cur, instance) >= cur->ws_info->cfg->rpl.rpl_selected_parent_max) {
2322+
if (rpl_control_selected_parent_count(cur, instance) >= cur->ws_info->cfg->gen.rpl_selected_parent_max) {
23232323
return false;
23242324
}
23252325

0 commit comments

Comments
 (0)