Share via


4.9 Querying the List of IPv6 Subnets from the DHCP Server

In this example, the DHCP server is configured with 100 DHCPv6 scopes. The example illustrates the use of the RPC methods defined in this specification to enumerate the list of IPv6 scopes configured on the DHCP server.

The client calls the RPC method R_DhcpEnumSubnetsV6 (section 3.2.4.59) 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.

  • Zero as the handle to the location within the DHCP server's data from which the RPC method will return data, in order to request data from the beginning of the data set. The handle can be set to zero. A successful call to the RPC method will return an updated handle to the location from which the data will be read in the next call to the RPC method.

  • Fifty as the preferred maximum number of IPv6 subnet addresses to return.

  • A pointer, EnumInfo, of type LPDHCPV6_IP_ARRAY (section 2.2.1.2.57) to a structure that contains a pointer to an array of DHCP_IPV6_ADDRESS (section 2.2.1.2.28) and the number of elements in the array in which the scope addresses identifying the DHCPv6 scopes configured on the server will be returned to the DHCP server.

  • An allocated pointer, ElementsRead, to a DWORD in which the number of scope addresses returned by the API is returned.

  • An allocated pointer, ElementsTotal, to a DWORD in which the total number of IPv6 scopes configured on the DHCP server that are still to be returned by the RPC method is returned.

When the client calls the RPC method as described in the preceding list, it returns ERROR_SUCCESS, and additionally the following parameter values are updated:

  • A pointer, EnumInfo, of type LPDHCPV6_IP_ARRAY to a structure that contains a pointer to an array of DHCP_IPV6_ADDRESS and the number of elements in the array; will contain the scope address of the first 50 of the 100 IPv6 scopes configured on the DHCP server.

  • The handle to the location on the DHCP server from which the DHCP server will return data in a subsequent invocation of this RPC method will be updated.

  • A DWORD, the ElementsRead parameter, containing the number of scope addresses returned by the API; will be set to 50.

  • A DWORD, the ElementsTotal parameter, containing the total number of IPv6 scopes configured on the DHCP server; is set to 50.

The client frees the memory pointed to by the pointer EnumInfo of type LPDHCPV6_IP_ARRAY by calling the function midl_user_free (section 3).

The client then calls the RPC method R_DhcpEnumSubnetsV6 again 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 updated handle received from the previous call to the RPC method is passed in as the handle to the location from which the DHCP server will return data in this invocation.

  • Fifty as the preferred maximum number of IPv6 subnet addresses to return.

  • A pointer, EnumInfo, of type LPDHCPV6_IP_ARRAY to a structure that contains a pointer to an array of DHCP_IPV6_ADDRESS and the number of elements in the array in which the scope addresses identifying the DHCPv6 scopes configured on the server will be returned.

  • A pointer, ElementsRead, to a DWORD in which the number of scope addresses returned by the API is returned.

  • A pointer, ElementsTotal, to a DWORD in which the total number of IPv6 scopes configured on the DHCP server that are still to be returned by the RPC method is returned.

This second call to the RPC method returns ERROR_SUCCESS, and additionally the following parameter values are updated:

  • The pointer of type LPDHCPV6_IP_ARRAY to a structure that contains a pointer to an array of DHCP_IPV6_ADDRESS and the number of elements in the array will contain the scope address of the remaining 50 IPv6 scopes configured on DHCP server.

  • The handle to the location on the DHCP server from which the DHCP server will return data in a subsequent invocation of this RPC method will be updated to the end of the server's data set.

  • A DWORD, the ElementsRead parameter, containing the number of scope addresses returned by the API; will be set to 50.

  • A DWORD, the ElementsTotal parameter, containing the total number of IPv4 scopes configured on the DHCP server; is set to 0.

Upon a successful call, as soon as the client no longer needs the list of enumerated DHCPv6 scopes, the client frees the memory pointed to by the pointer EnumInfo of type LPDHCPV6_IP_ARRAY by calling the function midl_user_free (section 3).