DhcpV6GetFreeIPAddress function

The DhcpV6GetFreeIPAddress function retrieves the list of available IPv6 addresses that can be leased to clients.

Syntax


DWORD DHCP_API_FUNCTION DhcpV6GetFreeIPAddress(
  _In_opt_ LPWSTR            ServerIpAddress,
  _In_     DHCP_IPV6_ADDRESS ScopeId,
  _In_     DHCP_IPV6_ADDRESS startIP,
  _In_     DHCP_IPV6_ADDRESS endIP,
  _In_     DWORD             numFreeAddrReq,
  _Out_    LPDHCPV6_IP_ARRAY *IPAddrList
);

Parameters

ServerIpAddress [in, optional]

Pointer to a null-terminated Unicode string that represents the IP address or hostname of the DHCP server.

ScopeId [in]

DHCP_IPV6_ADDRESS structure that specifies the IPv6 subnet ID from which available addresses to lease to clients are retrieved.

startIP [in]

DHCP_IPV6_ADDRESS structure that specifies the scope IPv6 range's starting point address from where the available addresses are retrieved. If this parameter is 0, the start address of the IPv6 subnet specified by ScopeId is the default.

endIP [in]

DHCP_IPV6_ADDRESS structure that specifies the scope IPv6 range's end point address from where the available addresses are retrieved. If this parameter is 0, the end address of the IPv6 subnet specified by ScopeId parameter is taken as the default.

numFreeAddrReq [in]

Integer that specifies the number of IPv6 addresses retrieved from the specified scope in IPAddrList. If this parameter is 0, only one IPv6 address is returned.

IPAddrList [out]

Pointer to a DHCPV6_IP_ARRAY structure that contains the list of available IPv6 addresses that can be leased to clients.

Return value

If the function succeeds, it returns ERROR_SUCCESS.

If the function fails, it returns one of the following or an error code from DHCP Server Management API Error Codes.

ValueMeaning
ERROR_INVALID_PARAMETER

One or more of the parameters were invalid.

ERROR_DHCP_SUBNET_NOT_PRESENT

IPv6 subnet does not exist on the DHCP server.

ERROR_DHCP_REACHED_END_OF_SELECTION

The specified DHCP server has reached the end of the selected range while finding the free IP address.

 

Remarks

IPAddrList should be free using DhcpRpcFreeMemory.

The maximum number of IPv6 addresses returned is 1024. To retrieve more that 1024 IPv6 addresses, multiple calls to DhcpV6GetFreeIPAddress must be made. After the initial call, each subsequent call to DhcpV6GetFreeIPAddress must set startIP to the last address in the list received in IPAddrList from the previous call to DhcpV6GetFreeIPAddress.

When the number of free IPv6 addresses available on the DHCP server is less than that requested, the list of free IPv6 addresses available are returned to the caller with error code ERROR_DHCP_REACHED_END_OF_SELECTION.

Requirements

Minimum supported client

None supported

Minimum supported server

Windows Server 2012 [desktop apps only]

Header

Dhcpsapi.h

Library

Dhcpsapi.lib

DLL

Dhcpsapi.dll

 

 

Show: