3.2.4.25 R_DhcpCreateClass (Opnum 24)

The R_DhcpCreateClass method creates a user class or a vendor class definition on the DHCPv4 server.

 DWORD R_DhcpCreateClass(
   [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
   [in] DWORD ReservedMustBeZero,
   [in] LPDHCP_CLASS_INFO ClassInfo
 );

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

ReservedMustBeZero: This is of type DWORD and is reserved for future use. Currently it is not used, and any value set to this parameter will not affect the behavior of this method.

ClassInfo: This is of type DHCP_CLASS_INFO (section 2.2.1.2.75) structure, containing the information about the class.

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.

0x00004E4D

ERROR_DHCP_CLASS_ALREADY_EXISTS

The class name is already in use or the class information is already in use.

The opnum field value for this method is 24.

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

  • Validate the fields ClassName, ClassData, and ClassDataLength in the ClassInfo structure. If any one of them is NULL, or if the ClassDataLength value is not in the range 1–255, return ERROR_INVALID_PARAMETER.

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

  • Iterate through the server ADM element DHCPv4ClassDefList, and if there is a DHCPv4ClassDef entry with ClassName and IsVendor matching ClassName and IsVendor fields respectively in the ClassInfo structure, return ERROR_DHCP_CLASS_ALREADY_EXISTS.

  • Iterate through the server ADM element DHCPv4ClassDefList, and if there is a DHCPv4ClassDef entry with ClassData and ClassDataLength matching ClassData and ClassDataLength fields respectively in the ClassInfo structure, return ERROR_DHCP_CLASS_ALREADY_EXISTS.

  • Create a DHCPv4ClassDef object and insert it into the DHCPv4ClassDefList. The DHCPv4ClassDef object is initialized with the information contained in the ClassInfo field.

  • Add the new class definition in the DHCPv4 server database, and return ERROR_SUCCESS.

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