Skip to content

Commit b57d9bc

Browse files
author
Mika Tervonen
authored
Add support for anonymous addressing in Wi-SUN border router (ARMmbed#2565)
DHCPv6 server can now assign addresses anonymously. Added support for New API to allow Anonymous addressing in border router Simplified the DHCPv6 server to assign Ids in sequence Simplified DHCPv6 library to use only one structure for address Fixed parameter names Fixed function names Added correct comments to function descriptions
1 parent 7400c8b commit b57d9bc

File tree

9 files changed

+202
-295
lines changed

9 files changed

+202
-295
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Release vXX.X.X
66

77
### Features
8-
*
8+
* Added support for Anonymous address generation in DHCPv6 server for Wi-SUN Border router
99

1010
### Changes
1111
* Added throttling of number of simultaneous EAPOL authentications based on Border Router TX queue size

nanostack/ws_bbr_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ int ws_bbr_start(int8_t interface_id, int8_t backbone_interface_id);
9999
#define BBR_REQUIRE_DAO_REFRESH 0x0000 /**< Deprecated DAO Refresh is now the default functionality*/
100100
#define BBR_PERIODIC_VERSION_INC 0x0010 /**< Increment PAN version number Periodically*/
101101
#define BBR_GUA_SLAAC 0x0020 /**< in Global prefix use SLAAC address generation to reduce traffic during bootstrap */
102+
#define BBR_DHCP_ANONYMOUS 0x0040 /**< Generate anonymous addresses from DHCP server */
102103

103104
/**
104105
* Configure border router features.
@@ -108,6 +109,9 @@ int ws_bbr_start(int8_t interface_id, int8_t backbone_interface_id);
108109
* BBR_ULA_C Configure Mesh local ULA prefix with SLAAC address
109110
* BBR_GUA_ROUTE Add more specific route for GUA
110111
* BBR_BB_WAIT Start Wi-SUN network only when backbone is ready
112+
* BBR_DHCP_ANONYMOUS if true give anonymous address (16 bit suffix) to
113+
* optimize data in RF interface (saves 12 bytes per hop)
114+
* or false to reduce RAM usage in Border router as assigned address list is not needed (40 bytes per device).
111115
*
112116
* By default Wi-SUN network is started and is treated as separate interface even if backbone is not available.
113117
*

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, false);
702+
return DHCPv6_server_service_set_address_generation_anonymous(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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,10 @@ static void ws_bbr_dhcp_server_start(protocol_interface_info_entry_t *cur, uint8
523523
return;
524524
}
525525
DHCPv6_server_service_callback_set(cur->id, global_id, NULL, wisun_dhcp_address_add_cb);
526-
//Enable SLAAC mode to border router
527-
DHCPv6_server_service_set_address_autonous_flag(cur->id, global_id, true, false);
526+
//Check for anonymous mode
527+
bool anonymous = (configuration & BBR_DHCP_ANONYMOUS) ? true : false;
528+
529+
DHCPv6_server_service_set_address_generation_anonymous(cur->id, global_id, anonymous, false);
528530
DHCPv6_server_service_set_address_validlifetime(cur->id, global_id, dhcp_address_lifetime);
529531
//SEt max value for not limiting address allocation
530532
DHCPv6_server_service_set_max_clients_accepts_count(cur->id, global_id, MAX_SUPPORTED_ADDRESS_LIST_SIZE);
@@ -533,6 +535,7 @@ static void ws_bbr_dhcp_server_start(protocol_interface_info_entry_t *cur, uint8
533535

534536
ws_dhcp_client_address_request(cur, global_id, ll);
535537
}
538+
536539
static void ws_bbr_dhcp_server_stop(protocol_interface_info_entry_t *cur, uint8_t *global_id)
537540
{
538541
if (!cur) {

source/DHCPv6_Server/DHCPv6_Server_service.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ int DHCPv6_server_respond_client(dhcpv6_gua_server_entry_s *serverBase, dhcpv6_r
9393
//Validate Client DUID
9494
dhcp_link_options_params_t clientDUID;
9595
if (libdhcpv6_get_link_address_from_duid(replyPacket->clientDUID.duid, replyPacket->clientDUID.duid_length, replyPacket->clientDUID.type, &clientDUID) == 0) {
96-
dhcp_allocated_address = libdhcpv6_address_allocated_list_scan(serverBase, clientDUID.link_id, clientDUID.link_type, dhcp_ia_non_temporal_params->iaId, dhcp_ia_non_temporal_params->T0, dhcp_ia_non_temporal_params->T1, allocateNew);
96+
dhcp_allocated_address = libdhcpv6_address_allocate(serverBase, clientDUID.link_id, clientDUID.link_type, dhcp_ia_non_temporal_params->iaId, dhcp_ia_non_temporal_params->T0, dhcp_ia_non_temporal_params->T1, allocateNew);
9797
}
9898
if (dhcp_allocated_address) {
9999
address_allocated = true;
@@ -109,7 +109,7 @@ int DHCPv6_server_respond_client(dhcpv6_gua_server_entry_s *serverBase, dhcpv6_r
109109

110110
if (!serverBase->addCb(serverBase->interfaceId, &update_info, serverBase->guaPrefix)) {
111111
address_allocated = false;
112-
libdhcpv6_address_rm_from_allocated_list(serverBase, dhcp_allocated_address->nonTemporalAddress);
112+
libdhcpv6_address_delete(serverBase, dhcp_allocated_address->nonTemporalAddress);
113113
}
114114
}
115115
}
@@ -299,9 +299,9 @@ void DHCPv6_server_service_delete(int8_t interface, uint8_t guaPrefix[static 8],
299299
ns_list_foreach_safe(dhcpv6_allocated_address_entry_t, cur, &serverInfo->allocatedAddressList) {
300300
//Delete Server data base
301301
if (serverInfo->removeCb) {
302-
uint8_t allocated_address[16];
303-
libdhcpv6_allocated_address_write(allocated_address, cur, serverInfo);
304-
serverInfo->removeCb(interface, allocated_address, NULL);
302+
uint8_t ipAddress[16];
303+
libdhcpv6_allocated_address_write(ipAddress, cur, serverInfo);
304+
serverInfo->removeCb(interface, ipAddress, NULL);
305305
}
306306
}
307307

@@ -327,25 +327,33 @@ void DHCPv6_server_service_delete(int8_t interface, uint8_t guaPrefix[static 8],
327327

328328
/* Control GUA address for client by DUI.Default value is true
329329
*
330+
* Anonymous and disable address list can optimize either
331+
* Using 16 bit suffix to optimize data amount in network
332+
* and having list of assigned addresses meaning larger RAM usage at border router
333+
*
334+
* or Using SLAAC type address generation and not have a list of addresses at Border router
335+
* -> Less RAM usage, but more bandwidth used
330336
*
331337
* /param interface interface id of this thread instance.
332338
* /param guaPrefix Prefix which will be removed
333-
* /param mode true trig autonous mode, false define address by default suffics + client id
339+
* /param mode true assign addresses anonymously. false define address by Prefix + client id
340+
* /param disable_address_list Dont keep track of assigned Addresses (Can't be used if anonymous)
334341
*/
335-
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool autonomous_skip_list)
342+
int DHCPv6_server_service_set_address_generation_anonymous(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool disable_address_list)
336343
{
337344
dhcpv6_gua_server_entry_s *serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid(interface, guaPrefix);
338345
if (!serverInfo) {
339346
return -1;
340347

341348
}
342349

343-
serverInfo->enableAddressAutonous = mode;
350+
serverInfo->anonymousAddress = mode;
344351
if (mode) {
345-
serverInfo->disableAddressListAllocation = autonomous_skip_list;
352+
serverInfo->disableAddressList = disable_address_list;
346353
} else {
347-
serverInfo->disableAddressListAllocation = false;
354+
serverInfo->disableAddressList = false;
348355
}
356+
tr_info("DHCPv6 %s, address list %s", mode ? "anonymous address" : "address mode SLAAC", disable_address_list ? "Not Stored" : "Stored");
349357

350358
return 0;
351359
}
@@ -375,6 +383,7 @@ int DHCPv6_server_service_duid_update(int8_t interface, uint8_t guaPrefix[static
375383
if (!serverInfo) {
376384
return -1;
377385
}
386+
tr_info("DHCPv6 duid %s", trace_array(duid_ptr, duid_length));
378387

379388
return libdhcpv6_server_duid_set(serverInfo, duid_ptr, duid_type, duid_length);
380389
}
@@ -399,6 +408,7 @@ int DHCPv6_server_service_set_max_clients_accepts_count(int8_t interface, uint8_
399408
}
400409

401410
serverInfo->maxSupportedClients = maxClientCount;
411+
tr_info("DHCPv6 maximum clients %"PRIu32, serverInfo->maxSupportedClients);
402412

403413
return 0;
404414
}
@@ -421,6 +431,7 @@ int DHCPv6_server_service_set_address_validlifetime(int8_t interface, uint8_t gu
421431
return -1;
422432
}
423433
serverInfo->validLifetime = validLifeTimne;
434+
tr_info("DHCPv6 Valid lifetime %"PRIu32, serverInfo->validLifetime);
424435

