3.1.4.31 R_DhcpEnumSubnetElementsV4 (Opnum 30)

The R_DhcpEnumSubnetElementsV4 method enumerates the list of a specific type of IPv4 subnet element (IPv4 reservation for DHCPv4 or BOOTP clients, IPv4 exclusion range, or IPv4 range) from a specific DHCPv4 IPv4 subnet. The caller of this function can free the memory pointed to by the EnumElementInfo parameter and its member the Elements array by calling the function midl_user_free specified in section 3.

 DWORD R_DhcpEnumSubnetElementsV4(
   [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
   [in] DHCP_IP_ADDRESS SubnetAddress,
   [in] DHCP_SUBNET_ELEMENT_TYPE EnumElementType,
   [in, out] DHCP_RESUME_HANDLE* ResumeHandle,
   [in] DWORD PreferredMaximum,
   [out] LPDHCP_SUBNET_ELEMENT_INFO_ARRAY_V4* EnumElementInfo,
   [out] DWORD* ElementsRead,
   [out] DWORD* ElementsTotal
 );

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

SubnetAddress: This is of type DHCP_IP_ADDRESS, containing the IPv4 subnet ID from which subnet elements are enumerated.

EnumElementType: This is of type DHCP_SUBNET_ELEMENT_TYPE (section 2.2.1.1.7) enumeration value, indicating the type of IPv4 subnet element to enumerate.

ResumeHandle: This is a pointer of type DHCP_RESUME_HANDLE (section 2.2.1.2.6) that identifies the enumeration operation. Initially, this value MUST be set to zero, with a successful call returning the handle value used for subsequent enumeration requests. For example, if the PreferredMaximum parameter is set to 1,000 bytes, and 2,000 bytes worth of IPv4 subnet elements are stored on the DHCPv4 server, the resume handle can be used after the first 1,000 bytes are retrieved to obtain the next 1,000 on a subsequent call, and so forth.

PreferredMaximum: This is of type DWORD, specifying the preferred maximum number of bytes to return. If the number of remaining un-enumerated subnet elements (in bytes) is less than this value, all IPv4 subnet elements for the specific type are returned. To retrieve all the IPv4 subnet elements of a specific type, 0xFFFFFFFF is specified.

EnumElementInfo: This is a pointer of type LPDHCP_SUBNET_ELEMENT_INFO_ARRAY_V4 in which an IPv4 subnet element of type EnumElementType is returned for a specific IPv4 subnet SubnetAddress. If no IPv4 subnet element of the specific type is available for enumeration, this value is null. The caller is responsible for freeing this memory.

ElementsRead: This is a pointer to a DWORD value that specifies the number of IPv4 subnet elements read in the EnumElementInfo parameter for a specific type of IPv4 subnet element. The caller MUST allocate memory for this parameter equal to the size of DWORD data type.

ElementsTotal: This is a pointer to a DWORD value that specifies the number of IPv4 subnet elements of a specific type from a specific IPv4 subnet that are not yet enumerated with respect to the resume handle that is returned. The caller MUST allocate memory for this parameter equal to the size of DWORD data type.

Return Values: A 32-bit unsigned integer value that indicates return status. A return value ERROR_SUCCESS (0x00000000) indicates that the operation was completed successfully, else 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 20099, or any generic failure.

Return value/code

Description

0x00000000

ERROR_SUCCESS

The call was successful.

0x000000EA

ERROR_MORE_DATA

There are more elements available to enumerate.

0x00000103

ERROR_NO_MORE_ITEMS

There are no more elements left to enumerate.

0x00004E25

ERROR_DHCP_SUBNET_NOT_PRESENT

The specified IPv4 subnet does not exist on the DHCP server.

0x00004E2D

ERROR_DHCP_JET_ERROR

An error occurred while accessing the DHCP server database.

The opnum field value for this method is 30.

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

  • Validate if this method is authorized for read access per section 3.5.4. If not, return the error ERROR_ACCESS_DENIED.

  • If the EnumElementType parameter is set to DhcpSecondaryHosts, return ERROR_NOT_SUPPORTED.

  • If the EnumElementType parameter is set to DhcpIpRangesDhcpOnly, DhcpIpUsedClusters, DhcpIpRangesDhcpBootp, or DhcpIpRangesBootpOnly, return ERROR_INVALID_PARAMETER.

  • Retrieve the DHCPv4Scope ADM element entry corresponding to the SubnetAddress parameter from the server ADM element DHCPv4ScopesList. If the subnet is not found, return ERROR_DHCP_SUBNET_NOT_PRESENT.

  • If the EnumElementType parameter is set to DhcpIpRanges, retrieve all the entries in DHCPv4Scope.DHCPv4IpRangesList ADM element, starting with the element at the index specified by the value in the ResumeHandle parameter and continuing while the total byte size of all retrieved IPv4 range elements is less than PreferredMaximum.

  • If the EnumElementType parameter is set to DhcpIpRanges and PreferredMaximum is 0, then ERROR_NO_MORE_ITEMS is returned.

  • If the EnumElementType parameter is set to DhcpIpRanges and the ResumeHandle parameter points to 0x00000000, the enumeration MUST start from the first entry of the DHCPv4IpRangesList ADM element.

  • If the EnumElementType parameter is set to DhcpIpRanges and the ResumeHandle parameter points to a nonzero value, the server MUST continue enumeration based on the value of ResumeHandle. If the ResumeHandle parameter is greater than or equal to the number of entries in the DHCPv4IpRangesList ADM element, then return ERROR_NO_MORE_ITEMS.

  • The PreferredMaximum parameter specifies the maximum number of bytes that the server can allocate and return to the caller containing the data related to the IPv4 ranges. If the EnumElementType parameter is set to DhcpIpRanges and the PreferredMaximum parameter is unable to hold all the entries being retrieved, then the server must store as many entries that will fit into the EnumElementInfo parameter and return ERROR_MORE_DATA.

  • If the EnumElementType parameter is set to DhcpIpRanges, copy the RangeInfo ADM element from the retrieved DHCPv4IpRange ADM element entries in the EnumElementInfo parameter, copy the number of read DHCPv4IpRanges ADM element entries in the ElementsRead parameter, and copy the number of DHCPv4IpRanges ADM element entries in the DHCPv4IpRangesList ADM element that are not yet enumerated in the ElementsTotal parameter. Update the ResumeHandle parameter to the value obtained by adding 1 to the index of the last DHCPv4IpRange ADM element entry read.

  • If the EnumElementType parameter is set to DhcpReservedIps, retrieve all the entries in DHCPv4Scope.DHCPv4ReservationsList ADM element, starting with the element at the index specified by the value in the ResumeHandle parameter and continuing while the total byte size of all retrieved IPv4 range elements is less than the PreferredMaximum parameter.

  • If the EnumElementType parameter is set to DhcpReservedIps, PreferredMaximum is 0, and the number of entries in the DHCPv4ReservationsList ADM element retrieved based on the EnumElementType parameter is greater than 0, then ERROR_MORE_DATA is returned.

  • If the EnumElementType parameter is set to DhcpReservedIps, PreferredMaximum is 0, and the number of entries in the DHCPv4ReservationsList ADM element retrieved based on EnumElementType is 0, then ERROR_NO_MORE_ITEMS is returned.

  • If the EnumElementType parameter is set to DhcpReservedIps and the ResumeHandle parameter points to 0x00000000, the enumeration MUST start from the first entry of the DHCPv4ReservationsList ADM element.

  • If the EnumElementType parameter is set to DhcpReservedIps and the ResumeHandle parameter points to a nonzero value, the server MUST continue enumeration based on the value of ResumeHandle. If the ResumeHandle parameter is greater than or equal to the number of entries in the DHCPv4ReservationsList ADM element, then return ERROR_NO_MORE_ITEMS.

  • The PreferredMaximum parameter specifies the maximum number of bytes that the server can allocate and return to the caller containing the data related to the IPv4 reservations. If the EnumElementType parameter is set to DhcpReservedIps and the PreferredMaximum parameter is unable to hold all the entries being retrieved, then the server must store as many entries that will fit into the EnumElementInfo parameter and return ERROR_MORE_DATA.

  • If the EnumElementType parameter is set to DhcpReservedIps, copy the retrieved DHCPv4Reservation ADM element entries in EnumElementInfo, copy the number of read DHCPv4Reservation ADM element entries in ElementsRead, and copy the number of DHCPv4Reservation ADM element entries in the DHCPv4ReservationsList ADM element that are not yet enumerated in ElementsTotal. Update the ResumeHandle parameter to the value obtained by adding 1 to the index of the last DHCPv4Reservation ADM element entry read.

  • If the EnumElementType parameter is set to DhcpExcludedIpRanges, retrieve all the entries in DHCPv4Scope.DHCPv4ExclusionRangesList ADM element, starting with the element at the index specified by the value in the ResumeHandle parameter and continuing while the total byte size of all retrieved IPv4 range elements is less than PreferredMaximum.

  • If the EnumElementType parameter is set to DhcpReservedIps and PreferredMaximum is 0, and the number of entries in the DHCPv4ExclusionRangesList ADM element retrieved based on the EnumElementType parameter is greater than 0, then ERROR_MORE_DATA is returned.

  • If the EnumElementType parameter is set to DhcpReservedIps and PreferredMaximum is 0, and the number of entries in the DHCPv4ExclusionRangesList ADM element retrieved based on EnumElementType is 0, then ERROR_NO_MORE_ITEMS is returned.

  • If the EnumElementType parameter is set to DhcpExcludedIpRanges and the ResumeHandle parameter points to 0x00000000, the enumeration MUST start from the first entry of the DHCPv4ExclusionRangesList ADM element.

  • If the EnumElementType parameter is set to DhcpExcludedIpRanges and the ResumeHandle parameter points to a nonzero value, the server MUST continue enumeration based on the value of ResumeHandle. If the ResumeHandle parameter is greater than or equal to the number of entries in the DHCPv4ExclusionRangesList, then return ERROR_NO_MORE_ITEMS.

  • The EnumElementType parameter is set to DhcpExcludedIpRanges, and the PreferredMaximum parameter specifies the maximum number of bytes that the server can allocate and return to the caller containing the data related to the IPv4 exclusions. If the PreferredMaximum parameter is unable to hold all the entries being retrieved, then the server must store as many entries that will fit into the EnumElementInfo parameter and return ERROR_MORE_DATA.

  • If the EnumElementType parameter is set to DhcpExcludedIpRanges, copy the retrieved DHCPv4ExclusionRange ADM element entries in the EnumElementInfo parameter, copy the number of read DHCPv4ExclusionRange ADM element entries in the ElementsRead parameter, and copy the number of DHCPv4ExclusionRange ADM element entries in the DHCPv4ExclusionRangesList ADM element that are not yet enumerated in the ElementsTotal parameter. Update the ResumeHandle parameter to the value obtained by adding 1 to the index of the last DHCPv4ExclusionRange ADM element entry read. Return ERROR_SUCCESS.

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