4.2 Adding an IP Range to a Scope
This example illustrates how an IP range is added to a DHCPv4 scope on the DHCP server.
The client calls the RPC method R_DhcpAddSubnetElementV5 (section 3.2.4.38) with the following parameters:
The endpoint of the DHCP server as the server IP address. This parameter is optional and can be passed as a pointer to a null Unicode string.
The IPv4 address of the scope is set as the subnet address. For example, for a subnet address 192.168.1.0, the SubnetAddress parameter is set to 0xC0A80100.
A pointer, AddElementInfo, of type LPDHCP_SUBNET_ELEMENT_DATA_V5 (section 2.2.1.2.38) to a data structure in which the member ElementType is set to the value DhcpIpRanges and the member Element is set as the union member IpRange to the value that the client wants to set as the IP range for that scope. For illustration, the StartAddress and EndAddress fields of the IpRange member are set to the IPv4 addresses 192.168.1.1 and 192.168.1.30 to add a range of 30 addresses for the subnet address 192.168.1.0.
The call to this RPC method will return either ERROR_SUCCESS or an error code between 20000 and 20099.