Skip to content

Commit 1d6ce9c

Browse files
author
Juha Heiskanen
committed
DHCPv6 Server feature update
Wi-sun border router disable dhcpv6 non autonoumous mode. Added possibility for skip alloacted address storing. Optimized Allocated address entry RAM usage 14 bytes. Server will now support 16-bit address id allocaing and it 64-bit suffics is genated by adding 48-bit padding which is genertaed from server unique link ID + 16-bit allocated id. Change-Id: I958a655a96fefd14ce75315b7149d8800ca7e9f8
1 parent 46aa460 commit 1d6ce9c

File tree

8 files changed

+343
-122
lines changed

8 files changed

+343
-122
lines changed

source/6LoWPAN/Thread/thread_management_if.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ int thread_dhcpv6_server_set_anonymous_addressing(int8_t interface_id, uint8_t *
699699
return -1;
700700
}
701701

702-
return DHCPv6_server_service_set_address_autonous_flag(interface_id, prefix_ptr, anonymous);
702+
return DHCPv6_server_service_set_address_autonous_flag(interface_id, prefix_ptr, anonymous, false);
703703
#else
704704
(void) interface_id;
705705
(void) prefix_ptr;

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static void ws_bbr_dhcp_server_start(protocol_interface_info_entry_t *cur, uint8
319319
}
320320
DHCPv6_server_service_callback_set(cur->id, global_id, NULL, wisun_dhcp_address_add_cb);
321321

322-
DHCPv6_server_service_set_address_autonous_flag(cur->id, global_id, true);
322+
DHCPv6_server_service_set_address_autonous_flag(cur->id, global_id, false, false);
323323
DHCPv6_server_service_set_address_validlifetime(cur->id, global_id, WS_DHCP_ADDRESS_LIFETIME);
324324

325325
ws_dhcp_client_address_request(cur, global_id, ll);

source/DHCPv6_Server/DHCPv6_Server_service.c

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static void DHCP_server_service_timer_stop(void)
8787

