' ########################################################################################
' Microsoft Windows
' File: IPHlpApi.inc
' Contents: Header file for functions to interact with the IP Stack for MIB-II and
' related functionality
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_IPHlpApi_PBI)
#DEFINE PBX_IPHlpApi_PBI
%EQUATE `IPHLPAPI_INC = 1
#INCLUDE ONCE "Core/Windows.inc"
'//////////////////////////////////////////////////////////////////////////////
'// //
'// IPRTRMIB.H has the definitions of the strcutures used to set and get //
'// information //
'// //
'//////////////////////////////////////////////////////////////////////////////
#INCLUDE ONCE "Legacy/System/Iprtrmib.inc"
#INCLUDE ONCE "Legacy/System/IPExport.inc"
#INCLUDE ONCE "Legacy/System/IPTypes.inc"
#INCLUDE ONCE "Legacy/Runtime/tcpestats.inc"
'//////////////////////////////////////////////////////////////////////////////
'// //
'// The GetXXXTable APIs take a buffer and a size of buffer. If the buffer //
'// is not large enough, the APIs return ERROR_INSUFFICIENT_BUFFER and //
'// *pdwSize is the required buffer size //
'// The bOrder is a BOOLEAN, which if TRUE sorts the table according to //
'// MIB-II (RFC XXXX) //
'// //
'//////////////////////////////////////////////////////////////////////////////
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Retrieves the number of interfaces in the system. These include LAN and //
'// WAN interfaces //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION GetNumberOfInterfaces LIB "iphlpapi.dll" ALIAS "GetNumberOfInterfaces" ( BYREF pdwNumIf AS QUAD ) AS QUAD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Gets the MIB-II ifEntry //
'// The dwIndex field of the MIB_IFROW should be set to the index of the //
'// interface being queried //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION GetIfEntry LIB "iphlpapi.dll" ALIAS "GetIfEntry" ( BYREF pIfRow AS MIB_IFROW ) AS QUAD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Gets the MIB-II IfTable //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION GetIfTable LIB "iphlpapi.dll" ALIAS "GetIfTable" ( BYREF pIfTable AS MIB_IFTABLE , BYREF pdwSize AS QUAD , BYVAL bOrder AS LONG ) AS QUAD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Gets the Interface to IP Address mapping //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION GetIpAddrTable LIB "iphlpapi.dll" ALIAS "GetIpAddrTable" ( BYREF pIpAddrTable AS MIB_IPADDRTABLE , BYREF pdwSize AS QUAD , BYVAL bOrder AS LONG ) AS QUAD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Gets the current IP Address to Physical Address (ARP) mapping //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION GetIpNetTable LIB "iphlpapi.dll" ALIAS "GetIpNetTable" ( BYREF pIpNetTable AS MIB_IPNETTABLE , BYREF pdwSize AS QUAD , BYVAL bOrder AS LONG ) AS QUAD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Gets the IP Routing Table (RFX XXXX) //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION GetIpForwardTable LIB "iphlpapi.dll" ALIAS "GetIpForwardTable" ( BYREF pIpForwardTable AS MIB_IPFORWARDTABLE , BYREF pdwSize AS QUAD , BYVAL bOrder AS LONG ) AS QUAD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Gets TCP Connection/UDP Listener Table //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION GetTcpTable LIB "iphlpapi.dll" ALIAS "GetTcpTable" ( BYREF pTcpTable AS MIB_TCPTABLE , BYREF pdwSize AS QUAD , BYVAL bOrder AS LONG ) AS QUAD ' ULONG
DECLARE FUNCTION GetExtendedTcpTable LIB "iphlpapi.dll" ALIAS "GetExtendedTcpTable" ( BYREF pTcpTable AS ANY , BYREF pdwSize AS QUAD , BYVAL bOrder AS LONG , BYVAL ulAf AS QUAD , BYVAL TableClass AS LONG , BYVAL Reserved AS LONG ) AS QUAD
DECLARE FUNCTION GetOwnerModuleFromTcpEntry LIB "iphlpapi.dll" ALIAS "GetOwnerModuleFromTcpEntry" ( BYREF pTcpEntry AS MIB_TCPROW_OWNER_MODULE
 , BYVAL Class AS LONG
 , BYREF pBuffer AS ANY
 , BYREF pdwSize AS DWORD
 ) AS DWORD
DECLARE FUNCTION GetUdpTable LIB "iphlpapi.dll" ALIAS "GetUdpTable" ( BYREF pUdpTable AS MIB_UDPTABLE
 , BYREF pdwSize AS DWORD
 , BYVAL bOrder AS LONG
 ) AS DWORD ' ULONG
DECLARE FUNCTION GetExtendedUdpTable LIB "iphlpapi.dll" ALIAS "GetExtendedUdpTable" ( BYREF pUdpTable AS ANY , BYREF pdwSize AS QUAD , BYVAL bOrder AS LONG , BYVAL ulAf AS QUAD , BYVAL TableClass AS LONG , BYVAL Reserved AS QUAD ) AS QUAD
DECLARE FUNCTION GetOwnerModuleFromUdpEntry LIB "iphlpapi.dll" ALIAS "GetOwnerModuleFromUdpEntry" ( BYREF pUdpEntry AS MIB_UDPROW_OWNER_MODULE
 , BYVAL Class AS LONG
 , BYREF pBuffer AS ANY
 , BYREF pdwSize AS DWORD
 ) AS DWORD
'#if (NTDDI_VERSION >= NTDDI_VISTA)
DECLARE FUNCTION GetTcpTable2 LIB "iphlpapi.dll" ALIAS "GetTcpTable2" ( BYREF pTcpTable AS MIB_TCPTABLE2 , BYREF SizePointer AS QUAD , BYVAL bOrder AS LONG ) AS QUAD ' ULONG
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'#if (NTDDI_VERSION < NTDDI_VISTA)
'//
'// Deprecated APIs, Added for documentation.
'//
'DECLARE FUNCTION AllocateAndGetTcpExTableFromStack LIB "iphlpapi.dll" ALIAS "AllocateAndGetTcpExTableFromStack" ( ' BYREF ppTcpTable AS ANY
' , BYVAL bOrder AS LONG
' , BYVAL hHeap AS DWORD
' , BYVAL dwFlags AS DWORD
' , BYVAL dwFamily AS DWORD
' ) AS DWORD
'DECLARE FUNCTION AllocateAndGetUdpExTableFromStack LIB "iphlpapi.dll" ALIAS "AllocateAndGetUdpExTableFromStack" ( ' BYREF ppUdpTable AS ANY
' , BYVAL bOrder AS LONG
' , BYVAL hHeap AS DWORD
' , BYVAL dwFlags AS DWORD
' , BYVAL dwFamily AS DWORD
' ) AS DWORD
'#endif // (NTDDI_VERSION < NTDDI_VISTA)
#IF %DEF(%WS2IPDEF_INC)
'//
'// The following definitions require Winsock2.
'//
'#if (NTDDI_VERSION >= NTDDI_VISTA)
DECLARE FUNCTION GetTcp6Table LIB "iphlpapi.dll" ALIAS "GetTcp6Table" ( BYREF TcpTable AS MIB_TCP6TABLE , BYREF SizePointer AS QUAD , BYVAL bOrder AS LONG ) AS QUAD ' ULONG
DECLARE FUNCTION GetTcp6Table2 LIB "iphlpapi.dll" ALIAS "GetTcp6Table2" ( BYREF TcpTable AS MIB_TCP6TABLE2 , BYREF SizePointer AS QUAD , BYVAL bOrder AS LONG ) AS QUAD ' ULONG
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
'#ifdef WINAPI
DECLARE FUNCTION GetPerTcpConnectionEStats LIB "iphlpapi.dll" ALIAS "GetPerTcpConnectionEStats" ( BYREF Row AS MIB_TCPROW , BYVAL EstatsType AS LONG , BYVAL Rw AS QUAD , BYVAL RwVersion AS QUAD , BYVAL RwSize AS QUAD , BYVAL Ros AS QUAD , BYVAL RosVersion AS QUAD , BYVAL RosSize AS QUAD , BYVAL Rod AS QUAD , BYVAL RodVersion AS QUAD , BYVAL RodSize AS QUAD ) AS QUAD ' ULONG
DECLARE FUNCTION SetPerTcpConnectionEStats LIB "iphlpapi.dll" ALIAS "SetPerTcpConnectionEStats" ( BYREF Row AS MIB_TCPROW , BYVAL EstatsType AS LONG , BYVAL Rw AS QUAD , BYVAL RwVersion AS QUAD , BYVAL RwSize AS QUAD , BYVAL Offset AS QUAD ) AS QUAD ' ULONG
'#ifdef _WS2IPDEF_
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetPerTcp6ConnectionEStats LIB "IpHlpApi.dll" ALIAS "GetPerTcp6ConnectionEStats" (Row AS MIB_TCP6ROW, BYVAL EstatsType AS LONG, Rw AS BYTE, BYVAL RwVersion AS QUAD, BYVAL RwSize AS QUAD, Ros AS BYTE, BYVAL RosVersion AS QUAD, BYVAL RosSize AS QUAD, Rod AS BYTE, BYVAL RodVersion AS QUAD, BYVAL RodSize AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION GetPerTcp6ConnectionEStats LIB "iphlpapi.dll" ALIAS "GetPerTcp6ConnectionEStats" ( BYREF Row AS MIB_TCP6ROW , BYVAL EstatsType AS LONG , BYREF Rw AS ANY , BYVAL RwVersion AS QUAD , BYVAL RwSize AS QUAD , BYREF Ros AS ANY , BYVAL RosVersion AS QUAD , BYVAL RosSize AS QUAD , BYREF Rod AS ANY , BYVAL RodVersion AS QUAD , BYVAL RodSize AS QUAD ) AS QUAD ' ULONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetPerTcp6ConnectionEStats LIB "IpHlpApi.dll" ALIAS "SetPerTcp6ConnectionEStats" (Row AS MIB_TCP6ROW, BYVAL EstatsType AS LONG, Rw AS BYTE, BYVAL RwVersion AS QUAD, BYVAL RwSize AS QUAD, BYVAL Offset AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION SetPerTcp6ConnectionEStats LIB "iphlpapi.dll" ALIAS "SetPerTcp6ConnectionEStats" ( BYREF Row AS MIB_TCP6ROW , BYVAL EstatsType AS LONG , BYREF Rw AS ANY , BYVAL RwVersion AS QUAD , BYVAL RwSize AS QUAD , BYVAL Offset AS QUAD ) AS QUAD ' ULONG
#ENDIF
'#endif // _WS2IPDEF_
'#endif // WINAPI
DECLARE FUNCTION GetOwnerModuleFromTcp6Entry LIB "iphlpapi.dll" ALIAS "GetOwnerModuleFromTcp6Entry" ( BYREF pTcpEntry AS MIB_TCP6ROW_OWNER_MODULE , BYVAL Class AS LONG , BYREF pBuffer AS ANY , BYREF pdwSize AS QUAD ) AS QUAD
DECLARE FUNCTION GetUdp6Table LIB "iphlpapi.dll" ALIAS "GetUdp6Table" ( BYREF Udp6Table AS MIB_UDP6TABLE
 , BYREF SizePointer AS DWORD
 , BYVAL Order AS LONG
 ) AS DWORD ' ULONG
DECLARE FUNCTION GetOwnerModuleFromUdp6Entry LIB "iphlpapi.dll" ALIAS "GetOwnerModuleFromUdp6Entry" ( BYREF pUdpEntry AS MIB_UDP6ROW_OWNER_MODULE , BYVAL Class AS LONG , BYREF pBuffer AS ANY , BYREF pdwSize AS QUAD ) AS QUAD ' ULONG
#ENDIF ' // _WS2IPDEF_
' Note: Can't find any documentation about this function
DECLARE FUNCTION GetOwnerModuleFromPidAndInfo LIB "iphlpapi.dll" ALIAS "GetOwnerModuleFromPidAndInfo" ( BYVAL ulPid AS QUAD , BYREF pInfo AS QUAD , BYVAL Class AS LONG , BYREF pBuffer AS ANY , BYREF pdwSize AS QUAD ) AS QUAD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Gets IP/ICMP/TCP/UDP Statistics //
'// //
'//////////////////////////////////////////////////////////////////////////////
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
DECLARE FUNCTION GetIpStatistics LIB "iphlpapi.dll" ALIAS "GetIpStatistics" ( BYREF Statistics AS MIB_IPSTATS ) AS QUAD ' ULONG
DECLARE FUNCTION GetIcmpStatistics LIB "iphlpapi.dll" ALIAS "GetIcmpStatistics" ( BYREF Statistics AS MIB_ICMP ) AS QUAD ' ULONG
DECLARE FUNCTION GetTcpStatistics LIB "iphlpapi.dll" ALIAS "GetTcpStatistics" ( BYREF Statistics AS MIB_TCPSTATS ) AS QUAD ' ULONG
DECLARE FUNCTION GetUdpStatistics LIB "iphlpapi.dll" ALIAS "GetUdpStatistics" ( BYREF Stats AS MIB_UDPSTATS ) AS QUAD ' ULONG
'#endif
'#if (NTDDI_VERSION >= NTDDI_XP)
DECLARE FUNCTION GetIpStatisticsEx LIB "iphlpapi.dll" ALIAS "GetIpStatisticsEx" ( BYREF Statistics AS MIB_IPSTATS , BYVAL Family AS QUAD ) AS QUAD ' ULONG
DECLARE FUNCTION SetIpStatisticsEx LIB "iphlpapi.dll" ALIAS "SetIpStatisticsEx" ( BYREF Statistics AS MIB_IPSTATS , BYVAL Family AS QUAD ) AS QUAD ' ULONG
DECLARE FUNCTION GetIcmpStatisticsEx LIB "iphlpapi.dll" ALIAS "GetIcmpStatisticsEx" ( BYREF Statistics AS MIB_ICMP_EX , BYVAL Family AS QUAD ) AS QUAD ' ULONG
DECLARE FUNCTION GetTcpStatisticsEx LIB "iphlpapi.dll" ALIAS "GetTcpStatisticsEx" ( BYREF Statistics AS MIB_TCPSTATS , BYVAL Family AS QUAD ) AS QUAD ' ULONG
DECLARE FUNCTION GetUdpStatisticsEx LIB "iphlpapi.dll" ALIAS "GetUdpStatisticsEx" ( BYREF Statistics AS MIB_UDPSTATS , BYVAL Family AS QUAD ) AS QUAD ' ULONG
'#endif
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Used to set the ifAdminStatus on an interface. The only fields of the //
'// MIB_IFROW that are relevant are the dwIndex (index of the interface //
'// whose status needs to be set) and the dwAdminStatus which can be either //
'// MIB_IF_ADMIN_STATUS_UP or MIB_IF_ADMIN_STATUS_DOWN //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION SetIfEntry LIB "iphlpapi.dll" ALIAS "SetIfEntry" ( BYREF pIfRow AS MIB_IFROW ) AS QUAD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Used to create, modify or delete a route. In all cases the //
'// dwForwardIfIndex, dwForwardDest, dwForwardMask, dwForwardNextHop and //
'// dwForwardPolicy MUST BE SPECIFIED. Currently dwForwardPolicy is unused //
'// and MUST BE 0. //
'// For a set, the complete MIB_IPFORWARDROW structure must be specified //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION CreateIpForwardEntry LIB "iphlpapi.dll" ALIAS "CreateIpForwardEntry" ( BYREF pRoute AS MIB_IPFORWARDROW ) AS QUAD
DECLARE FUNCTION SetIpForwardEntry LIB "iphlpapi.dll" ALIAS "SetIpForwardEntry" ( BYREF pRoute AS MIB_IPFORWARDROW
 ) AS DWORD
DECLARE FUNCTION DeleteIpForwardEntry LIB "iphlpapi.dll" ALIAS "DeleteIpForwardEntry" ( BYREF pRoute AS MIB_IPFORWARDROW
 ) AS DWORD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Used to set the ipForwarding to ON or OFF (currently only ON->OFF is //
'// allowed) and to set the defaultTTL. If only one of the fields needs to //
'// be modified and the other needs to be the same as before the other field //
'// needs to be set to MIB_USE_CURRENT_TTL or MIB_USE_CURRENT_FORWARDING as //
'// the case may be //
'// //
'//////////////////////////////////////////////////////////////////////////////
'#if (NTDDI_VERSION >= NTDDI_WIN2K)
DECLARE FUNCTION SetIpStatistics LIB "iphlpapi.dll" ALIAS "SetIpStatistics" ( BYREF pIpStats AS MIB_IPSTATS ) AS QUAD
'#endif
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Used to set the defaultTTL. //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION SetIpTTL LIB "iphlpapi.dll" ALIAS "SetIpTTL" ( BYVAL nTTL AS QUAD ) AS QUAD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Used to create, modify or delete an ARP entry. In all cases the dwIndex //
'// dwAddr field MUST BE SPECIFIED. //
'// For a set, the complete MIB_IPNETROW structure must be specified //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION CreateIpNetEntry LIB "iphlpapi.dll" ALIAS "CreateIpNetEntry" ( BYREF pArpEntry AS MIB_IPNETROW ) AS QUAD
DECLARE FUNCTION SetIpNetEntry LIB "iphlpapi.dll" ALIAS "SetIpNetEntry" ( BYREF pArpEntry AS MIB_IPNETROW
 ) AS DWORD
DECLARE FUNCTION DeleteIpNetEntry LIB "iphlpapi.dll" ALIAS "DeleteIpNetEntry" ( BYREF pArpEntry AS MIB_IPNETROW
 ) AS DWORD
DECLARE FUNCTION FlushIpNetTable LIB "iphlpapi.dll" ALIAS "FlushIpNetTable" ( BYVAL dwIfIndex AS DWORD
 ) AS DWORD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Used to create or delete a Proxy ARP entry. The dwIndex is the index of //
'// the interface on which to PARP for the dwAddress. If the interface is //
'// of a type that doesnt support ARP, e.g. PPP, then the call will fail //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION CreateProxyArpEntry LIB "iphlpapi.dll" ALIAS "CreateProxyArpEntry" ( BYVAL dwAddress AS QUAD , BYVAL dwMask AS QUAD , BYVAL dwIfIndex AS QUAD ) AS QUAD
DECLARE FUNCTION DeleteProxyArpEntry LIB "iphlpapi.dll" ALIAS "DeleteProxyArpEntry" ( BYVAL dwAddress AS QUAD
 , BYVAL dwMask AS DWORD
 , BYVAL dwIfIndex AS DWORD
 ) AS DWORD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Used to set the state of a TCP Connection. The only state that it can be //
'// set to is MIB_TCP_STATE_DELETE_TCB. The complete MIB_TCPROW structure //
'// MUST BE SPECIFIED //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION SetTcpEntry LIB "iphlpapi.dll" ALIAS "SetTcpEntry" ( BYREF pTcpRow AS MIB_TCPROW ) AS QUAD
DECLARE FUNCTION GetInterfaceInfo LIB "iphlpapi.dll" ALIAS "GetInterfaceInfo" ( BYREF pIfTable AS IP_INTERFACE_INFO
 , BYREF dwOutBufLen AS DWORD
 ) AS DWORD
DECLARE FUNCTION GetUniDirectionalAdapterInfo LIB "iphlpapi.dll" ALIAS "GetUniDirectionalAdapterInfo" ( BYREF pIPIfInfo AS IP_UNIDIRECTIONAL_ADAPTER_ADDRESS
 , BYREF dwOutBufLen AS DWORD
 ) AS DWORD
'#if (NTDDI_VERSION >= NTDDI_WIN2KSP1)
#IF NOT %DEF(%NhpAllocateAndGetInterfaceInfoFromStack_DEFINED)
 %NhpAllocateAndGetInterfaceInfoFromStack_DEFINED = 1
DECLARE FUNCTION NhpAllocateAndGetInterfaceInfoFromStack LIB "iphlpapi.dll" ALIAS "NhpAllocateAndGetInterfaceInfoFromStack" ( BYREF ppTable AS ANY , BYREF pdwCount AS QUAD , BYVAL bOrder AS LONG , BYVAL hHeap AS QUAD , BYVAL dwFlags AS QUAD ) AS QUAD
#ENDIF
'#endif // (NTDDI_VERSION >= NTDDI_WIN2KSP1)
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Gets the "best" outgoing interface for the specified destination address //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION GetBestInterface LIB "iphlpapi.dll" ALIAS "GetBestInterface" ( BYVAL dwDestAddr AS QUAD , BYREF pdwBestIfIndex AS QUAD ) AS QUAD
DECLARE FUNCTION GetBestInterfaceEx LIB "iphlpapi.dll" ALIAS "GetBestInterfaceEx" ( BYREF pDestAddr AS ANY
 , BYREF pdwBestIfIndex AS DWORD
 ) AS DWORD
'//////////////////////////////////////////////////////////////////////////////
'// //
'// Gets the best (longest matching prefix) route for the given destination //
'// If the source address is also specified (i.e. is not 0x00000000), and //
'// there are multiple "best" routes to the given destination, the returned //
'// route will be one that goes out over the interface which has an address //
'// that matches the source address //
'// //
'//////////////////////////////////////////////////////////////////////////////
DECLARE FUNCTION GetBestRoute LIB "iphlpapi.dll" ALIAS "GetBestRoute" ( BYVAL dwDestAddr AS QUAD , BYVAL dwSourceAddr AS QUAD , BYREF pBestRoute AS MIB_IPFORWARDROW ) AS QUAD
DECLARE FUNCTION NotifyAddrChange LIB "iphlpapi.dll" ALIAS "NotifyAddrChange" ( BYREF Handle AS QUAD
 , BYREF overlapped AS OVERLAPPED
 ) AS DWORD
DECLARE FUNCTION NotifyRouteChange LIB "iphlpapi.dll" ALIAS "NotifyRouteChange" ( BYREF Handle AS DWORD
 , BYREF overlapped AS OVERLAPPED
 ) AS DWORD
DECLARE FUNCTION CancelIPChangeNotify LIB "iphlpapi.dll" ALIAS "CancelIPChangeNotify" ( BYREF notifyOverlapped AS OVERLAPPED
 ) AS LONG
DECLARE FUNCTION GetAdapterIndex LIB "iphlpapi.dll" ALIAS "GetAdapterIndex" ( BYREF AdapterName AS WSTRINGZ
 , BYREF IfIndex AS DWORD
 ) AS DWORD
DECLARE FUNCTION AddIPAddress LIB "iphlpapi.dll" ALIAS "AddIPAddress" ( BYVAL Address AS DWORD
 , BYVAL IpMask AS DWORD
 , BYVAL IfIndex AS DWORD
 , BYREF NTEContext AS DWORD
 , BYREF NTEInstance AS DWORD
 ) AS DWORD
DECLARE FUNCTION DeleteIPAddress LIB "iphlpapi.dll" ALIAS "DeleteIPAddress" ( BYVAL NTEContext AS DWORD
 ) AS DWORD
'#if (NTDDI_VERSION >= NTDDI_WIN2KSP1)
DECLARE FUNCTION GetNetworkParams LIB "iphlpapi.dll" ALIAS "GetNetworkParams" ( BYREF pFixedInfo AS FIXED_INFO , BYREF pOutBufLen AS QUAD ) AS QUAD
'#endif
DECLARE FUNCTION GetAdaptersInfo LIB "iphlpapi.dll" ALIAS "GetAdaptersInfo" ( BYREF pAdapterInfo AS IP_ADAPTER_INFO , BYREF pOutBufLen AS QUAD ) AS QUAD
DECLARE FUNCTION GetAdapterOrderMap LIB "iphlpapi.dll" ALIAS "GetAdapterOrderMap" ( ) AS QUAD ' PIP_ADAPTER_ORDER_MAP
#IF %DEF(%WINSOCK2API)
'//
'// The following functions require Winsock2.
'//
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetAdaptersAddresses LIB "IpHlpApi.dll" ALIAS "GetAdaptersAddresses" (BYVAL Family AS QUAD, BYVAL Flags AS QUAD, Reserved AS ANY, AdapterAddresses AS IP_ADAPTER_ADDRESSES, SizePointer AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION GetAdaptersAddresses LIB "iphlpapi.dll" ALIAS "GetAdaptersAddresses" ( BYVAL Family AS QUAD , BYVAL Flags AS QUAD , BYVAL Reserved AS QUAD , BYREF pAdapterAddresses AS IP_ADAPTER_ADDRESSES , BYREF pOutBufLen AS QUAD ) AS QUAD
#ENDIF
#ENDIF ' WINSOCK2API
'#if (NTDDI_VERSION >= NTDDI_WIN2KSP1)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetPerAdapterInfo LIB "IpHlpApi.dll" ALIAS "GetPerAdapterInfo" (BYVAL IfIndex AS QUAD, BYVAL pPerAdapterInfo AS IP_PER_ADAPTER_INFO PTR, pOutBufLen AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION GetPerAdapterInfo LIB "iphlpapi.dll" ALIAS "GetPerAdapterInfo" ( BYVAL IfIndex AS QUAD , BYREF pPerAdapterInfo AS IP_PER_ADAPTER_INFO , BYREF pOutBufLen AS QUAD ) AS QUAD
 #ENDIF
'#endif
DECLARE FUNCTION IpReleaseAddress LIB "iphlpapi.dll" ALIAS "IpReleaseAddress" ( BYREF AdapterInfo AS IP_ADAPTER_INDEX_MAP ) AS QUAD
DECLARE FUNCTION IpRenewAddress LIB "iphlpapi.dll" ALIAS "IpRenewAddress" ( BYREF AdapterInfo AS IP_ADAPTER_INDEX_MAP
 ) AS DWORD
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SendARP LIB "IpHlpApi.dll" ALIAS "SendARP" (BYVAL DestIP AS QUAD, BYVAL SrcIP AS QUAD, pMacAddr AS ANY, PhyAddrLen AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION SendARP LIB "iphlpapi.dll" ALIAS "SendARP" ( BYVAL DestIP AS QUAD , BYVAL SrcIP AS QUAD , BYREF pMacAddr AS QUAD , BYREF PhyAddrLen AS QUAD ) AS QUAD
#ENDIF
DECLARE FUNCTION GetRTTAndHopCount LIB "iphlpapi.dll" ALIAS "GetRTTAndHopCount" ( BYVAL DestIpAddress AS QUAD , BYREF HopCount AS QUAD , BYVAL MaxHops AS QUAD , BYREF RTT AS QUAD ) AS LONG
DECLARE FUNCTION GetFriendlyIfIndex LIB "iphlpapi.dll" ALIAS "GetFriendlyIfIndex" ( BYVAL IfIndex AS QUAD
 ) AS DWORD
DECLARE FUNCTION EnableRouter LIB "iphlpapi.dll" ALIAS "EnableRouter" ( BYREF pHandle AS DWORD
 , BYREF pOverlapped AS OVERLAPPED
 ) AS DWORD
DECLARE FUNCTION UnenableRouter LIB "iphlpapi.dll" ALIAS "UnenableRouter" ( BYREF pOverlapped AS OVERLAPPED
 , BYREF lpdwEnableCount AS DWORD
 ) AS DWORD
DECLARE FUNCTION DisableMediaSense LIB "iphlpapi.dll" ALIAS "DisableMediaSense" ( BYREF pHandle AS DWORD
 , BYREF pOverlapped AS OVERLAPPED
 ) AS DWORD
DECLARE FUNCTION RestoreMediaSense LIB "iphlpapi.dll" ALIAS "RestoreMediaSense" ( BYREF pOverlapped AS OVERLAPPED
 , BYREF lpdwEnableCount AS DWORD
 ) AS DWORD
'#if (NTDDI_VERSION >= NTDDI_VISTA)
DECLARE FUNCTION GetIpErrorString LIB "iphlpapi.dll" ALIAS "GetIpErrorString" ( BYVAL ErrorCode AS QUAD , BYREF Buffer AS WSTRINGZ , BYREF Size AS QUAD ) AS QUAD
'#ifdef _WS2DEF_
'Note This function is deprecated and not supported. Developers should use the ResolveIpNetEntry2 function.
'DECLARE FUNCTION ResolveNeighbor LIB "iphlpapi.dll" ALIAS "ResolveNeighbor" ( ' BYREF NetworkAddress AS SOCKADDR
' , BYREF PhysicalAddress AS ANY
' , BYREF PhysicalAddressLength AS DWORD
' ) AS DWORD ' ULONG
'#endif
'#endif
'//
'// Port reservation API routines.
'//
DECLARE FUNCTION CreatePersistentTcpPortReservation LIB "iphlpapi.dll" ALIAS "CreatePersistentTcpPortReservation" ( BYVAL StartPort AS WORD , BYVAL NumberOfPorts AS WORD , BYREF Token AS QUAD ) AS QUAD ' ULONG
DECLARE FUNCTION CreatePersistentUdpPortReservation LIB "iphlpapi.dll" ALIAS "CreatePersistentUdpPortReservation" ( BYVAL StartPort AS WORD , BYVAL NumberOfPorts AS WORD , BYREF Token AS QUAD ) AS QUAD ' ULONG
DECLARE FUNCTION DeletePersistentTcpPortReservation LIB "iphlpapi.dll" ALIAS "DeletePersistentTcpPortReservation" ( BYVAL StartPort AS WORD , BYVAL NumberOfPorts AS WORD ) AS QUAD ' ULONG
DECLARE FUNCTION DeletePersistentUdpPortReservation LIB "iphlpapi.dll" ALIAS "DeletePersistentUdpPortReservation" ( BYVAL StartPort AS WORD , BYVAL NumberOfPorts AS WORD ) AS QUAD ' ULONG
DECLARE FUNCTION LookupPersistentTcpPortReservation LIB "iphlpapi.dll" ALIAS "LookupPersistentTcpPortReservation" ( BYVAL StartPort AS WORD , BYVAL NumberOfPorts AS WORD , BYREF Token AS QUAD ) AS QUAD ' ULONG
DECLARE FUNCTION LookupPersistentUdpPortReservation LIB "iphlpapi.dll" ALIAS "LookupPersistentUdpPortReservation" ( BYVAL StartPort AS WORD , BYVAL NumberOfPorts AS WORD , BYREF Token AS QUAD ) AS QUAD ' ULONG
'//
'// Network String parsing API
'//
%EQUATE `NET_STRING_IPV4_ADDRESS = &H00000001
' // The string identifies an IPv4 Host/router using literal address.
' // (port or prefix not allowed)
%EQUATE `NET_STRING_IPV4_SERVICE = &H00000002
' // The string identifies an IPv4 service using literal address.
' // (port required; prefix not allowed)
%EQUATE `NET_STRING_IPV4_NETWORK = &H00000004
' // The string identifies an IPv4 network.
' // (prefix required; port not allowed)
%EQUATE `NET_STRING_IPV6_ADDRESS = &H00000008
' // The string identifies an IPv6 Host/router using literal address.
' // (port or prefix not allowed; scope-id allowed)
%EQUATE `NET_STRING_IPV6_ADDRESS_NO_SCOPE = &H00000010
' // The string identifies an IPv6 Host/router using literal address
' // where the interface context is already known.
' // (port or prefix not allowed; scope-id not allowed)
%EQUATE `NET_STRING_IPV6_SERVICE = &H00000020
' // The string identifies an IPv6 service using literal address.
' // (port required; prefix not allowed; scope-id allowed)
%EQUATE `NET_STRING_IPV6_SERVICE_NO_SCOPE = &H00000040
' // The string identifies an IPv6 service using literal address
' // where the interface context is already known.
' // (port required; prefix not allowed; scope-id not allowed)
%EQUATE `NET_STRING_IPV6_NETWORK = &H00000080
' // The string identifies an IPv6 network.
' // (prefix required; port or scope-id not allowed)
%EQUATE `NET_STRING_NAMED_ADDRESS = &H00000100
' // The string identifies an Internet Host using DNS.
' // (port or prefix or scope-id not allowed)
%EQUATE `NET_STRING_NAMED_SERVICE = &H00000200
' // The string identifies an Internet service using DNS.
' // (port required; prefix or scope-id not allowed)
%EQUATE `NET_STRING_IP_ADDRESS = %NET_STRING_IPV4_ADDRESS OR %NET_STRING_IPV6_ADDRESS
%EQUATE `NET_STRING_IP_ADDRESS_NO_SCOPE = %NET_STRING_IPV4_ADDRESS OR %NET_STRING_IPV6_ADDRESS_NO_SCOPE
%EQUATE `NET_STRING_IP_SERVICE = %NET_STRING_IPV4_SERVICE OR %NET_STRING_IPV6_SERVICE
%EQUATE `NET_STRING_IP_SERVICE_NO_SCOPE = %NET_STRING_IPV4_SERVICE OR %NET_STRING_IPV6_SERVICE_NO_SCOPE
%EQUATE `NET_STRING_IP_NETWORK = %NET_STRING_IPV4_NETWORK OR %NET_STRING_IPV6_NETWORK
%EQUATE `NET_STRING_ANY_ADDRESS = %NET_STRING_NAMED_ADDRESS OR %NET_STRING_IP_ADDRESS
%EQUATE `NET_STRING_ANY_ADDRESS_NO_SCOPE = %NET_STRING_NAMED_ADDRESS OR %NET_STRING_IP_ADDRESS_NO_SCOPE
%EQUATE `NET_STRING_ANY_SERVICE = %NET_STRING_NAMED_SERVICE OR %NET_STRING_IP_SERVICE
%EQUATE `NET_STRING_ANY_SERVICE_NO_SCOPE = %NET_STRING_NAMED_SERVICE OR %NET_STRING_IP_SERVICE_NO_SCOPE
' enum NET_ADDRESS_FORMAT
%EQUATE `NET_ADDRESS_FORMAT_UNSPECIFIED = 0
%EQUATE `NET_ADDRESS_DNS_NAME = 1
%EQUATE `NET_ADDRESS_IPV4 = 2
%EQUATE `NET_ADDRESS_IPV6 = 3
'#if defined (_WS2DEF_) && defined (_WS2IPDEF_) && defined(_WINDNS_INCLUDED_)
' // app must include winsock2.h, ws2ipdef.h, and windns.h to use this API
#IF %DEF(%WS2DEF_INC)
#IF %DEF(%WS2IPDEF_INC)
#IF %DEF(%WINDNS_INC)
' // Size = 524 bytes
TYPE NET_ADDRESS_INFO_NamedAddress DWORD
 Address AS WSTRINGZ * %DNS_MAX_NAME_BUFFER_LENGTH ' WCHAR
 Port(5) AS WORD ' WCHAR[6]
END TYPE
' // Size = 524 bytes
UNION NET_ADDRESS_INFO_UNION
 NET_ADDRESS_INFO_NamedAddress
 Ipv4Address AS SOCKADDR_IN
 Ipv6Address AS SOCKADDR_IN6
 IpAddress AS SOCKADDR
END UNION
' // Size = 528 bytes
TYPE NET_ADDRESS_INFO DWORD
 Format AS LONG ' NET_ADDRESS_FORMAT
 NET_ADDRESS_INFO_UNION
END TYPE
DECLARE FUNCTION ParseNetworkString LIB "iphlpapi.dll" ALIAS "ParseNetworkString" ( BYREF NetworkString AS WSTRINGZ , BYVAL Types AS QUAD , BYREF AddressInfo AS NET_ADDRESS_INFO , BYREF PortNumber AS WORD , BYREF PrefixLength AS BYTE ) AS QUAD
#ENDIF ' WS2DEF_INC
#ENDIF ' WS2IPDEF_INC
#ENDIF ' WINDNS_INC
'#endif
#INCLUDE ONCE "Legacy/Network/netioapi.inc"
'#endif // (NTDDI_VERSION >= NTDDI_VISTA)
#ENDIF
