Skip to content

Commit

Permalink
DHCPv6 Server feature update
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Juha Heiskanen authored and Arto Kinnunen committed Feb 20, 2020
1 parent cee8502 commit c536960
Show file tree
Hide file tree
Showing 8 changed files with 343 additions and 122 deletions.
2 changes: 1 addition & 1 deletion source/6LoWPAN/Thread/thread_management_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ int thread_dhcpv6_server_set_anonymous_addressing(int8_t interface_id, uint8_t *
return -1;
}

return DHCPv6_server_service_set_address_autonous_flag(interface_id, prefix_ptr, anonymous);
return DHCPv6_server_service_set_address_autonous_flag(interface_id, prefix_ptr, anonymous, false);
#else
(void) interface_id;
(void) prefix_ptr;
Expand Down
2 changes: 1 addition & 1 deletion source/6LoWPAN/ws/ws_bbr_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static void ws_bbr_dhcp_server_start(protocol_interface_info_entry_t *cur, uint8
}
DHCPv6_server_service_callback_set(cur->id, global_id, NULL, wisun_dhcp_address_add_cb);

DHCPv6_server_service_set_address_autonous_flag(cur->id, global_id, true);
DHCPv6_server_service_set_address_autonous_flag(cur->id, global_id, false, false);
DHCPv6_server_service_set_address_validlifetime(cur->id, global_id, WS_DHCP_ADDRESS_LIFETIME);

ws_dhcp_client_address_request(cur, global_id, ll);
Expand Down
67 changes: 37 additions & 30 deletions source/DHCPv6_Server/DHCPv6_Server_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static void DHCP_server_service_timer_stop(void)

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)
{
dhcpv6_alloacted_address_entry_t *dhcp_allocated_address = NULL;
dhcpv6_allocated_address_t *dhcp_allocated_address = NULL;
dhcpv6_ia_non_temporal_address_s nonTemporalAddress;
bool address_allocated = false;
//Validate Client DUID
Expand Down Expand Up @@ -279,12 +279,15 @@ void DHCPv6_server_service_delete(int8_t interface, uint8_t guaPrefix[static 8],
{
dhcpv6_gua_server_entry_s *serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
if (serverInfo) {
ns_list_foreach_safe(dhcpv6_alloacted_address_entry_t, cur, &serverInfo->allocatedAddressList) {
ns_list_foreach_safe(dhcpv6_allocated_address_entry_t, cur, &serverInfo->allocatedAddressList) {
//Delete Server data base
if (serverInfo->removeCb) {
serverInfo->removeCb(interface, cur->nonTemporalAddress, NULL);
uint8_t allocated_address[16];
libdhcpv6_allocated_address_write(allocated_address, cur, serverInfo);
serverInfo->removeCb(interface, allocated_address, NULL);
}
}

if (serverInfo->removeCb) {
// Clean all /128 'Thread Proxy' routes to self and others added when acting as a DHCP server
serverInfo->removeCb(interface, NULL, serverInfo->guaPrefix);
Expand Down Expand Up @@ -312,18 +315,22 @@ void DHCPv6_server_service_delete(int8_t interface, uint8_t guaPrefix[static 8],
* /param guaPrefix Prefix which will be removed
* /param mode true trig autonous mode, false define address by default suffics + client id
*/
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode)
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool autonomous_skip_list)
{
int retVal = -1;
dhcpv6_gua_server_entry_s *serverInfo;
dhcpv6_gua_server_entry_s *serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
if (!serverInfo) {
return -1;

serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
if (serverInfo) {
serverInfo->enableAddressAutonous = mode;
retVal = 0;
}

return retVal;
serverInfo->enableAddressAutonous = mode;
if (mode) {
serverInfo->disableAddressListAllocation = autonomous_skip_list;
} else {
serverInfo->disableAddressListAllocation = false;
}

return 0;
}

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)
Expand Down Expand Up @@ -365,18 +372,18 @@ int DHCPv6_server_service_duid_update(int8_t interface, uint8_t guaPrefix[static
*/
int DHCPv6_server_service_set_max_clients_accepts_count(int8_t interface, uint8_t guaPrefix[static 16], uint32_t maxClientCount)
{
int retVal = -1;
dhcpv6_gua_server_entry_s *serverInfo;
if (maxClientCount == 0) {
if (maxClientCount == 0 || maxClientCount > MAX_SUPPORTED_ADDRESS_LIST_SIZE) {
return -2;
} else {
serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
if (serverInfo) {
serverInfo->maxSuppertedClients = maxClientCount;
retVal = 0;
}
}
return retVal;
serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
if (!serverInfo) {
return -1;
}

serverInfo->maxSupportedClients = maxClientCount;

return 0;
}

/** SET Address Valid Lifetime parameter for allocated address, Default is 7200 seconds
Expand All @@ -388,18 +395,17 @@ int DHCPv6_server_service_set_max_clients_accepts_count(int8_t interface, uint8_
*/
int DHCPv6_server_service_set_address_validlifetime(int8_t interface, uint8_t guaPrefix[static 16], uint32_t validLifeTimne)
{
int retVal = -1;
dhcpv6_gua_server_entry_s *serverInfo;
if (validLifeTimne < 120) {
retVal = -2;
} else {
serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
if (serverInfo) {
serverInfo->validLifetime = validLifeTimne;
retVal = 0;
}
return -2;
}
return retVal;
serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
if (!serverInfo) {
return -1;
}
serverInfo->validLifetime = validLifeTimne;

return 0;
}
#else

Expand All @@ -422,11 +428,12 @@ void DHCPv6_server_service_timeout_cb(uint32_t timeUpdateInSeconds)
{
(void) timeUpdateInSeconds;
}
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode)
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool autonomous_skip_list)
{
(void) interface;
(void) guaPrefix;
(void) mode;
(void) autonomous_skip_list;

return -1;
}
Expand Down
3 changes: 2 additions & 1 deletion source/DHCPv6_Server/DHCPv6_server_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ void DHCPv6_server_service_timeout_cb(uint32_t timeUpdateInSeconds);
* /param interface interface id of this thread instance.
* /param guaPrefix Prefix which will be removed
* /param mode true trig autonous mode, false define address by default suffics + client id
* /param autonomous_skip_list true skip address list allocation when autonous mode is selected
*/
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode);
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool autonomous_skip_list);


/* SET max accepted clients to server, Default is 200
Expand Down
Loading

0 comments on commit c536960

Please sign in to comment.