using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
/// Items from Dhcpcsvc6.dll and Dhcpcsvc.dll.
public static partial class Dhcp
{
private const string Lib_Dhcpcsvc6 = "dhcpcsvc6.dll";
/// DHCP V6 options.
[PInvokeData("dhcpcsdk.h")]
public enum DHCPV6_OPTION_ID : uint
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
DHCPV6_OPTION_CLIENTID = 1,
DHCPV6_OPTION_SERVERID = 2,
DHCPV6_OPTION_IA_NA = 3,
DHCPV6_OPTION_IA_TA = 4,
DHCPV6_OPTION_ORO = 6,
DHCPV6_OPTION_PREFERENCE = 7,
DHCPV6_OPTION_UNICAST = 12,
DHCPV6_OPTION_RAPID_COMMIT = 14,
DHCPV6_OPTION_USER_CLASS = 15,
DHCPV6_OPTION_VENDOR_CLASS = 16,
DHCPV6_OPTION_VENDOR_OPTS = 17,
DHCPV6_OPTION_RECONF_MSG = 19,
DHCPV6_OPTION_SIP_SERVERS_NAMES = 21,
DHCPV6_OPTION_SIP_SERVERS_ADDRS = 22,
DHCPV6_OPTION_DNS_SERVERS = 23,
DHCPV6_OPTION_DOMAIN_LIST = 24,
DHCPV6_OPTION_IA_PD = 25,
DHCPV6_OPTION_NIS_SERVERS = 27,
DHCPV6_OPTION_NISP_SERVERS = 28,
DHCPV6_OPTION_NIS_DOMAIN_NAME = 29,
DHCPV6_OPTION_NISP_DOMAIN_NAME = 30,
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
}
/// The StatusCode enum contains status codes for IPv6 operations.
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/ne-dhcpv6csdk-statuscode typedef enum { STATUS_NO_ERROR,
// STATUS_UNSPECIFIED_FAILURE, STATUS_NO_BINDING, STATUS_NOPREFIX_AVAIL } StatusCode;
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NE:dhcpv6csdk.__unnamed_enum_0")]
public enum StatusCode
{
///
STATUS_NO_ERROR,
///
STATUS_UNSPECIFIED_FAILURE,
///
STATUS_NO_BINDING,
///
STATUS_NOPREFIX_AVAIL,
}
///
/// The Dhcpv6CApiCleanup function enables DHCPv6 to properly clean up resources allocated throughout the use of DHCPv6
/// function calls. The Dhcpv6CApiCleanup function must only be called if a previous call to Dhcpv6CApiInitialize executed successfully.
///
/// None
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/nf-dhcpv6csdk-dhcpv6capicleanup void Dhcpv6CApiCleanup();
[DllImport(Lib_Dhcpcsvc6, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NF:dhcpv6csdk.Dhcpv6CApiCleanup")]
public static extern void Dhcpv6CApiCleanup();
///
/// The Dhcpv6CApiInitialize function must be the first function call made by users of DHCPv6. The function prepares the
/// system for all other DHCPv6 function calls. Other DHCPv6 functions should only be called if the Dhcpv6CApiInitialize
/// function executes successfully.
///
///
/// Pointer to the DHCPv6 version implemented by the client. If a valid pointer is passed, the DHCPv6 client will be returned
/// through it.
///
/// Returns ERROR_SUCCESS upon successful completion.
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/nf-dhcpv6csdk-dhcpv6capiinitialize void Dhcpv6CApiInitialize(
// LPDWORD Version );
[DllImport(Lib_Dhcpcsvc6, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NF:dhcpv6csdk.Dhcpv6CApiInitialize")]
public static extern void Dhcpv6CApiInitialize(out uint Version);
/// The Dhcpv6ReleasePrefix function releases a prefix previously acquired with the Dhcpv6RequestPrefix function.
/// Name of the adapter on which the PD request must be sent.
///
/// Pointer to a DHCPV6CAPI_CLASSID structure that contains the binary ClassId information to use to send on the wire.
///
/// Note DHCPv6 Option Code 15 (0x000F) is not supported by this API. Typically, the User Class option is used by a client to
/// identify the type or category of user or application it represents. A server selects the configuration information for the
/// client based on the classes identified in this option.
///
///
/// Pointer to a DHCPV6CAPIPrefixLeaseInformation structure that is used to release the prefix.
///
/// Returns ERROR_SUCCESS upon successful completion.
///
///
/// Return code
/// Description
///
/// -
/// ERROR_INVALID_PARAMETER
/// Returned if one of the following conditions are true:
///
/// -
/// ERROR_INVALID_NAME
/// The AdapterName is not in the correct format. It should be in this format: {00000000-0000-0000-0000-000000000000}.
///
///
///
///
///
/// Release messages sent as the result of the call to this function must contain the following values for the T1 and
/// T2 fields of the DHCPV6CAPIPrefixLeaseInformation structure supplied in the prefixleaseInfo parameter:
///
///
/// -
/// T1: the renewal time for the prefix, in seconds specified as absolute time values.
///
/// -
/// T2: the rebind time of the prefix, in seconds specified as absolute time values.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/nf-dhcpv6csdk-dhcpv6releaseprefix DWORD Dhcpv6ReleasePrefix( LPWSTR
// adapterName, LPDHCPV6CAPI_CLASSID classId, LPDHCPV6PrefixLeaseInformation leaseInfo );
[DllImport(Lib_Dhcpcsvc6, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NF:dhcpv6csdk.Dhcpv6ReleasePrefix")]
public static extern Win32Error Dhcpv6ReleasePrefix([MarshalAs(UnmanagedType.LPWStr)] string adapterName, in DHCPV6CAPI_CLASSID classId,
in DHCPV6PrefixLeaseInformation leaseInfo);
/// The Dhcpv6ReleasePrefix function releases a prefix previously acquired with the Dhcpv6RequestPrefix function.
/// Name of the adapter on which the PD request must be sent.
///
/// Pointer to a DHCPV6CAPI_CLASSID structure that contains the binary ClassId information to use to send on the wire.
///
/// Note DHCPv6 Option Code 15 (0x000F) is not supported by this API. Typically, the User Class option is used by a client to
/// identify the type or category of user or application it represents. A server selects the configuration information for the
/// client based on the classes identified in this option.
///
///
/// Pointer to a DHCPV6CAPIPrefixLeaseInformation structure that is used to release the prefix.
///
/// Returns ERROR_SUCCESS upon successful completion.
///
///
/// Return code
/// Description
///
/// -
/// ERROR_INVALID_PARAMETER
/// Returned if one of the following conditions are true:
///
/// -
/// ERROR_INVALID_NAME
/// The AdapterName is not in the correct format. It should be in this format: {00000000-0000-0000-0000-000000000000}.
///
///
///
///
///
/// Release messages sent as the result of the call to this function must contain the following values for the T1 and
/// T2 fields of the DHCPV6CAPIPrefixLeaseInformation structure supplied in the prefixleaseInfo parameter:
///
///
/// -
/// T1: the renewal time for the prefix, in seconds specified as absolute time values.
///
/// -
/// T2: the rebind time of the prefix, in seconds specified as absolute time values.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/nf-dhcpv6csdk-dhcpv6releaseprefix DWORD Dhcpv6ReleasePrefix( LPWSTR
// adapterName, LPDHCPV6CAPI_CLASSID classId, LPDHCPV6PrefixLeaseInformation leaseInfo );
[DllImport(Lib_Dhcpcsvc6, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NF:dhcpv6csdk.Dhcpv6ReleasePrefix")]
public static extern Win32Error Dhcpv6ReleasePrefix([MarshalAs(UnmanagedType.LPWStr)] string adapterName, [In, Optional] IntPtr classId,
in DHCPV6PrefixLeaseInformation leaseInfo);
/// The Dhcpv6RenewPrefix function renews a prefix previously acquired with the Dhcpv6RequestPrefix function.
/// GUID of the adapter on which the prefix renewal must be sent.
///
///
/// Pointer to a DHCPV6CAPI_CLASSID structure that contains the binary ClassId information to send on the wire. This parameter is
/// can be NULL.
///
///
/// Note DHCPv6 Option Code 15 (0x000F) is not supported by this API. Typically, the User Class option is used by a client to
/// identify the type or category of user or application it represents. A server selects the configuration information for the
/// client based on the classes identified in this option.
///
///
/// Pointer to a DHCPV6PrefixLeaseInformation structure that contains the prefix lease information.
///
/// Contains the number of seconds a requesting application needs to wait before calling the Dhcpv6RenewPrefix function to
/// renew its acquired prefixes. A value of 0xFFFFFFFF indicates that the application does not need to renew its lease.
///
///
/// Specifies to the DHCPv6 client whether or not to send a REBIND in order to validate the prefix bindings. TRUE indicates
/// that a REBIND is required. FALSE indicates RENEW is required.
///
///
/// Returns ERROR_SUCCESS upon successful completion.
///
///
/// Return code
/// Description
///
/// -
/// ERROR_INVALID_PARAMETER
/// Returned if one of the following conditions are true:
///
/// -
/// ERROR_MORE_DATA
/// Returned if the API responds with more prefixes than there is memory allocated.
///
/// -
/// ERROR_INVALID_NAME
/// The AdapterName is not in the correct format. It should be in this format: {00000000-0000-0000-0000-000000000000}.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/nf-dhcpv6csdk-dhcpv6renewprefix DWORD Dhcpv6RenewPrefix( LPWSTR
// adapterName, LPDHCPV6CAPI_CLASSID pclassId, LPDHCPV6PrefixLeaseInformation prefixleaseInfo, DWORD *pdwTimeToWait, DWORD
// bValidatePrefix );
[DllImport(Lib_Dhcpcsvc6, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NF:dhcpv6csdk.Dhcpv6RenewPrefix")]
public static extern Win32Error Dhcpv6RenewPrefix([MarshalAs(UnmanagedType.LPWStr)] string adapterName, in DHCPV6CAPI_CLASSID pclassId,
ref DHCPV6PrefixLeaseInformation prefixleaseInfo, out uint pdwTimeToWait, [MarshalAs(UnmanagedType.Bool)] bool bValidatePrefix);
/// The Dhcpv6RenewPrefix function renews a prefix previously acquired with the Dhcpv6RequestPrefix function.
/// GUID of the adapter on which the prefix renewal must be sent.
///
///
/// Pointer to a DHCPV6CAPI_CLASSID structure that contains the binary ClassId information to send on the wire. This parameter is
/// can be NULL.
///
///
/// Note DHCPv6 Option Code 15 (0x000F) is not supported by this API. Typically, the User Class option is used by a client to
/// identify the type or category of user or application it represents. A server selects the configuration information for the
/// client based on the classes identified in this option.
///
///
/// Pointer to a DHCPV6PrefixLeaseInformation structure that contains the prefix lease information.
///
/// Contains the number of seconds a requesting application needs to wait before calling the Dhcpv6RenewPrefix function to
/// renew its acquired prefixes. A value of 0xFFFFFFFF indicates that the application does not need to renew its lease.
///
///
/// Specifies to the DHCPv6 client whether or not to send a REBIND in order to validate the prefix bindings. TRUE indicates
/// that a REBIND is required. FALSE indicates RENEW is required.
///
///
/// Returns ERROR_SUCCESS upon successful completion.
///
///
/// Return code
/// Description
///
/// -
/// ERROR_INVALID_PARAMETER
/// Returned if one of the following conditions are true:
///
/// -
/// ERROR_MORE_DATA
/// Returned if the API responds with more prefixes than there is memory allocated.
///
/// -
/// ERROR_INVALID_NAME
/// The AdapterName is not in the correct format. It should be in this format: {00000000-0000-0000-0000-000000000000}.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/nf-dhcpv6csdk-dhcpv6renewprefix DWORD Dhcpv6RenewPrefix( LPWSTR
// adapterName, LPDHCPV6CAPI_CLASSID pclassId, LPDHCPV6PrefixLeaseInformation prefixleaseInfo, DWORD *pdwTimeToWait, DWORD
// bValidatePrefix );
[DllImport(Lib_Dhcpcsvc6, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NF:dhcpv6csdk.Dhcpv6RenewPrefix")]
public static extern Win32Error Dhcpv6RenewPrefix([MarshalAs(UnmanagedType.LPWStr)] string adapterName, [In, Optional] IntPtr pclassId,
ref DHCPV6PrefixLeaseInformation prefixleaseInfo, out uint pdwTimeToWait, [MarshalAs(UnmanagedType.Bool)] bool bValidatePrefix);
/// The Dhcpv6RequestParams function requests options from the DHCPv6 client cache or directly from the DHCPv6 server.
///
/// If this value is set to TRUE, any available cached information will be ignored and new information will be requested.
/// Otherwise, the request is only sent if there is no cached information.
///
/// Reserved for future use. Must be set to NULL.
/// GUID of the adapter for which this request is meant. This parameter must not be NULL.
///
/// Pointer to a DHCPV6CAPI_CLASSID structure that contains the binary ClassId information to use to send on the wire. This
/// parameter is optional.
///
/// A DHCPV6CAPI_PARAMS_ARRAY structure that contains the parameters to be received from the DHCPV6 server.
/// A buffer to contain information returned by some pointers in recdParams.
///
/// Size of the buffer. When the function returns ERROR_MORE_DATA, this parameter will contain the size, in bytes, required to
/// complete the operation. If the function is successful, this parameter contains the number of bytes used.
///
///
/// Returns ERROR_SUCCESS upon successful completion.
///
///
/// Return code
/// Description
///
/// -
/// ERROR_INVALID_PARAMETER
/// Returned if one of the following conditions are true:
///
/// -
/// ERROR_MORE_DATA
///
/// The call to this API was made with insufficient memory allocated for the Buffer parameter, while pSize contains the actual
/// memory size required.
///
///
/// -
/// ERROR_INVALID_NAME
/// The AdapterName is not in the correct format. It should be in this format: {00000000-0000-0000-0000-000000000000}.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/nf-dhcpv6csdk-dhcpv6requestparams DWORD Dhcpv6RequestParams( BOOL
// forceNewInform, LPVOID reserved, LPWSTR adapterName, LPDHCPV6CAPI_CLASSID classId, DHCPV6CAPI_PARAMS_ARRAY recdParams, LPBYTE
// buffer, LPDWORD pSize );
[DllImport(Lib_Dhcpcsvc6, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NF:dhcpv6csdk.Dhcpv6RequestParams")]
public static extern Win32Error Dhcpv6RequestParams([MarshalAs(UnmanagedType.Bool)] bool forceNewInform, [In, Optional] IntPtr reserved,
[MarshalAs(UnmanagedType.LPWStr)] string adapterName, in DHCPV6CAPI_CLASSID classId, [In, Out] DHCPV6CAPI_PARAMS_ARRAY recdParams,
[In] IntPtr buffer, ref uint pSize);
/// The Dhcpv6RequestParams function requests options from the DHCPv6 client cache or directly from the DHCPv6 server.
///
/// If this value is set to TRUE, any available cached information will be ignored and new information will be requested.
/// Otherwise, the request is only sent if there is no cached information.
///
/// Reserved for future use. Must be set to NULL.
/// GUID of the adapter for which this request is meant. This parameter must not be NULL.
///
/// Pointer to a DHCPV6CAPI_CLASSID structure that contains the binary ClassId information to use to send on the wire. This
/// parameter is optional.
///
/// A DHCPV6CAPI_PARAMS_ARRAY structure that contains the parameters to be received from the DHCPV6 server.
/// A buffer to contain information returned by some pointers in recdParams.
///
/// Size of the buffer. When the function returns ERROR_MORE_DATA, this parameter will contain the size, in bytes, required to
/// complete the operation. If the function is successful, this parameter contains the number of bytes used.
///
///
/// Returns ERROR_SUCCESS upon successful completion.
///
///
/// Return code
/// Description
///
/// -
/// ERROR_INVALID_PARAMETER
/// Returned if one of the following conditions are true:
///
/// -
/// ERROR_MORE_DATA
///
/// The call to this API was made with insufficient memory allocated for the Buffer parameter, while pSize contains the actual
/// memory size required.
///
///
/// -
/// ERROR_INVALID_NAME
/// The AdapterName is not in the correct format. It should be in this format: {00000000-0000-0000-0000-000000000000}.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/nf-dhcpv6csdk-dhcpv6requestparams DWORD Dhcpv6RequestParams( BOOL
// forceNewInform, LPVOID reserved, LPWSTR adapterName, LPDHCPV6CAPI_CLASSID classId, DHCPV6CAPI_PARAMS_ARRAY recdParams, LPBYTE
// buffer, LPDWORD pSize );
[DllImport(Lib_Dhcpcsvc6, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NF:dhcpv6csdk.Dhcpv6RequestParams")]
public static extern Win32Error Dhcpv6RequestParams([MarshalAs(UnmanagedType.Bool)] bool forceNewInform, [In, Optional] IntPtr reserved,
[MarshalAs(UnmanagedType.LPWStr)] string adapterName, [In, Optional] IntPtr classId, [In, Out] DHCPV6CAPI_PARAMS_ARRAY recdParams,
[In] IntPtr buffer, ref uint pSize);
/// The Dhcpv6RequestPrefix function requests a specific prefix.
/// GUID of the adapter on which the prefix request must be sent.
///
///
/// Pointer to a DHCPV6CAPI_CLASSID structure that contains the binary ClassId information to send on the wire. This parameter is optional.
///
///
/// Note DHCPv6 Option Code 15 (0x000F) is not supported by this API. Typically, the User Class option is used by a client to
/// identify the type or category of user or application it represents. A server selects the configuration information for the
/// client based on the classes identified in this option.
///
///
///
/// Pointer to a DHCPV6PrefixLeaseInformation structure that contains the prefix lease information.
/// The following members of the DHCPV6PrefixLeaseInformation structure must follow these guidelines.
///
///
/// DHCPV6PrefixLeaseInformation member
/// Consideration
///
/// -
/// nPrefixes
///
/// Must contain a maximum value of 10. The caller should have the memory allocated in the prefixArray member based on the number of
/// prefixes specified.
///
///
/// -
/// iaid
///
/// A unique positive number assigned to this member. This same value should be reused if this function is called again.This
/// mandatory value must be set by the calling application.
///
///
/// -
/// ServerIdLen
///
/// Must contain a maximum value of 128. The caller must have the memory allocated in the ServerId member based on the specified
/// ServerIdLen value.
///
///
///
///
/// The caller must follow these considerations when assigning the values of the nPrefixes, iaid, and
/// ServerIdLen members of the DHCPV6PrefixLeaseInformation structure. Based on these values, memory must also be properly
/// allocated to the ServerId and PrefixArray members before the Dhcpv6RequestPrefix function is called.
///
///
///
/// Contains the number of seconds a requesting application needs to wait before calling the Dhcpv6RenewPrefix function to renew its
/// acquired prefixes. A value of 0xFFFFFFFF indicates that the application does not need to renew its lease.
///
///
/// Returns ERROR_SUCCESS upon successful completion.
///
///
/// Return code
/// Description
///
/// -
/// ERROR_MORE_DATA
///
/// The value of the nPrefixes or the ServerIdLen member specified is less than the number of prefixes available from the server or
/// the available server ID length. Increase the nPrefixes or the ServerIdLen member and make sure the corresponding memory has been
/// allocated properly before calling the Dhcpv6RequestPrefix function again.
///
///
/// -
/// ERROR_INVALID_PARAMETER
/// Returned if one of the following conditions are true:
///
/// -
/// ERROR_INVALID_NAME
/// The AdapterName is not in the correct format. It should be in this format: {00000000-0000-0000-0000-000000000000}.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/nf-dhcpv6csdk-dhcpv6requestprefix DWORD Dhcpv6RequestPrefix( LPWSTR
// adapterName, LPDHCPV6CAPI_CLASSID pclassId, LPDHCPV6PrefixLeaseInformation prefixleaseInfo, DWORD *pdwTimeToWait );
[DllImport(Lib_Dhcpcsvc6, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NF:dhcpv6csdk.Dhcpv6RequestPrefix")]
public static extern Win32Error Dhcpv6RequestPrefix([MarshalAs(UnmanagedType.LPWStr)] string adapterName, in DHCPV6CAPI_CLASSID pclassId,
ref DHCPV6PrefixLeaseInformation prefixleaseInfo, out uint pdwTimeToWait);
/// The Dhcpv6RequestPrefix function requests a specific prefix.
/// GUID of the adapter on which the prefix request must be sent.
///
///
/// Pointer to a DHCPV6CAPI_CLASSID structure that contains the binary ClassId information to send on the wire. This parameter is optional.
///
///
/// Note DHCPv6 Option Code 15 (0x000F) is not supported by this API. Typically, the User Class option is used by a client to
/// identify the type or category of user or application it represents. A server selects the configuration information for the
/// client based on the classes identified in this option.
///
///
///
/// Pointer to a DHCPV6PrefixLeaseInformation structure that contains the prefix lease information.
/// The following members of the DHCPV6PrefixLeaseInformation structure must follow these guidelines.
///
///
/// DHCPV6PrefixLeaseInformation member
/// Consideration
///
/// -
/// nPrefixes
///
/// Must contain a maximum value of 10. The caller should have the memory allocated in the prefixArray member based on the number of
/// prefixes specified.
///
///
/// -
/// iaid
///
/// A unique positive number assigned to this member. This same value should be reused if this function is called again.This
/// mandatory value must be set by the calling application.
///
///
/// -
/// ServerIdLen
///
/// Must contain a maximum value of 128. The caller must have the memory allocated in the ServerId member based on the specified
/// ServerIdLen value.
///
///
///
///
/// The caller must follow these considerations when assigning the values of the nPrefixes, iaid, and
/// ServerIdLen members of the DHCPV6PrefixLeaseInformation structure. Based on these values, memory must also be properly
/// allocated to the ServerId and PrefixArray members before the Dhcpv6RequestPrefix function is called.
///
///
///
/// Contains the number of seconds a requesting application needs to wait before calling the Dhcpv6RenewPrefix function to renew its
/// acquired prefixes. A value of 0xFFFFFFFF indicates that the application does not need to renew its lease.
///
///
/// Returns ERROR_SUCCESS upon successful completion.
///
///
/// Return code
/// Description
///
/// -
/// ERROR_MORE_DATA
///
/// The value of the nPrefixes or the ServerIdLen member specified is less than the number of prefixes available from the server or
/// the available server ID length. Increase the nPrefixes or the ServerIdLen member and make sure the corresponding memory has been
/// allocated properly before calling the Dhcpv6RequestPrefix function again.
///
///
/// -
/// ERROR_INVALID_PARAMETER
/// Returned if one of the following conditions are true:
///
/// -
/// ERROR_INVALID_NAME
/// The AdapterName is not in the correct format. It should be in this format: {00000000-0000-0000-0000-000000000000}.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/nf-dhcpv6csdk-dhcpv6requestprefix DWORD Dhcpv6RequestPrefix( LPWSTR
// adapterName, LPDHCPV6CAPI_CLASSID pclassId, LPDHCPV6PrefixLeaseInformation prefixleaseInfo, DWORD *pdwTimeToWait );
[DllImport(Lib_Dhcpcsvc6, SetLastError = false, ExactSpelling = true)]
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NF:dhcpv6csdk.Dhcpv6RequestPrefix")]
public static extern Win32Error Dhcpv6RequestPrefix([MarshalAs(UnmanagedType.LPWStr)] string adapterName, [In, Optional] IntPtr pclassId,
ref DHCPV6PrefixLeaseInformation prefixleaseInfo, out uint pdwTimeToWait);
/// The DHCPV6CAPI_CLASSID structure defines an IPv6 client class ID.
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/ns-dhcpv6csdk-dhcpv6capi_classid typedef struct _DHCPV6CAPI_CLASSID
// { ULONG Flags; #if ... LPBYTE Data; #else LPBYTE Data; #endif ULONG nBytesData; } DHCPV6CAPI_CLASSID, *PDHCPV6CAPI_CLASSID, *LPDHCPV6CAPI_CLASSID;
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NS:dhcpv6csdk._DHCPV6CAPI_CLASSID")]
[StructLayout(LayoutKind.Sequential)]
public struct DHCPV6CAPI_CLASSID
{
/// Reserved for future use. Must be set to 0.
public uint Flags;
/// Class ID binary data.
public IntPtr Data;
/// Size of Data, in bytes.
public uint nBytesData;
}
/// A DHCPV6CAPI_PARAMS structure contains a requested parameter.
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/ns-dhcpv6csdk-dhcpv6capi_params typedef struct _DHCPV6CAPI_PARAMS {
// ULONG Flags; ULONG OptionId; BOOL IsVendor; LPBYTE Data; DWORD nBytesData; } DHCPV6CAPI_PARAMS, *PDHCPV6CAPI_PARAMS, *LPDHCPV6CAPI_PARAMS;
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NS:dhcpv6csdk._DHCPV6CAPI_PARAMS")]
[StructLayout(LayoutKind.Sequential)]
public struct DHCPV6CAPI_PARAMS
{
/// Reserved for future use.
public uint Flags;
///
/// Identifier for the DHCPv6 parameter being requested.
/// DHCPV6_OPTION_CLIENTID
/// DHCPV6_OPTION_SERVERID
/// DHCPV6_OPTION_IA_NA
/// DHCPV6_OPTION_IA_TA
/// DHCPV6_OPTION_ORO
/// DHCPV6_OPTION_PREFERENCE
/// DHCPV6_OPTION_UNICAST
/// DHCPV6_OPTION_RAPID_COMMIT
/// DHCPV6_OPTION_USER_CLASS
/// DHCPV6_OPTION_VENDOR_CLASS
/// DHCPV6_OPTION_VENDOR_OPTS
/// DHCPV6_OPTION_RECONF_MSG
/// DHCPV6_OPTION_SIP_SERVERS_NAMES
/// DHCPV6_OPTION_SIP_SERVERS_ADDRS
/// DHCPV6_OPTION_DNS_SERVERS
/// DHCPV6_OPTION_DOMAIN_LIST
/// DHCPV6_OPTION_IA_PD
/// DHCPV6_OPTION_NIS_SERVERS
/// DHCPV6_OPTION_NISP_SERVERS
/// DHCPV6_OPTION_NIS_DOMAIN_NAME
/// DHCPV6_OPTION_CLIENTIDNISP_DOMAIN_NAME
///
public DHCPV6_OPTION_ID OptionId;
/// This option is set to TRUE if this parameter is vendor-specific. Otherwise, it is FALSE.
[MarshalAs(UnmanagedType.Bool)]
public bool IsVendor;
/// Contains the actual parameter data.
public IntPtr Data;
/// Size of the Data member, in bytes.
public uint nBytesData;
}
/// The DHCPV6CAPI_PARAMS_ARRAY structure contains an array of requested parameters.
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/ns-dhcpv6csdk-dhcpv6capi_params_array typedef struct
// _DHCPV6CAPI_PARAMS_ARRAY { ULONG nParams; LPDHCPV6CAPI_PARAMS Params; } DHCPV6CAPI_PARAMS_ARRAY, *PDHCPV6CAPI_PARAMS_ARRAY, *LPDHCPV6CAPI_PARAMS_ARRAY;
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NS:dhcpv6csdk._DHCPV6CAPI_PARAMS_ARRAY")]
[StructLayout(LayoutKind.Sequential)]
public struct DHCPV6CAPI_PARAMS_ARRAY
{
/// Number of parameters in the array.
public uint nParams;
/// Pointer to a DHCPV6CAPI_PARAMS structure that contains a parameter.
public IntPtr /*LPDHCPV6CAPI_PARAMS*/ Params;
}
/// The DHCPV6Prefix contains an IPv6 prefix.
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/ns-dhcpv6csdk-dhcpv6prefix typedef struct _DHCPV6Prefix { UCHAR
// prefix[16]; DWORD prefixLength; DWORD preferredLifeTime; DWORD validLifeTime; StatusCode status; } DHCPV6Prefix, *PDHCPV6Prefix, *LPDHCPV6Prefix;
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NS:dhcpv6csdk._DHCPV6Prefix")]
[StructLayout(LayoutKind.Sequential)]
public struct DHCPV6Prefix
{
/// 128 bit prefix.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] prefix;
/// Length of the prefix.
public uint prefixLength;
/// Preferred lifetime of the prefix, in seconds.
public uint preferredLifeTime;
/// The valid lifetime of the prefix in seconds.
public uint validLifeTime;
/// The status code returned.
public StatusCode status;
}
/// The DHCPV6PrefixLeaseInformation structure contains information about a prefix lease.
///
/// In a prefix delegation scenario, the validation of lease lifetime values (specific status codes, T1, T2,
/// MaxLeaseExpirationTime, and LastRenewalTime) are performed by the calling API, rather than the application
/// consuming the data, as the latter might interpret these values differently.
///
// https://docs.microsoft.com/en-us/windows/win32/api/dhcpv6csdk/ns-dhcpv6csdk-dhcpv6prefixleaseinformation typedef struct
// _DHCPV6PrefixLeaseInformation { DWORD nPrefixes; LPDHCPV6Prefix prefixArray; DWORD iaid; time_t T1; time_t T2; time_t
// MaxLeaseExpirationTime; time_t LastRenewalTime; StatusCode status; LPBYTE ServerId; DWORD ServerIdLen; }
// DHCPV6PrefixLeaseInformation, *PDHCPV6PrefixLeaseInformation, *LPDHCPV6PrefixLeaseInformation;
[PInvokeData("dhcpv6csdk.h", MSDNShortId = "NS:dhcpv6csdk._DHCPV6PrefixLeaseInformation")]
[StructLayout(LayoutKind.Sequential)]
public struct DHCPV6PrefixLeaseInformation
{
/// Number of prefixes.
public uint nPrefixes;
/// Pointer to a list DHCPV6Prefix structures that contain the prefixes requested or returned by the server.
public IntPtr /*LPDHCPV6Prefix*/ prefixArray;
/// Identity Association identifier for the prefix operation.
public uint iaid;
/// The renewal time for the prefix, in seconds.
public time_t T1;
/// The rebind time of the prefix, in seconds.
public time_t T2;
/// The maximum lease expiration time of all the prefix leases in this structure.
public time_t MaxLeaseExpirationTime;
/// The time at which the last renewal for the prefixes occurred.
public time_t LastRenewalTime;
///
///
/// Status code returned by the server for the IAPD. The following codes can be returned by the DHCP server for prefix
/// delegation scenarios:
///
///
///
/// Value
/// Meaning
///
/// -
/// STATUS_NO_ERROR 0
/// The prefix was successfully leased or renewed.
///
/// -
/// STATUS_UNSPECIFIED_FAILURE 1
/// The lease or renewal action failed for an unspecified reason.
///
/// -
/// STATUS_NO_BINDING 3
/// The DHCPv6 server does not have a binding for the prefix.
///
/// -
/// STATUS_NOPREFIX_AVAIL 6
/// The DHCPv6 server does not have a prefix availble to offer the requesting client.
///
///
///
public StatusCode status;
/// The server DUID from which the prefix is received. This data is used in subsequent renews.
public IntPtr ServerId;
/// The length of the above DUID data.
public uint ServerIdLen;
}
}
}