@@ -87,7 +87,7 @@ static void DHCP_server_service_timer_stop(void)
8787
8888int 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
329336void 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 */
366373int 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 */
389396int 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}
0 commit comments