@@ -87,7 +87,7 @@ static void DHCP_server_service_timer_stop(void)
87
87
88
88
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 )
89
89
{
90
- dhcpv6_alloacted_address_entry_t * dhcp_allocated_address = NULL ;
90
+ dhcpv6_allocated_address_t * dhcp_allocated_address = NULL ;
91
91
dhcpv6_ia_non_temporal_address_s nonTemporalAddress ;
92
92
bool address_allocated = false;
93
93
//Validate Client DUID
@@ -279,12 +279,15 @@ void DHCPv6_server_service_delete(int8_t interface, uint8_t guaPrefix[static 8],
279
279
{
280
280
dhcpv6_gua_server_entry_s * serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid (interface , guaPrefix );
281
281
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 ) {
283
283
//Delete Server data base
284
284
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 );
286
288
}
287
289
}
290
+
288
291
if (serverInfo -> removeCb ) {
289
292
// Clean all /128 'Thread Proxy' routes to self and others added when acting as a DHCP server
290
293
serverInfo -> removeCb (interface , NULL , serverInfo -> guaPrefix );
@@ -312,18 +315,22 @@ void DHCPv6_server_service_delete(int8_t interface, uint8_t guaPrefix[static 8],
312
315
* /param guaPrefix Prefix which will be removed
313
316
* /param mode true trig autonous mode, false define address by default suffics + client id
314
317
*/
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 )
316
319
{
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 ;
319
323
320
- serverInfo = libdhcpv6_server_data_get_by_prefix_and_interfaceid (interface , guaPrefix );
321
- if (serverInfo ) {
322
- serverInfo -> enableAddressAutonous = mode ;
323
- retVal = 0 ;
324
324
}
325
325
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 ;
327
334
}
328
335
329
336
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
365
372
*/
366
373
int DHCPv6_server_service_set_max_clients_accepts_count (int8_t interface , uint8_t guaPrefix [static 16 ], uint32_t maxClientCount )
367
374
{
368
- int retVal = -1 ;
369
375
dhcpv6_gua_server_entry_s * serverInfo ;
370
- if (maxClientCount == 0 ) {
376
+ if (maxClientCount == 0 || maxClientCount > MAX_SUPPORTED_ADDRESS_LIST_SIZE ) {
371
377
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
- }
378
378
}
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 ;
380
387
}
381
388
382
389
/** 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_
388
395
*/
389
396
int DHCPv6_server_service_set_address_validlifetime (int8_t interface , uint8_t guaPrefix [static 16 ], uint32_t validLifeTimne )
390
397
{
391
- int retVal = -1 ;
392
398
dhcpv6_gua_server_entry_s * serverInfo ;
393
399
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 ;
401
401
}
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 ;
403
409
}
404
410
#else
405
411
@@ -422,11 +428,12 @@ void DHCPv6_server_service_timeout_cb(uint32_t timeUpdateInSeconds)
422
428
{
423
429
(void ) timeUpdateInSeconds ;
424
430
}
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 )
426
432
{
427
433
(void ) interface ;
428
434
(void ) guaPrefix ;
429
435
(void ) mode ;
436
+ (void ) autonomous_skip_list ;
430
437
431
438
return -1 ;
432
439
}
0 commit comments