8888
int DHCPv6_server_respond_client(dhcpv6_gua_server_entry_s *serverBase, dhcpv6_reply_packet_s *replyPacket, dhcp_ia_non_temporal_params_t *dhcp_ia_non_temporal_params, dhcpv6_gua_response_t *response, bool allocateNew)
8989
{
90-
dhcpv6_alloacted_address_entry_t *dhcp_allocated_address = NULL;
90+
dhcpv6_allocated_address_t *dhcp_allocated_address = NULL;
9191
dhcpv6_ia_non_temporal_address_s nonTemporalAddress;
9292
bool address_allocated = false;
9393
//Validate Client DUID
@@ -279,12 +279,15 @@ void DHCPv6_server_service_delete(int8_t interface, uint8_t guaPrefix[static 8],
279279
{
280280
dhcpv6_gua_server_entry_s *serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
281281
if (serverInfo) {
282-
ns_list_foreach_safe(dhcpv6_alloacted_address_entry_t, cur, &serverInfo->allocatedAddressList) {
282+
ns_list_foreach_safe(dhcpv6_allocated_address_entry_t, cur, &serverInfo->allocatedAddressList) {
283283
//Delete Server data base
284284
if (serverInfo->removeCb) {
285-
serverInfo->removeCb(interface, cur->nonTemporalAddress, NULL);
285+
uint8_t allocated_address[16];
286+
libdhcpv6_allocated_address_write(allocated_address, cur, serverInfo);
287+
serverInfo->removeCb(interface, allocated_address, NULL);
286288
}
287289
}
290+
288291
if (serverInfo->removeCb) {
289292
// Clean all /128 'Thread Proxy' routes to self and others added when acting as a DHCP server
290293
serverInfo->removeCb(interface, NULL, serverInfo->guaPrefix);
@@ -312,18 +315,22 @@ void DHCPv6_server_service_delete(int8_t interface, uint8_t guaPrefix[static 8],
312315
* /param guaPrefix Prefix which will be removed
313316
* /param mode true trig autonous mode, false define address by default suffics + client id
314317
*/
315-
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode)
318+
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool autonomous_skip_list)
316319
{
317-
int retVal = -1;
318-
dhcpv6_gua_server_entry_s *serverInfo;
320+
dhcpv6_gua_server_entry_s *serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
321+
if (!serverInfo) {
322+
return -1;
319323

320-
serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
321-
if (serverInfo) {
322-
serverInfo->enableAddressAutonous = mode;
323-
retVal = 0;
324324
}
325325

326-
return retVal;
326+
serverInfo->enableAddressAutonous = mode;
327+
if (mode) {
328+
serverInfo->disableAddressListAllocation = autonomous_skip_list;
329+
} else {
330+
serverInfo->disableAddressListAllocation = false;
331+
}
332+
333+
return 0;
327334
}
328335

329336
void DHCPv6_server_service_callback_set(int8_t interface, uint8_t guaPrefix[static 16], dhcp_address_prefer_remove_cb *remove_cb, dhcp_address_add_notify_cb *add_cb)
@@ -365,18 +372,18 @@ int DHCPv6_server_service_duid_update(int8_t interface, uint8_t guaPrefix[static
365372
*/
366373
int DHCPv6_server_service_set_max_clients_accepts_count(int8_t interface, uint8_t guaPrefix[static 16], uint32_t maxClientCount)
367374
{
368-
int retVal = -1;
369375
dhcpv6_gua_server_entry_s *serverInfo;
370-
if (maxClientCount == 0) {
376+
if (maxClientCount == 0 || maxClientCount > MAX_SUPPORTED_ADDRESS_LIST_SIZE) {
371377
return -2;
372-
} else {
373-
serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
374-
if (serverInfo) {
375-
serverInfo->maxSuppertedClients = maxClientCount;
376-
retVal = 0;
377-
}
378378
}
379-
return retVal;
379+
serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
380+
if (!serverInfo) {
381+
return -1;
382+
}
383+
384+
serverInfo->maxSupportedClients = maxClientCount;
385+
386+
return 0;
380387
}
381388

382389
/** SET Address Valid Lifetime parameter for allocated address, Default is 7200 seconds
@@ -388,18 +395,17 @@ int DHCPv6_server_service_set_max_clients_accepts_count(int8_t interface, uint8_
388395
*/
389396
int DHCPv6_server_service_set_address_validlifetime(int8_t interface, uint8_t guaPrefix[static 16], uint32_t validLifeTimne)
390397
{
391-
int retVal = -1;
392398
dhcpv6_gua_server_entry_s *serverInfo;
393399
if (validLifeTimne < 120) {
394-
retVal = -2;
395-
} else {
396-
serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
397-
if (serverInfo) {
398-
serverInfo->validLifetime = validLifeTimne;
399-
retVal = 0;
400-
}
400+
return -2;
401401
}
402-
return retVal;
402+
serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
403+
if (!serverInfo) {
404+
return -1;
405+
}
406+
serverInfo->validLifetime = validLifeTimne;
407+
408+
return 0;
403409
}
404410
#else
405411

@@ -422,11 +428,12 @@ void DHCPv6_server_service_timeout_cb(uint32_t timeUpdateInSeconds)
422428
{
423429
(void) timeUpdateInSeconds;
424430
}
425-
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode)
431+
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool autonomous_skip_list)
426432
{
427433
(void) interface;
428434
(void) guaPrefix;
429435
(void) mode;
436+
(void) autonomous_skip_list;
430437

431438
return -1;
432439
}

source/DHCPv6_Server/DHCPv6_server_service.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ void DHCPv6_server_service_timeout_cb(uint32_t timeUpdateInSeconds);
6666
* /param interface interface id of this thread instance.
6767
* /param guaPrefix Prefix which will be removed
6868
* /param mode true trig autonous mode, false define address by default suffics + client id
69+
* /param autonomous_skip_list true skip address list allocation when autonous mode is selected
6970
*/
70-
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode);
71+
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool autonomous_skip_list);
7172

7273

7374
/* SET max accepted clients to server, Default is 200

0 commit comments

Comments
 (0)