<div class="content" name="R_DhcpCreateSubnetVQ" uuid="e8cdbe00-e7be-457b-866e-b3b7311ad0e5"><p>The <b>R_DhcpCreateSubnetVQ</b> method is used to create the
new IPv4 subnet along with its <a href="a9d6a415-4de6-4058-befe-ca2e42764485#gt_f30fdc41-d7c1-422e-b5a8-9dcce071ebeb" data-linktype="relative-path">NAP</a> state on the DHCPv4
server. This method is an extension of <a href="8b3c3d99-490d-4a16-a9c1-0ed0349f37b0" data-linktype="relative-path">R_DhcpCreateSubnet (section 3.1.4.1)</a>.</p><dl>
<dd>
<div><pre> DWORD R_DhcpCreateSubnetVQ(
   [in, unique, string] DHCP_SRV_HANDLE ServerIpAddress,
   [in] DHCP_IP_ADDRESS SubnetAddress,
   [in, ref] LPDHCP_SUBNET_INFO_VQ SubnetInfoVQ
 );
</pre></div>
</dd></dl><p><b>ServerIpAddress: </b>The IP address/host name of
the DHCP server. This parameter is unused.</p><p><b>SubnetAddress: </b>This is of type <a href="5122557b-b85d-4982-8ffb-98d8d934e353" data-linktype="relative-path">DHCP_IP_ADDRESS (section 2.2.1.2.1)</a>,
containing the IPv4 address of the subnet.</p><p><b>SubnetInfoVQ: </b>This is a pointer to a structure
of type <a href="baec452a-0eda-44d4-b2d7-acd86950b2a6" data-linktype="relative-path">DHCP_SUBNET_INFO_VQ (section 2.2.1.2.45)</a>
that contains information about the IPv4 subnet, including the IPv4 subnet mask
and the IPv4 address of the subnet. The structure <a href="51e16f4a-cb1d-400a-85c7-defe4cba1609" data-linktype="relative-path">DHCP_HOST_INFO (section 2.2.1.2.7)</a>
(referred by the <b>PrimaryHost</b> member) stored in the <i>SubnetInfoVQ</i>
parameter MUST be ignored by both the caller and the server.</p><p><b>Return Values: </b>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 <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>.
This error code value can correspond to a DHCP-specific failure, which takes a
value between 20000 and 20099, or any generic failure.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000000 ERROR_SUCCESS</td>
  <td>The call was successful.</td>
 </tr><tr>
  <td>0x00004E2D ERROR_DHCP_JET_ERROR</td>
  <td>An error occurred while accessing the DHCP server database.</td>
 </tr><tr>
  <td>0x00004E54 ERROR_DHCP_SUBNET_EXISTS</td>
  <td>The IPv4 scope parameters are incorrect. Either the IPv4 scope already exists, corresponding to the SubnetAddress and SubnetMask members of the DHCP_SUBNET_INFO_VQ (section 2.2.1.2.45) structure, or there is a range overlap of IPv4 addresses between those associated with the SubnetAddress and SubnetMask members of the new IPv4 scope and the subnet address and mask of an already existing IPv4 scope.</td>
 </tr></tbody></table>
</dd></dl><p>The opnum field value for this method is 48.</p><p>When processing this call, the DHCP server MUST do the
following:</p><ul><li><p><span><span> 
</span></span>Validate if this method is authorized for read/write access per
section <a href="38840bd0-0a5a-47ed-bc69-0dd870d33aec" data-linktype="relative-path">3.5.5</a>. If not,
return the error ERROR_ACCESS_DENIED.</p>
</li><li><p><span><span> 
</span></span>If the <i>SubnetAddress</i> input parameter is 0, return
ERROR_INVALID_PARAMETER.</p>
</li><li><p><span><span> 
</span></span>If the <i>SubnetInfoVQ</i> input parameter is NULL, return
ERROR_INVALID_PARAMETER.</p>
</li><li><p><span><span> 
</span></span>If the <i>SubnetAddress</i> input parameter is not the same as
the <b>SubnetAddress</b> member of the <i>SubnetInfoVQ</i> input parameter,
return ERROR_INVALID_PARAMETER.</p>
</li><li><p><span><span> 
</span></span>If the bitwise AND operation of the <i>SubnetAddress</i> input
parameter with the <b>SubnetMask</b> member of the <i>SubnetInfoVQ</i> input
parameter is not the same as the <i>SubnetAddress</i> input parameter, return
ERROR_INVALID_PARAMETER.</p>
</li><li><p><span><span> 
</span></span>Iterate through the server ADM element <b>DHCPv4ScopesList</b>
and validate that the range of IPv4 addresses, that correspond to the <b>SubnetAddress</b>
and <b>SubnetMask</b> members of the <i>SubnetInfoVQ</i> parameter, does not
overlap the range of IPv4 addresses that correspond to the subnet address and
mask of any <b>DHCPv4Scope</b> ADM element entry present in <b>DHCPv4ScopesList</b>
ADM element. If an overlap is detected, return ERROR_DHCP_SUBNET_EXISTS.</p>
</li><li><p><span><span> 
</span></span>Create a <b>DHCPv4Scope</b> ADM element object and insert it into
the <b>DHCPv4ScopesList</b> ADM element. The <b>DHCPv4Scope</b> ADM element
object is initialized as follows:</p>
<ul><li><p><span><span>  </span></span>The
<b>DHCPv4Scope.ScopeInfo</b> ADM element is initialized with the information
contained in the <i>SubnetInfoVQ</i> parameter. The <b>QuarantineOn</b> member
of the <b>DHCPv4Scope.ScopeInfo</b> ADM element is set to 0.</p>
</li><li><p><span><span>  </span></span>The
<b>DHCPv4Scope.DelayOffer</b> ADM element is set to 0.</p>
</li><li><p><span><span>  </span></span>The
<b>DHCPv4Scope.SuperScopeId</b> ADM element is set to 0.</p>
</li><li><p><span><span>  </span></span>The
<b>DHCPv4Scope.DHCPv4IpRangesList</b> ADM element is set to empty list.</p>
</li><li><p><span><span>  </span></span>The
<b>DHCPv4Scope.DHCPv4ExclusionRangesList</b> ADM element is set to empty list.</p>
</li><li><p><span><span>  </span></span>The
<b>DHCPv4Scope.DHCPv4ReservationsList</b> ADM element is set to empty list.</p>
</li><li><p><span><span>  </span></span>The
<b>DHCPv4Scope.DHCPv4ClientsList</b> ADM element is set to empty list.</p>
</li><li><p><span><span>  </span></span>The
<b>DHCPv4Scope.DHCPv4OptionValues</b> ADM element is set to empty list.</p>
</li></ul></li><li><p><span><span> 
</span></span>Return ERROR_SUCCESS.</p>
</li></ul><p><b>Exceptions Thrown:</b> No exceptions are thrown beyond
those thrown by the underlying RPC protocol <a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a>.</p></div>