ifndef __IPHLPAPI_H__
define __IPHLPAPI_H__

include winapifamily.inc

.pragma comment(lib, iphlpapi)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

include iprtrmib.inc
include ipexport.inc
include iptypes.inc
include tcpestats.inc

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

GetNumberOfInterfaces proto :PDWORD
GetIfEntry proto :PMIB_IFROW
GetIfTable proto :PMIB_IFTABLE, :PULONG, :BOOL
GetIpAddrTable proto :PMIB_IPADDRTABLE, :PULONG, :BOOL
GetIpNetTable proto :PMIB_IPNETTABLE, :PULONG, :BOOL
GetIpForwardTable proto :PMIB_IPFORWARDTABLE, :PULONG, :BOOL

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
GetTcpTable proto :PMIB_TCPTABLE, :PULONG, :BOOL
GetExtendedTcpTable proto :PVOID, :PDWORD, :BOOL, :ULONG, :TCP_TABLE_CLASS, :ULONG
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
GetOwnerModuleFromTcpEntry proto :PMIB_TCPROW_OWNER_MODULE, :TCPIP_OWNER_MODULE_INFO_CLASS, :PVOID, :PDWORD
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
GetUdpTable proto :PMIB_UDPTABLE, :PULONG, :BOOL
GetExtendedUdpTable proto :PVOID, :PDWORD, :BOOL, :ULONG, :UDP_TABLE_CLASS, :ULONG
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

GetOwnerModuleFromUdpEntry proto :PMIB_UDPROW_OWNER_MODULE, :TCPIP_OWNER_MODULE_INFO_CLASS, :PVOID, :PDWORD

if (NTDDI_VERSION ge NTDDI_VISTA)
GetTcpTable2 proto :PMIB_TCPTABLE2, :PULONG, :BOOL
endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

if (NTDDI_VERSION lt NTDDI_VISTA)

AllocateAndGetTcpExTableFromStack proto :ptr, :BOOL, :HANDLE, :DWORD, :DWORD
AllocateAndGetUdpExTableFromStack proto :ptr, :BOOL, :HANDLE, :DWORD, :DWORD

endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

ifdef _WS2IPDEF_

if (NTDDI_VERSION ge NTDDI_VISTA)
GetTcp6Table proto :PMIB_TCP6TABLE, :PULONG, :BOOL
GetTcp6Table2 proto :PMIB_TCP6TABLE2, :PULONG, :BOOL

endif

ifdef WINAPI

GetPerTcpConnectionEStats proto :PMIB_TCPROW, :TCP_ESTATS_TYPE, :PUCHAR, :ULONG, :ULONG, :PUCHAR, :ULONG, :ULONG, :PUCHAR, :ULONG, :ULONG
SetPerTcpConnectionEStats proto :PMIB_TCPROW, :TCP_ESTATS_TYPE, :PUCHAR, :ULONG, :ULONG, :ULONG

ifdef _WS2IPDEF_
GetPerTcp6ConnectionEStats proto :PMIB_TCP6ROW, :TCP_ESTATS_TYPE, :PUCHAR, :ULONG, :ULONG, :PUCHAR, :ULONG, :ULONG, :PUCHAR, :ULONG, :ULONG
SetPerTcp6ConnectionEStats proto :PMIB_TCP6ROW, :TCP_ESTATS_TYPE, :PUCHAR, :ULONG, :ULONG, :ULONG
endif

endif

GetOwnerModuleFromTcp6Entry proto :PMIB_TCP6ROW_OWNER_MODULE, :TCPIP_OWNER_MODULE_INFO_CLASS, :PVOID, :PDWORD
GetUdp6Table proto :PMIB_UDP6TABLE, :PULONG, :BOOL
GetOwnerModuleFromUdp6Entry proto :PMIB_UDP6ROW_OWNER_MODULE, :TCPIP_OWNER_MODULE_INFO_CLASS, :PVOID, :PDWORD

endif

GetOwnerModuleFromPidAndInfo proto :ULONG, :ptr, :TCPIP_OWNER_MODULE_INFO_CLASS, :PVOID, :PDWORD

if (NTDDI_VERSION ge NTDDI_WIN2K)
GetIpStatistics proto :PMIB_IPSTATS
endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

