The R_DhcpEnumOptions method enumerates the option definition for a default user class and vendor class pair specified at the default level. The extension of this method is R_DhcpEnumOptionsV5 (section 3.2.4.18), which enumerates the option definition for the specific user class and vendor class. The caller of this function can free the memory pointed to by the Options parameter and its member the Options array by calling the function midl_user_free (section 3).
DWORD R_DhcpEnumOptions( [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress, [in, out] DHCP_RESUME_HANDLE* ResumeHandle, [in] DWORD PreferredMaximum, [out] LPDHCP_OPTION_ARRAY* Options, [out] DWORD* OptionsRead, [out] DWORD* OptionsTotal );
ServerIpAddress: The IP address/host name of the DHCP server. This parameter is unused.
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 option definitions 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 unenumerated option definitions (in bytes) is less than this value, all option definitions are returned. To retrieve all the option definitions defined for a default user class and vendor class on the DHCPv4 server, 0xFFFFFFFF is specified.
Options: This is a pointer of type LPDHCP_OPTION_ARRAY that points to the location where all the option definitions for the default user class and vendor class are retrieved from the DHCPv4 server.
OptionsRead: This is a pointer to a DWORD value that specifies the number of option definitions read in the Options parameter. The caller MUST allocate memory for this parameter equal to the size of data type DWORD.
OptionsTotal: This is a pointer to a DWORD value that specifies the number of option definitions that have not yet been enumerated. The caller MUST allocate memory for this parameter that is equal to the size of data type DWORD.
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. |
The opnum field value for this method is 23.
When processing this call, the DHCP server MUST do the following:
Validate whether this method is authorized for read access per section 3.5.4. If not, return the error ERROR_ACCESS_DENIED.
Iterate though the server Abstract Data Model (ADM) element DHCPv4OptionDefList and retrieve the DHCPv4ClassedOptDefList ADM element corresponding to the DHCPv4OptionDef ADM element entry whose UserClass and VendorClass ADM element fields are NULL.
If there are no entries in the retrieved DHCPv4ClassedOptDefList ADM element, return the error ERROR_NO_MORE_ITEMS.
If the PreferredMaximum parameter is 0 and the number of DHCPv4ClassedOptDef ADM element entries retrieved is greater than 0, then ERROR_MORE_DATA is returned.
If the PreferredMaximum parameter is 0 and the number of DHCPv4ClassedOptDef ADM element entries retrieved is 0, then ERROR_NO_MORE_ITEMS is returned.
If the PreferredMaximum parameter is 0XFFFFFFFF, then all the DHCPv4ClassedOptDef ADM element entries are retrieved. If the number of DHCPv4ClassedOptDef ADM element entries is 0, then ERROR_NO_MORE_ITEMS is returned.
If the ResumeHandle parameter points to 0x00000000, the enumeration MUST start from the first entry of the DHCPv4ClassedOptDefList ADM element.
If 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 DHCPv4ClassedOptDefList 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 option definitions. If PreferredMaximum is not 0xFFFFFFFF, allocate the memory for the number of DHCPv4ClassedOptDef ADM element entries available in the retrieved list starting from the index specified by the ResumeHandle parameter that can fit in PreferredMaximum amount of memory. Else, if the PreferredMaximum parameter is 0xFFFFFFFF, allocate the memory for all remaining DHCPv4ClassedOptDef ADM elements.
Enumerate the DHCPv4ClassedOptDef ADM element entries for the default user class and vendor class pair from the ResumeHandle parameter, and copy them in the Options parameter until as many DHCPv4ClassedOptDef ADM element entries have been copied that can be accommodated in PreferredMaximum memory, or until the end of the DHCPv4ClassedOptDefList ADM element, whichever comes first.
Copy the number of DHCPv4ClassedOptDef ADM element entries read from that list in the OptionsRead parameter, copy the number of DHCPv4ClassedOptDef ADM element entries from that list that are not yet enumerated in the OptionsTotal parameter. Update the ResumeHandle parameter to one more than the index of the last DHCPv4ClassedOptDef ADM element entry read.
If all DHCPv4ClassedOptDef ADM element entries from DHCPv4ClassedOptDefList ADM element were copied to the OptionsRead parameter, return ERROR_SUCCESS; else, if the number of DHCPv4ClassedOptDef ADM element entries copied to the OptionsRead parameter was limited by PreferredMaximum, return ERROR_MORE_DATA.
Exceptions Thrown: No exceptions are thrown beyond those thrown by the underlying RPC protocol [MS-RPCE].