The R_DhcpV4GetFreeIPAddress method retrieves the list of IPv4 addresses available to be leased out to the clients. The caller of this function can free the memory pointed to by the IPAddrList parameter by calling the function midl_user_free (section 3).

 DWORD R_DhcpV4GetFreeIPAddress(
   [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
   [in] DHCP_IP_ADDRESS ScopeId,
   [in] DHCP_IP_ADDRESS startIP,
   [in] DHCP_IP_ADDRESS endIP,
   [in] DWORD numFreeAddr,
   [out] LPDHCP_IP_ARRAY *IPAddrList
 );

ServerIpAddress: The IP address of the DHCP server. This parameter is unused.

ScopeId: The IPv4 subnet ID that contains the addresses available to be leased out.

startIP: The IPv4 address at the start of the range of IPv4 addresses available to be leased out. A value of 0 indicates that the method uses the starting address of the IPv4 range of the scope specified by the ScopeId parameter.

endIP: The IPv4 address at the end of the range of IPv4 addresses available to be leased out. A value of 0 indicates that the method uses the ending address of the IPv4 range of the scope specified by the ScopeId parameter.

numFreeAddr: The number of IPv4 addresses to obtain from the specified scope. If this parameter is 0, only one IPv4 address is returned.

IpAddrList: A pointer to the location at which the list of IPv4 addresses available to be leased out will be returned.

Return Values: A 32-bit unsigned integer value that indicates return status. A return value of ERROR_SUCCESS (0x00000000) indicates that the operation was completed successfully. Otherwise, it contains a Win32 error code, as specified in [MS-ERREF]. This error code value can correspond to a DHCP-specific failure, which takes a value between 20000 and 20123, or any generic failure.

Return value/code

Description

0x00000000

ERROR_SUCCESS

The call completed successfully.

0x00000103

ERROR_FILE_NOT_FOUND

No more elements are left to enumerate.

0x00020126

ERROR_DHCP_REACHED_END_OF_SELECTION

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

The opnum field value for this method is 120.

When processing this call, the DHCP server MUST do the following:

Exceptions Thrown: No exceptions are thrown beyond those thrown by the underlying RPC protocol [MS-RPCE].