if (NTDDI_VERSION ge NTDDI_WIN2K)
GetIcmpStatistics proto :PMIB_ICMP
endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

if (NTDDI_VERSION ge NTDDI_WIN2K)
GetTcpStatistics proto :PMIB_TCPSTATS
GetUdpStatistics proto :PMIB_UDPSTATS
endif

if (NTDDI_VERSION ge NTDDI_WINXP)
SetIpStatisticsEx proto :PMIB_IPSTATS, :ULONG
endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

if (NTDDI_VERSION ge NTDDI_WINXP)
GetIpStatisticsEx proto :PMIB_IPSTATS, :ULONG
GetIcmpStatisticsEx proto :PMIB_ICMP_EX, :ULONG
GetTcpStatisticsEx proto :PMIB_TCPSTATS, :ULONG
GetUdpStatisticsEx proto :PMIB_UDPSTATS, :ULONG
endif

if (NTDDI_VERSION ge NTDDI_WIN10_RS3)
GetTcpStatisticsEx2 proto :PMIB_TCPSTATS2, :ULONG
GetUdpStatisticsEx2 proto :PMIB_UDPSTATS2, :ULONG
endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

SetIfEntry proto :PMIB_IFROW
CreateIpForwardEntry proto :PMIB_IPFORWARDROW
SetIpForwardEntry proto :PMIB_IPFORWARDROW
DeleteIpForwardEntry proto :PMIB_IPFORWARDROW

if (NTDDI_VERSION ge NTDDI_WIN2K)
SetIpStatistics proto :PMIB_IPSTATS
endif

SetIpTTL proto :UINT
CreateIpNetEntry proto :PMIB_IPNETROW
SetIpNetEntry proto :PMIB_IPNETROW
DeleteIpNetEntry proto :PMIB_IPNETROW
FlushIpNetTable proto :DWORD
CreateProxyArpEntry proto :DWORD, :DWORD, :DWORD
DeleteProxyArpEntry proto :DWORD, :DWORD, :DWORD
SetTcpEntry proto :PMIB_TCPROW
GetInterfaceInfo proto :PIP_INTERFACE_INFO, :PULONG
GetUniDirectionalAdapterInfo proto :PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS, :PULONG

if (NTDDI_VERSION ge NTDDI_WIN2KSP1)

ifndef NHPALLOCATEANDGETINTERFACEINFOFROMSTACK_DEFINED
define NHPALLOCATEANDGETINTERFACEINFOFROMSTACK_DEFINED
NhpAllocateAndGetInterfaceInfoFromStack proto :ptr ptr, :PDWORD, :BOOL, :HANDLE, :DWORD
endif

endif

GetBestInterface proto :IPAddr, :PDWORD

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
GetBestInterfaceEx proto :ptr, :PDWORD
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
GetBestRoute proto :DWORD, :DWORD, :PMIB_IPFORWARDROW
NotifyAddrChange proto :PHANDLE, :ptr OVERLAPPED
NotifyRouteChange proto :PHANDLE, :ptr OVERLAPPED
CancelIPChangeNotify proto :ptr OVERLAPPED
GetAdapterIndex proto :LPWSTR, :PULONG
AddIPAddress proto :IPAddr, :IPMask, :DWORD, :PULONG, :PULONG
DeleteIPAddress proto :ULONG
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

if (NTDDI_VERSION ge NTDDI_WIN2KSP1)
GetNetworkParams proto :PFIXED_INFO, :PULONG
endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
GetAdaptersInfo proto :PIP_ADAPTER_INFO, :PULONG
GetAdapterOrderMap proto
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

ifdef _WINSOCK2API_
GetAdaptersAddresses proto :ULONG, :ULONG, :PVOID, :PIP_ADAPTER_ADDRESSES, :PULONG
endif

if (NTDDI_VERSION ge NTDDI_WIN2KSP1)
GetPerAdapterInfo proto :ULONG, :PIP_PER_ADAPTER_INFO, :PULONG
endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

if (NTDDI_VERSION ge NTDDI_WIN10_RS5)

define INTERFACE_TIMESTAMP_CAPABILITIES_VERSION_1 0x01
define INTERFACE_HARDWARE_CROSSTIMESTAMP_VERSION_1 0x01