425436
return 0;
426437
}
@@ -510,7 +521,7 @@ void DHCPv6_server_service_timeout_cb(uint32_t timeUpdateInSeconds)
510521
{
511522
(void) timeUpdateInSeconds;
512523
}
513-
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool autonomous_skip_list)
524+
int DHCPv6_server_service_set_address_generation_anonymous(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool autonomous_skip_list)
514525
{
515526
(void) interface;
516527
(void) guaPrefix;

source/DHCPv6_Server/DHCPv6_server_service.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,19 @@ void DHCPv6_server_service_timeout_cb(uint32_t timeUpdateInSeconds);
6262

6363
/* Control GUA address for client by DUI.Default value is true
6464
*
65+
* Anonymous and disable address list can optimize either
66+
* Using 16 bit suffix to optimize data amount in network
67+
* and having list of assigned addresses meaning larger RAM usage at border router
68+
*
69+
* or Using SLAAC type address generation and not have a list of addresses at Border router
70+
* -> Less RAM usage, but more bandwidth used
6571
*
6672
* /param interface interface id of this thread instance.
6773
* /param guaPrefix Prefix which will be removed
68-
* /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
74+
* /param mode true assign addresses anonymously. false define address by Prefix + client id
75+
* /param disable_address_list Dont keep track of assigned Addresses (Can't be used if anonymous)
7076
*/
71-
int DHCPv6_server_service_set_address_autonous_flag(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool autonomous_skip_list);
77+
int DHCPv6_server_service_set_address_generation_anonymous(int8_t interface, uint8_t guaPrefix[static 16], bool mode, bool autonomous_skip_list);
7278

7379

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

0 commit comments

Comments
 (0)