_INTERFACE_TIMESTAMP_CAPABILITY_FLAGS struct
PtpV2OverUdpIPv4EventMsgReceiveHw BOOLEAN ?
PtpV2OverUdpIPv4AllMsgReceiveHw BOOLEAN ?
PtpV2OverUdpIPv4EventMsgTransmitHw BOOLEAN ?
PtpV2OverUdpIPv4AllMsgTransmitHw BOOLEAN ?
PtpV2OverUdpIPv6EventMsgReceiveHw BOOLEAN ?
PtpV2OverUdpIPv6AllMsgReceiveHw BOOLEAN ?
PtpV2OverUdpIPv6EventMsgTransmitHw BOOLEAN ?
PtpV2OverUdpIPv6AllMsgTransmitHw BOOLEAN ?
AllReceiveHw            BOOLEAN ?
AllTransmitHw           BOOLEAN ?
TaggedTransmitHw        BOOLEAN ?
AllReceiveSw            BOOLEAN ?
AllTransmitSw           BOOLEAN ?
TaggedTransmitSw        BOOLEAN ?
_INTERFACE_TIMESTAMP_CAPABILITY_FLAGS ends
INTERFACE_TIMESTAMP_CAPABILITY_FLAGS typedef _INTERFACE_TIMESTAMP_CAPABILITY_FLAGS
PINTERFACE_TIMESTAMP_CAPABILITY_FLAGS typedef ptr _INTERFACE_TIMESTAMP_CAPABILITY_FLAGS

_INTERFACE_TIMESTAMP_CAPABILITIES struct
Version                 ULONG ?
HardwareClockFrequencyHz ULONG64 ?
CrossTimestamp          BOOLEAN ?
Reserved1               ULONG64 ?
Reserved2               ULONG64 ?
TimestampFlags          INTERFACE_TIMESTAMP_CAPABILITY_FLAGS ?
_INTERFACE_TIMESTAMP_CAPABILITIES ends
INTERFACE_TIMESTAMP_CAPABILITIES typedef _INTERFACE_TIMESTAMP_CAPABILITIES
PINTERFACE_TIMESTAMP_CAPABILITIES typedef ptr _INTERFACE_TIMESTAMP_CAPABILITIES

_INTERFACE_HARDWARE_CROSSTIMESTAMP struct
Version                 ULONG ?
Flags                   ULONG ?
SystemTimestamp1        ULONG64 ?
HardwareClockTimestamp  ULONG64 ?
SystemTimestamp2        ULONG64 ?
_INTERFACE_HARDWARE_CROSSTIMESTAMP ends
INTERFACE_HARDWARE_CROSSTIMESTAMP typedef _INTERFACE_HARDWARE_CROSSTIMESTAMP
PINTERFACE_HARDWARE_CROSSTIMESTAMP typedef ptr _INTERFACE_HARDWARE_CROSSTIMESTAMP

DECLARE_HANDLE(HIFTIMESTAMPCHANGE)

GetInterfaceCurrentTimestampCapabilities proto :ptr, :PINTERFACE_TIMESTAMP_CAPABILITIES
GetInterfaceHardwareTimestampCapabilities proto :ptr, :PINTERFACE_TIMESTAMP_CAPABILITIES
CaptureInterfaceHardwareCrossTimestamp proto :ptr, :PINTERFACE_HARDWARE_CROSSTIMESTAMP

CALLBACK(PINTERFACE_TIMESTAMP_CONFIG_CHANGE_CALLBACK typedef ptr INTERFACE_TIMESTAMP_CONFIG_CHANGE_CALLBACK

NotifyIfTimestampConfigChange proto :PVOID, :PINTERFACE_TIMESTAMP_CONFIG_CHANGE_CALLBACK, :ptr
CancelIfTimestampConfigChange proto :HIFTIMESTAMPCHANGE

endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

IpReleaseAddress proto :PIP_ADAPTER_INDEX_MAP
IpRenewAddress proto :PIP_ADAPTER_INDEX_MAP
SendARP proto :IPAddr, :IPAddr, :PVOID, :PULONG
GetRTTAndHopCount proto :IPAddr, :PULONG, :ULONG, :PULONG
GetFriendlyIfIndex proto :DWORD
EnableRouter proto :ptr, :ptr
UnenableRouter proto :ptr, :LPDWORD
DisableMediaSense proto :ptr, :ptr
RestoreMediaSense proto :ptr, :LPDWORD

if (NTDDI_VERSION ge NTDDI_VISTA)

GetIpErrorString proto :IP_STATUS, :PWSTR, :PDWORD

if (NTDDI_VERSION ge NTDDI_VISTA)
ifdef _WS2DEF_
ResolveNeighbor proto :ptr, :PVOID, :PULONG
endif
endif

CreatePersistentTcpPortReservation proto :USHORT, :USHORT, :PULONG64
CreatePersistentUdpPortReservation proto :USHORT, :USHORT, :PULONG64
DeletePersistentTcpPortReservation proto :USHORT, :USHORT
DeletePersistentUdpPortReservation proto :USHORT, :USHORT
LookupPersistentTcpPortReservation proto :USHORT, :USHORT, :PULONG64
LookupPersistentUdpPortReservation proto :USHORT, :USHORT, :PULONG64

define NET_STRING_IPV4_ADDRESS           0x00000001
define NET_STRING_IPV4_SERVICE           0x00000002
define NET_STRING_IPV4_NETWORK           0x00000004
define NET_STRING_IPV6_ADDRESS           0x00000008
define NET_STRING_IPV6_ADDRESS_NO_SCOPE  0x00000010
define NET_STRING_IPV6_SERVICE           0x00000020
define NET_STRING_IPV6_SERVICE_NO_SCOPE  0x00000040
define NET_STRING_IPV6_NETWORK           0x00000080
define NET_STRING_NAMED_ADDRESS          0x00000100
define NET_STRING_NAMED_SERVICE          0x00000200

define NET_STRING_IP_ADDRESS             (NET_STRING_IPV4_ADDRESS or NET_STRING_IPV6_ADDRESS)
define NET_STRING_IP_ADDRESS_NO_SCOPE    (NET_STRING_IPV4_ADDRESS or NET_STRING_IPV6_ADDRESS_NO_SCOPE)
define NET_STRING_IP_SERVICE             (NET_STRING_IPV4_SERVICE or NET_STRING_IPV6_SERVICE)
define NET_STRING_IP_SERVICE_NO_SCOPE    (NET_STRING_IPV4_SERVICE or NET_STRING_IPV6_SERVICE_NO_SCOPE)
define NET_STRING_IP_NETWORK             (NET_STRING_IPV4_NETWORK or NET_STRING_IPV6_NETWORK)
define NET_STRING_ANY_ADDRESS            (NET_STRING_NAMED_ADDRESS or NET_STRING_IP_ADDRESS)
define NET_STRING_ANY_ADDRESS_NO_SCOPE   (NET_STRING_NAMED_ADDRESS or NET_STRING_IP_ADDRESS_NO_SCOPE)
define NET_STRING_ANY_SERVICE            (NET_STRING_NAMED_SERVICE or NET_STRING_IP_SERVICE)
define NET_STRING_ANY_SERVICE_NO_SCOPE   (NET_STRING_NAMED_SERVICE or NET_STRING_IP_SERVICE_NO_SCOPE)

.enum NET_ADDRESS_FORMAT {
   NET_ADDRESS_FORMAT_UNSPECIFIED = 0,
   NET_ADDRESS_DNS_NAME,
   NET_ADDRESS_IPV4,
   NET_ADDRESS_IPV6
   }

if defined (_WS2DEF_) and defined (_WS2IPDEF_) and defined(_WINDNS_INCLUDED_)

NET_ADDRESS_INFO_       struct
Format                  NET_ADDRESS_FORMAT ?
union
 struct NamedAddress
  Address               WCHAR DNS_MAX_NAME_BUFFER_LENGTH dup(?)
  Port                  WCHAR 6 dup(?)
 ends
 Ipv4Address            SOCKADDR_IN ?
 Ipv6Address            SOCKADDR_IN6 ?
 IpAddress              SOCKADDR ?
ends
NET_ADDRESS_INFO_       ends
NET_ADDRESS_INFO        typedef NET_ADDRESS_INFO_
PNET_ADDRESS_INFO       typedef ptr NET_ADDRESS_INFO_

ParseNetworkString proto :ptr, :DWORD, :PNET_ADDRESS_INFO, :ptr, :ptr

endif

endif

if (NTDDI_VERSION ge NTDDI_VISTA)
include netioapi.inc
endif

endif

endif
