2 * iphlpapi dll implementation
4 * Copyright (C) 2003 Juan Lang
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "iphlpapi_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi
);
28 typedef struct _NAME_SERVER_LIST_CONTEXT
{
31 PIP_PER_ADAPTER_INFO pData
;
33 IP_ADDR_STRING
*pLastAddr
;
34 } NAME_SERVER_LIST_CONTEXT
, *PNAME_SERVER_LIST_CONTEXT
;
36 BOOL WINAPI
DllMain (HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
41 case DLL_PROCESS_ATTACH
:
42 DisableThreadLibraryCalls( hinstDLL
);
44 WSAStartup(MAKEWORD(2, 2), &wsaData
);
47 case DLL_PROCESS_DETACH
:
55 /******************************************************************
56 * AddIPAddress (IPHLPAPI.@)
65 * NTEInstance [In/Out]
72 DWORD WINAPI
AddIPAddress(IPAddr Address
, IPMask Netmask
, DWORD IfIndex
, PULONG NteContext
, PULONG NteInstance
)
74 return RtlNtStatusToDosError(addIPAddress(Address
, Netmask
, IfIndex
, NteContext
, NteInstance
));
77 DWORD
getInterfaceGatewayByIndex(DWORD index
)
79 DWORD ndx
, retVal
= 0, numRoutes
= getNumRoutes();
80 RouteTable
*table
= getRouteTable();
83 for (ndx
= 0; ndx
< numRoutes
; ndx
++)
85 if ((table
->routes
[ndx
].ifIndex
== (index
)) && (table
->routes
[ndx
].dest
== 0))
86 retVal
= table
->routes
[ndx
].gateway
;
88 HeapFree(GetProcessHeap(), 0, table
);
92 /******************************************************************
93 * AllocateAndGetIfTableFromStack (IPHLPAPI.@)
98 * ppIfTable [Out] -- pointer into which the MIB_IFTABLE is
99 * allocated and returned.
100 * bOrder [In] -- passed to GetIfTable to order the table
101 * heap [In] -- heap from which the table is allocated
102 * flags [In] -- flags to HeapAlloc
104 * RETURNS -- ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
105 * GetIfTable returns otherwise
108 DWORD WINAPI
AllocateAndGetIfTableFromStack(PMIB_IFTABLE
*ppIfTable
,
109 BOOL bOrder
, HANDLE heap
, DWORD flags
)
113 TRACE("ppIfTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n", ppIfTable
,
114 (DWORD
)bOrder
, (DWORD
)heap
, flags
);
116 ret
= ERROR_INVALID_PARAMETER
;
121 ret
= GetIfTable(*ppIfTable
, &dwSize
, bOrder
);
122 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
123 *ppIfTable
= (PMIB_IFTABLE
)HeapAlloc(heap
, flags
, dwSize
);
124 ret
= GetIfTable(*ppIfTable
, &dwSize
, bOrder
);
125 if (ret
!= NO_ERROR
) {
126 HeapFree(heap
, flags
, *ppIfTable
);
131 TRACE("returning %ld\n", ret
);
136 /******************************************************************
137 * AllocateAndGetIpAddrTableFromStack (IPHLPAPI.@)
142 * ppIpAddrTable [Out]
143 * bOrder [In] -- passed to GetIpAddrTable to order the table
144 * heap [In] -- heap from which the table is allocated
145 * flags [In] -- flags to HeapAlloc
152 DWORD WINAPI
AllocateAndGetIpAddrTableFromStack(PMIB_IPADDRTABLE
*ppIpAddrTable
,
153 BOOL bOrder
, HANDLE heap
, DWORD flags
)
157 TRACE("ppIpAddrTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
158 ppIpAddrTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
160 ret
= ERROR_INVALID_PARAMETER
;
164 *ppIpAddrTable
= NULL
;
165 ret
= GetIpAddrTable(*ppIpAddrTable
, &dwSize
, bOrder
);
166 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
167 *ppIpAddrTable
= (PMIB_IPADDRTABLE
)HeapAlloc(heap
, flags
, dwSize
);
168 ret
= GetIpAddrTable(*ppIpAddrTable
, &dwSize
, bOrder
);
169 if (ret
!= NO_ERROR
) {
170 HeapFree(heap
, flags
, *ppIpAddrTable
);
171 *ppIpAddrTable
= NULL
;
175 TRACE("returning %ld\n", ret
);
180 /******************************************************************
181 * AllocateAndGetIpForwardTableFromStack (IPHLPAPI.@)
184 * ppIpForwardTable [Out] -- pointer into which the MIB_IPFORWARDTABLE is
185 * allocated and returned.
186 * bOrder [In] -- passed to GetIfTable to order the table
187 * heap [In] -- heap from which the table is allocated
188 * flags [In] -- flags to HeapAlloc
190 * RETURNS -- ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
191 * GetIpForwardTable returns otherwise
194 DWORD WINAPI
AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE
*
195 ppIpForwardTable
, BOOL bOrder
, HANDLE heap
, DWORD flags
)
199 TRACE("ppIpForwardTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
200 ppIpForwardTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
201 if (!ppIpForwardTable
)
202 ret
= ERROR_INVALID_PARAMETER
;
206 *ppIpForwardTable
= NULL
;
207 ret
= GetIpForwardTable(*ppIpForwardTable
, &dwSize
, bOrder
);
208 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
209 *ppIpForwardTable
= (PMIB_IPFORWARDTABLE
)HeapAlloc(heap
, flags
, dwSize
);
210 ret
= GetIpForwardTable(*ppIpForwardTable
, &dwSize
, bOrder
);
211 if (ret
!= NO_ERROR
) {
212 HeapFree(heap
, flags
, *ppIpForwardTable
);
213 *ppIpForwardTable
= NULL
;
217 TRACE("returning %ld\n", ret
);
222 /******************************************************************
223 * AllocateAndGetIpNetTableFromStack (IPHLPAPI.@)
229 * bOrder [In] -- passed to GetIpNetTable to order the table
230 * heap [In] -- heap from which the table is allocated
231 * flags [In] -- flags to HeapAlloc
238 DWORD WINAPI
AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE
*ppIpNetTable
,
239 BOOL bOrder
, HANDLE heap
, DWORD flags
)
243 TRACE("ppIpNetTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
244 ppIpNetTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
246 ret
= ERROR_INVALID_PARAMETER
;
250 *ppIpNetTable
= NULL
;
251 ret
= GetIpNetTable(*ppIpNetTable
, &dwSize
, bOrder
);
252 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
253 *ppIpNetTable
= (PMIB_IPNETTABLE
)HeapAlloc(heap
, flags
, dwSize
);
254 ret
= GetIpNetTable(*ppIpNetTable
, &dwSize
, bOrder
);
255 if (ret
!= NO_ERROR
) {
256 HeapFree(heap
, flags
, *ppIpNetTable
);
257 *ppIpNetTable
= NULL
;
261 TRACE("returning %ld\n", ret
);
266 /******************************************************************
267 * AllocateAndGetTcpTableFromStack (IPHLPAPI.@)
273 * bOrder [In] -- passed to GetTcpTable to order the table
274 * heap [In] -- heap from which the table is allocated
275 * flags [In] -- flags to HeapAlloc
282 DWORD WINAPI
AllocateAndGetTcpTableFromStack(PMIB_TCPTABLE
*ppTcpTable
,
283 BOOL bOrder
, HANDLE heap
, DWORD flags
)
287 TRACE("ppTcpTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
288 ppTcpTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
290 ret
= ERROR_INVALID_PARAMETER
;
295 ret
= GetTcpTable(*ppTcpTable
, &dwSize
, bOrder
);
296 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
297 *ppTcpTable
= (PMIB_TCPTABLE
)HeapAlloc(heap
, flags
, dwSize
);
298 ret
= GetTcpTable(*ppTcpTable
, &dwSize
, bOrder
);
299 if (ret
!= NO_ERROR
) {
300 HeapFree(heap
, flags
, *ppTcpTable
);
305 TRACE("returning %ld\n", ret
);
310 /******************************************************************
311 * AllocateAndGetUdpTableFromStack (IPHLPAPI.@)
317 * bOrder [In] -- passed to GetUdpTable to order the table
318 * heap [In] -- heap from which the table is allocated
319 * flags [In] -- flags to HeapAlloc
326 DWORD WINAPI
AllocateAndGetUdpTableFromStack(PMIB_UDPTABLE
*ppUdpTable
,
327 BOOL bOrder
, HANDLE heap
, DWORD flags
)
331 TRACE("ppUdpTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
332 ppUdpTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
334 ret
= ERROR_INVALID_PARAMETER
;
339 ret
= GetUdpTable(*ppUdpTable
, &dwSize
, bOrder
);
340 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
341 *ppUdpTable
= (PMIB_UDPTABLE
)HeapAlloc(heap
, flags
, dwSize
);
342 ret
= GetUdpTable(*ppUdpTable
, &dwSize
, bOrder
);
343 if (ret
!= NO_ERROR
) {
344 HeapFree(heap
, flags
, *ppUdpTable
);
349 TRACE("returning %ld\n", ret
);
354 /******************************************************************
355 * CreateIpForwardEntry (IPHLPAPI.@)
367 DWORD WINAPI
CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
369 return createIpForwardEntry( pRoute
);
373 /******************************************************************
374 * CreateIpNetEntry (IPHLPAPI.@)
386 DWORD WINAPI
CreateIpNetEntry(PMIB_IPNETROW pArpEntry
)
388 TRACE("pArpEntry %p\n", pArpEntry
);
389 /* could use SIOCSARP on systems that support it, not sure I want to */
395 /******************************************************************
396 * CreateProxyArpEntry (IPHLPAPI.@)
410 DWORD WINAPI
CreateProxyArpEntry(DWORD dwAddress
, DWORD dwMask
, DWORD dwIfIndex
)
412 TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress
,
415 /* marking Win2K+ functions not supported */
416 return ERROR_NOT_SUPPORTED
;
420 /******************************************************************
421 * DeleteIPAddress (IPHLPAPI.@)
433 DWORD WINAPI
DeleteIPAddress(ULONG NTEContext
)
435 TRACE("NTEContext %ld\n", NTEContext
);
436 return RtlNtStatusToDosError(deleteIpAddress(NTEContext
));
440 /******************************************************************
441 * DeleteIpForwardEntry (IPHLPAPI.@)
453 DWORD WINAPI
DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
455 return deleteIpForwardEntry( pRoute
);
459 /******************************************************************
460 * DeleteIpNetEntry (IPHLPAPI.@)
472 DWORD WINAPI
DeleteIpNetEntry(PMIB_IPNETROW pArpEntry
)
474 TRACE("pArpEntry %p\n", pArpEntry
);
475 /* could use SIOCDARP on systems that support it, not sure I want to */
481 /******************************************************************
482 * DeleteProxyArpEntry (IPHLPAPI.@)
496 DWORD WINAPI
DeleteProxyArpEntry(DWORD dwAddress
, DWORD dwMask
, DWORD dwIfIndex
)
498 TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress
,
501 /* marking Win2K+ functions not supported */
502 return ERROR_NOT_SUPPORTED
;
505 /******************************************************************
506 * EnableRouter (IPHLPAPI.@)
512 * pOverlapped [In/Out]
519 DWORD WINAPI
EnableRouter(HANDLE
* pHandle
, OVERLAPPED
* pOverlapped
)
521 TRACE("pHandle %p, pOverlapped %p\n", pHandle
, pOverlapped
);
523 /* could echo "1" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
524 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
525 marking Win2K+ functions not supported */
526 return ERROR_NOT_SUPPORTED
;
530 /******************************************************************
531 * FlushIpNetTable (IPHLPAPI.@)
543 DWORD WINAPI
FlushIpNetTable(DWORD dwIfIndex
)
545 TRACE("dwIfIndex 0x%08lx\n", dwIfIndex
);
547 /* this flushes the arp cache of the given index
548 marking Win2K+ functions not supported */
549 return ERROR_NOT_SUPPORTED
;
553 /******************************************************************
554 * GetAdapterIndex (IPHLPAPI.@)
559 * AdapterName [In/Out]
567 DWORD WINAPI
GetAdapterIndex(LPWSTR AdapterName
, PULONG IfIndex
)
569 TRACE("AdapterName %p, IfIndex %p\n", AdapterName
, IfIndex
);
571 /* marking Win2K+ functions not supported */
572 return ERROR_NOT_SUPPORTED
;
576 /******************************************************************
577 * GetAdaptersInfo (IPHLPAPI.@)
582 * pAdapterInfo [In/Out]
583 * pOutBufLen [In/Out]
590 DWORD WINAPI
GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo
, PULONG pOutBufLen
)
596 TRACE("pAdapterInfo %p, pOutBufLen %p\n", pAdapterInfo
, pOutBufLen
);
598 ret
= ERROR_INVALID_PARAMETER
;
600 DWORD numNonLoopbackInterfaces
= getNumNonLoopbackInterfaces();
602 if (numNonLoopbackInterfaces
> 0) {
603 /* this calculation assumes only one address in the IP_ADDR_STRING lists.
604 that's okay, because:
605 - we don't get multiple addresses per adapter anyway
606 - we don't know about per-adapter gateways
607 - DHCP and WINS servers can have max one entry per list */
608 ULONG size
= sizeof(IP_ADAPTER_INFO
) * numNonLoopbackInterfaces
;
610 if (!pAdapterInfo
|| *pOutBufLen
< size
) {
612 ret
= ERROR_BUFFER_OVERFLOW
;
615 InterfaceIndexTable
*table
= getNonLoopbackInterfaceIndexTable();
618 size
= sizeof(IP_ADAPTER_INFO
) * table
->numIndexes
;
619 if (*pOutBufLen
< size
) {
621 ret
= ERROR_INSUFFICIENT_BUFFER
;
626 BOOL winsEnabled
= FALSE
;
627 IP_ADDRESS_STRING primaryWINS
, secondaryWINS
;
629 memset(pAdapterInfo
, 0, size
);
630 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
631 "Software\\Wine\\Wine\\Config\\Network", 0, KEY_READ
,
632 &hKey
) == ERROR_SUCCESS
) {
633 DWORD size
= sizeof(primaryWINS
.String
);
636 RegQueryValueExA(hKey
, "WinsServer", NULL
, NULL
,
637 (PBYTE
)primaryWINS
.String
, &size
);
638 addr
= inet_addr(primaryWINS
.String
);
639 if (addr
!= INADDR_NONE
&& addr
!= INADDR_ANY
)
641 size
= sizeof(secondaryWINS
.String
);
642 RegQueryValueExA(hKey
, "BackupWinsServer", NULL
, NULL
,
643 (PBYTE
)secondaryWINS
.String
, &size
);
644 addr
= inet_addr(secondaryWINS
.String
);
645 if (addr
!= INADDR_NONE
&& addr
!= INADDR_ANY
)
649 TRACE("num of index is %lu\n", table
->numIndexes
);
650 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
651 PIP_ADAPTER_INFO ptr
= &pAdapterInfo
[ndx
];
652 DWORD addrLen
= sizeof(ptr
->Address
), type
;
654 getInterfaceNameByIndex(table
->indexes
[ndx
]);
656 ret
= ERROR_OUTOFMEMORY
;
660 /* on Win98 this is left empty, but whatever */
661 strncpy(ptr
->AdapterName
,ifname
,sizeof(ptr
->AdapterName
));
662 consumeInterfaceName(ifname
);
663 ptr
->AdapterName
[MAX_ADAPTER_NAME_LENGTH
] = '\0';
664 getInterfacePhysicalByIndex(table
->indexes
[ndx
], &addrLen
,
665 ptr
->Address
, &type
);
666 /* MS defines address length and type as UINT in some places and
667 DWORD in others, **sigh**. Don't want to assume that PUINT and
668 PDWORD are equiv (64-bit?) */
669 ptr
->AddressLength
= addrLen
;
671 ptr
->Index
= table
->indexes
[ndx
];
672 toIPAddressString(getInterfaceIPAddrByIndex(table
->indexes
[ndx
]),
673 ptr
->IpAddressList
.IpAddress
.String
);
674 toIPAddressString(getInterfaceMaskByIndex(table
->indexes
[ndx
]),
675 ptr
->IpAddressList
.IpMask
.String
);
676 ptr
->IpAddressList
.Context
= ptr
->Index
;
677 toIPAddressString(getInterfaceGatewayByIndex(table
->indexes
[ndx
]),
678 ptr
->GatewayList
.IpAddress
.String
);
679 getDhcpInfoForAdapter(table
->indexes
[ndx
], &dhcpEnabled
,
680 &dhcpServer
, &ptr
->LeaseObtained
,
682 ptr
->DhcpEnabled
= (DWORD
) dhcpEnabled
;
683 toIPAddressString(dhcpServer
,
684 ptr
->DhcpServer
.IpAddress
.String
);
686 ptr
->HaveWins
= TRUE
;
687 memcpy(ptr
->PrimaryWinsServer
.IpAddress
.String
,
688 primaryWINS
.String
, sizeof(primaryWINS
.String
));
689 memcpy(ptr
->SecondaryWinsServer
.IpAddress
.String
,
690 secondaryWINS
.String
, sizeof(secondaryWINS
.String
));
692 if (ndx
< table
->numIndexes
- 1)
693 ptr
->Next
= &pAdapterInfo
[ndx
+ 1];
702 ret
= ERROR_OUTOFMEMORY
;
708 TRACE("returning %ld\n", ret
);
713 /******************************************************************
714 * GetBestInterface (IPHLPAPI.@)
720 * pdwBestIfIndex [In/Out]
727 DWORD WINAPI
GetBestInterface(IPAddr dwDestAddr
, PDWORD pdwBestIfIndex
)
731 TRACE("dwDestAddr 0x%08lx, pdwBestIfIndex %p\n", dwDestAddr
, pdwBestIfIndex
);
733 ret
= ERROR_INVALID_PARAMETER
;
735 MIB_IPFORWARDROW ipRow
;
737 ret
= GetBestRoute(dwDestAddr
, 0, &ipRow
);
738 if (ret
== ERROR_SUCCESS
)
739 *pdwBestIfIndex
= ipRow
.dwForwardIfIndex
;
741 TRACE("returning %ld\n", ret
);
746 /******************************************************************
747 * GetBestRoute (IPHLPAPI.@)
761 DWORD WINAPI
GetBestRoute(DWORD dwDestAddr
, DWORD dwSourceAddr
, PMIB_IPFORWARDROW pBestRoute
)
763 PMIB_IPFORWARDTABLE table
;
766 TRACE("dwDestAddr 0x%08lx, dwSourceAddr 0x%08lx, pBestRoute %p\n", dwDestAddr
,
767 dwSourceAddr
, pBestRoute
);
769 return ERROR_INVALID_PARAMETER
;
771 AllocateAndGetIpForwardTableFromStack(&table
, FALSE
, GetProcessHeap(), 0);
773 DWORD ndx
, matchedBits
, matchedNdx
= 0;
775 for (ndx
= 0, matchedBits
= 0; ndx
< table
->dwNumEntries
; ndx
++) {
776 if ((dwDestAddr
& table
->table
[ndx
].dwForwardMask
) ==
777 (table
->table
[ndx
].dwForwardDest
& table
->table
[ndx
].dwForwardMask
)) {
778 DWORD numShifts
, mask
;
780 for (numShifts
= 0, mask
= table
->table
[ndx
].dwForwardMask
;
781 mask
&& !(mask
& 1); mask
>>= 1, numShifts
++)
783 if (numShifts
> matchedBits
) {
784 matchedBits
= numShifts
;
789 memcpy(pBestRoute
, &table
->table
[matchedNdx
], sizeof(MIB_IPFORWARDROW
));
790 HeapFree(GetProcessHeap(), 0, table
);
794 ret
= ERROR_OUTOFMEMORY
;
795 TRACE("returning %ld\n", ret
);
799 /******************************************************************
800 * GetExtendedTcpTable (IPHLPAPI.@)
802 * Get the table of TCP endpoints available to the application.
805 * pTcpTable [Out] table struct with the filtered TCP endpoints available to application
806 * pdwSize [In/Out] estimated size of the structure returned in pTcpTable, in bytes
807 * bOrder [In] whether to order the table
808 * ulAf [in] version of IP used by the TCP endpoints
809 * TableClass [in] type of the TCP table structure from TCP_TABLE_CLASS
810 * Reserved [in] reserved - this value must be zero
814 * Failure: either ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER
819 DWORD WINAPI
GetExtendedTcpTable(PVOID pTcpTable
, PDWORD pdwSize
, BOOL bOrder
, ULONG ulAf
, TCP_TABLE_CLASS TableClass
, ULONG Reserved
)
821 DWORD ret
= NO_ERROR
;
823 if (TableClass
== TCP_TABLE_OWNER_PID_ALL
) {
825 *pdwSize
= sizeof(MIB_TCPTABLE_OWNER_PID
);
826 return ERROR_INSUFFICIENT_BUFFER
;
828 ZeroMemory(pTcpTable
, sizeof(MIB_TCPTABLE_OWNER_PID
));
839 /******************************************************************
840 * GetFriendlyIfIndex (IPHLPAPI.@)
852 DWORD WINAPI
GetFriendlyIfIndex(DWORD IfIndex
)
854 /* windows doesn't validate these, either, just makes sure the top byte is
855 cleared. I assume my ifenum module never gives an index with the top
857 TRACE("returning %ld\n", IfIndex
);
862 /******************************************************************
863 * GetIcmpStatistics (IPHLPAPI.@)
875 DWORD WINAPI
GetIcmpStatistics(PMIB_ICMP pStats
)
879 TRACE("pStats %p\n", pStats
);
880 ret
= getICMPStats(pStats
);
881 TRACE("returning %ld\n", ret
);
886 /******************************************************************
887 * GetIfEntry (IPHLPAPI.@)
899 DWORD WINAPI
GetIfEntry(PMIB_IFROW pIfRow
)
904 TRACE("pIfRow %p\n", pIfRow
);
906 return ERROR_INVALID_PARAMETER
;
908 name
= getInterfaceNameByIndex(pIfRow
->dwIndex
);
910 ret
= getInterfaceEntryByIndex(pIfRow
->dwIndex
, pIfRow
);
912 ret
= getInterfaceStatsByName(name
, pIfRow
);
913 consumeInterfaceName(name
);
916 ret
= ERROR_INVALID_DATA
;
917 TRACE("returning %ld\n", ret
);
922 static int IfTableSorter(const void *a
, const void *b
)
927 ret
= ((PMIB_IFROW
)a
)->dwIndex
- ((PMIB_IFROW
)b
)->dwIndex
;
934 /******************************************************************
935 * GetIfTable (IPHLPAPI.@)
949 DWORD WINAPI
GetIfTable(PMIB_IFTABLE pIfTable
, PULONG pdwSize
, BOOL bOrder
)
953 TRACE("pIfTable %p, pdwSize %p, bOrder %ld\n", pdwSize
, pdwSize
,
956 ret
= ERROR_INVALID_PARAMETER
;
958 DWORD numInterfaces
= getNumInterfaces();
960 TRACE("GetIfTable: numInterfaces = %d\n", (int)numInterfaces
);
961 size
= sizeof(MIB_IFTABLE
) + (numInterfaces
- 1) * sizeof(MIB_IFROW
);
963 if (!pIfTable
|| *pdwSize
< size
) {
965 ret
= ERROR_INSUFFICIENT_BUFFER
;
968 InterfaceIndexTable
*table
= getInterfaceIndexTable();
971 size
= sizeof(MIB_IFTABLE
) + (table
->numIndexes
- 1) *
973 if (*pdwSize
< size
) {
975 ret
= ERROR_INSUFFICIENT_BUFFER
;
980 pIfTable
->dwNumEntries
= 0;
981 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
982 pIfTable
->table
[ndx
].dwIndex
= table
->indexes
[ndx
];
983 GetIfEntry(&pIfTable
->table
[ndx
]);
984 pIfTable
->dwNumEntries
++;
987 qsort(pIfTable
->table
, pIfTable
->dwNumEntries
, sizeof(MIB_IFROW
),
994 ret
= ERROR_OUTOFMEMORY
;
997 TRACE("returning %ld\n", ret
);
1002 /******************************************************************
1003 * GetInterfaceInfo (IPHLPAPI.@)
1009 * dwOutBufLen [In/Out]
1016 DWORD WINAPI
GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable
, PULONG dwOutBufLen
)
1020 TRACE("pIfTable %p, dwOutBufLen %p\n", pIfTable
, dwOutBufLen
);
1022 ret
= ERROR_INVALID_PARAMETER
;
1024 DWORD numNonLoopbackInterfaces
= getNumNonLoopbackInterfaces();
1026 TRACE("numNonLoopbackInterfaces == 0x%x\n", numNonLoopbackInterfaces
);
1027 size
= sizeof(IP_INTERFACE_INFO
) + (numNonLoopbackInterfaces
) *
1028 sizeof(IP_ADAPTER_INDEX_MAP
);
1030 if (!pIfTable
|| *dwOutBufLen
< size
) {
1031 *dwOutBufLen
= size
;
1032 ret
= ERROR_INSUFFICIENT_BUFFER
;
1035 InterfaceIndexTable
*table
= getNonLoopbackInterfaceIndexTable();
1038 TRACE("table->numIndexes == 0x%x\n", table
->numIndexes
);
1039 size
= sizeof(IP_INTERFACE_INFO
) + (table
->numIndexes
) *
1040 sizeof(IP_ADAPTER_INDEX_MAP
);
1041 if (*dwOutBufLen
< size
) {
1042 *dwOutBufLen
= size
;
1043 ret
= ERROR_INSUFFICIENT_BUFFER
;
1048 pIfTable
->NumAdapters
= 0;
1049 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
1050 const char *walker
, *name
;
1053 pIfTable
->Adapter
[ndx
].Index
= table
->indexes
[ndx
];
1054 name
= getInterfaceNameByIndex(table
->indexes
[ndx
]);
1055 for (walker
= name
, assigner
= pIfTable
->Adapter
[ndx
].Name
;
1056 walker
&& *walker
&&
1057 assigner
- pIfTable
->Adapter
[ndx
].Name
< MAX_ADAPTER_NAME
- 1;
1058 walker
++, assigner
++)
1059 *assigner
= *walker
;
1061 consumeInterfaceName(name
);
1062 pIfTable
->NumAdapters
++;
1069 ret
= ERROR_OUTOFMEMORY
;
1072 TRACE("returning %ld\n", ret
);
1077 static int IpAddrTableSorter(const void *a
, const void *b
)
1082 ret
= ((PMIB_IPADDRROW
)a
)->dwAddr
- ((PMIB_IPADDRROW
)b
)->dwAddr
;
1089 /******************************************************************
1090 * GetIpAddrTable (IPHLPAPI.@)
1095 * pIpAddrTable [In/Out]
1104 DWORD WINAPI
GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable
, PULONG pdwSize
, BOOL bOrder
)
1108 TRACE("pIpAddrTable %p, pdwSize %p, bOrder %ld\n", pIpAddrTable
, pdwSize
,
1111 ret
= ERROR_INVALID_PARAMETER
;
1113 DWORD numInterfaces
= getNumInterfaces();
1114 ULONG size
= sizeof(MIB_IPADDRTABLE
) + (numInterfaces
- 1) *
1115 sizeof(MIB_IPADDRROW
);
1117 if (!pIpAddrTable
|| *pdwSize
< size
) {
1119 ret
= ERROR_INSUFFICIENT_BUFFER
;
1122 InterfaceIndexTable
*table
= getInterfaceIndexTable();
1125 size
= sizeof(MIB_IPADDRTABLE
) + (table
->numIndexes
- 1) *
1126 sizeof(MIB_IPADDRROW
);
1127 if (*pdwSize
< size
) {
1129 ret
= ERROR_INSUFFICIENT_BUFFER
;
1134 pIpAddrTable
->dwNumEntries
= 0;
1135 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
1136 pIpAddrTable
->table
[ndx
].dwIndex
= table
->indexes
[ndx
];
1137 pIpAddrTable
->table
[ndx
].dwAddr
=
1138 getInterfaceIPAddrByIndex(table
->indexes
[ndx
]);
1139 pIpAddrTable
->table
[ndx
].dwMask
=
1140 getInterfaceMaskByIndex(table
->indexes
[ndx
]);
1141 /* the dwBCastAddr member isn't the broadcast address, it indicates
1142 * whether the interface uses the 1's broadcast address (1) or the
1143 * 0's broadcast address (0).
1145 bcast
= getInterfaceBCastAddrByIndex(table
->indexes
[ndx
]);
1146 pIpAddrTable
->table
[ndx
].dwBCastAddr
=
1147 (bcast
& pIpAddrTable
->table
[ndx
].dwMask
) ? 1 : 0;
1148 /* FIXME: hardcoded reasm size, not sure where to get it */
1149 pIpAddrTable
->table
[ndx
].dwReasmSize
= 65535;
1150 pIpAddrTable
->table
[ndx
].unused1
= 0;
1151 pIpAddrTable
->table
[ndx
].wType
= 0; /* aka unused2 */
1152 pIpAddrTable
->dwNumEntries
++;
1155 qsort(pIpAddrTable
->table
, pIpAddrTable
->dwNumEntries
,
1156 sizeof(MIB_IPADDRROW
), IpAddrTableSorter
);
1162 ret
= ERROR_OUTOFMEMORY
;
1165 TRACE("returning %ld\n", ret
);
1170 static int IpForwardTableSorter(const void *a
, const void *b
)
1175 PMIB_IPFORWARDROW rowA
= (PMIB_IPFORWARDROW
)a
, rowB
= (PMIB_IPFORWARDROW
)b
;
1177 ret
= rowA
->dwForwardDest
- rowB
->dwForwardDest
;
1179 ret
= rowA
->dwForwardProto
- rowB
->dwForwardProto
;
1181 ret
= rowA
->dwForwardPolicy
- rowB
->dwForwardPolicy
;
1183 ret
= rowA
->dwForwardNextHop
- rowB
->dwForwardNextHop
;
1193 /******************************************************************
1194 * GetIpForwardTable (IPHLPAPI.@)
1199 * pIpForwardTable [In/Out]
1208 DWORD WINAPI
GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable
, PULONG pdwSize
, BOOL bOrder
)
1212 TRACE("pIpForwardTable %p, pdwSize %p, bOrder %ld\n", pIpForwardTable
,
1213 pdwSize
, (DWORD
)bOrder
);
1215 ret
= ERROR_INVALID_PARAMETER
;
1217 DWORD numRoutes
= getNumRoutes();
1218 ULONG sizeNeeded
= sizeof(MIB_IPFORWARDTABLE
) + (numRoutes
- 1) *
1219 sizeof(MIB_IPFORWARDROW
);
1221 if (!pIpForwardTable
|| *pdwSize
< sizeNeeded
) {
1222 *pdwSize
= sizeNeeded
;
1223 ret
= ERROR_INSUFFICIENT_BUFFER
;
1226 RouteTable
*table
= getRouteTable();
1228 sizeNeeded
= sizeof(MIB_IPFORWARDTABLE
) + (table
->numRoutes
- 1) *
1229 sizeof(MIB_IPFORWARDROW
);
1230 if (*pdwSize
< sizeNeeded
) {
1231 *pdwSize
= sizeNeeded
;
1232 ret
= ERROR_INSUFFICIENT_BUFFER
;
1237 pIpForwardTable
->dwNumEntries
= table
->numRoutes
;
1238 for (ndx
= 0; ndx
< numRoutes
; ndx
++) {
1239 pIpForwardTable
->table
[ndx
].dwForwardIfIndex
=
1240 table
->routes
[ndx
].ifIndex
;
1241 pIpForwardTable
->table
[ndx
].dwForwardDest
=
1242 table
->routes
[ndx
].dest
;
1243 pIpForwardTable
->table
[ndx
].dwForwardMask
=
1244 table
->routes
[ndx
].mask
;
1245 pIpForwardTable
->table
[ndx
].dwForwardPolicy
= 0;
1246 pIpForwardTable
->table
[ndx
].dwForwardNextHop
=
1247 table
->routes
[ndx
].gateway
;
1248 /* FIXME: this type is appropriate for local interfaces; may not
1249 always be appropriate */
1250 pIpForwardTable
->table
[ndx
].dwForwardType
= MIB_IPROUTE_TYPE_DIRECT
;
1251 /* FIXME: other protos might be appropriate, e.g. the default route
1252 is typically set with MIB_IPPROTO_NETMGMT instead */
1253 pIpForwardTable
->table
[ndx
].dwForwardProto
= MIB_IPPROTO_LOCAL
;
1254 /* punt on age and AS */
1255 pIpForwardTable
->table
[ndx
].dwForwardAge
= 0;
1256 pIpForwardTable
->table
[ndx
].dwForwardNextHopAS
= 0;
1257 pIpForwardTable
->table
[ndx
].dwForwardMetric1
=
1258 table
->routes
[ndx
].metric
;
1259 /* rest of the metrics are 0.. */
1260 pIpForwardTable
->table
[ndx
].dwForwardMetric2
= 0;
1261 pIpForwardTable
->table
[ndx
].dwForwardMetric3
= 0;
1262 pIpForwardTable
->table
[ndx
].dwForwardMetric4
= 0;
1263 pIpForwardTable
->table
[ndx
].dwForwardMetric5
= 0;
1266 qsort(pIpForwardTable
->table
, pIpForwardTable
->dwNumEntries
,
1267 sizeof(MIB_IPFORWARDROW
), IpForwardTableSorter
);
1270 HeapFree(GetProcessHeap(), 0, table
);
1273 ret
= ERROR_OUTOFMEMORY
;
1276 TRACE("returning %ld\n", ret
);
1281 static int IpNetTableSorter(const void *a
, const void *b
)
1286 ret
= ((PMIB_IPNETROW
)a
)->dwAddr
- ((PMIB_IPNETROW
)b
)->dwAddr
;
1293 /******************************************************************
1294 * GetIpNetTable (IPHLPAPI.@)
1299 * pIpNetTable [In/Out]
1308 DWORD WINAPI
GetIpNetTable(PMIB_IPNETTABLE pIpNetTable
, PULONG pdwSize
, BOOL bOrder
)
1310 DWORD ret
= NO_ERROR
;
1312 TRACE("pIpNetTable %p, pdwSize %p, bOrder %d\n", pIpNetTable
, pdwSize
,
1315 ret
= ERROR_INVALID_PARAMETER
;
1317 DWORD numEntries
= getNumArpEntries();
1318 ULONG size
= sizeof(MIB_IPNETTABLE
);
1321 size
+= (numEntries
- 1) * sizeof(MIB_IPNETROW
);
1322 if (!pIpNetTable
|| *pdwSize
< size
) {
1324 ret
= ERROR_INSUFFICIENT_BUFFER
;
1327 PMIB_IPNETTABLE table
= getArpTable();
1329 size
= sizeof(MIB_IPNETTABLE
);
1330 if (table
->dwNumEntries
> 1)
1331 size
+= (table
->dwNumEntries
- 1) * sizeof(MIB_IPNETROW
);
1332 if (*pdwSize
< size
) {
1334 ret
= ERROR_INSUFFICIENT_BUFFER
;
1338 memcpy(pIpNetTable
, table
, size
);
1340 qsort(pIpNetTable
->table
, pIpNetTable
->dwNumEntries
,
1341 sizeof(MIB_IPNETROW
), IpNetTableSorter
);
1344 HeapFree(GetProcessHeap(), 0, table
);
1348 TRACE("returning %d\n", ret
);
1353 /******************************************************************
1354 * GetIpStatistics (IPHLPAPI.@)
1366 DWORD WINAPI
GetIpStatistics(PMIB_IPSTATS pStats
)
1368 return GetIpStatisticsEx(pStats
, PF_INET
);
1371 /******************************************************************
1372 * GetIpStatisticsEx (IPHLPAPI.@)
1385 DWORD WINAPI
GetIpStatisticsEx(PMIB_IPSTATS pStats
, DWORD dwFamily
)
1389 TRACE("pStats %p\n", pStats
);
1390 ret
= getIPStats(pStats
, dwFamily
);
1391 TRACE("returning %ld\n", ret
);
1395 /******************************************************************
1396 * GetNetworkParams (IPHLPAPI.@)
1401 * pFixedInfo [In/Out]
1402 * pOutBufLen [In/Out]
1409 DWORD WINAPI
GetNetworkParams(PFIXED_INFO pFixedInfo
, PULONG pOutBufLen
)
1414 PIPHLP_RES_INFO resInfo
;
1416 TRACE("pFixedInfo %p, pOutBufLen %p\n", pFixedInfo
, pOutBufLen
);
1418 return ERROR_INVALID_PARAMETER
;
1420 resInfo
= getResInfo();
1422 return ERROR_OUTOFMEMORY
;
1424 size
= sizeof(FIXED_INFO
) + (resInfo
->riCount
> 1 ? (resInfo
->riCount
-1) *
1425 sizeof(IP_ADDR_STRING
) : 0);
1426 if (!pFixedInfo
|| *pOutBufLen
< size
) {
1428 disposeResInfo( resInfo
);
1429 return ERROR_BUFFER_OVERFLOW
;
1432 memset(pFixedInfo
, 0, size
);
1433 size
= sizeof(pFixedInfo
->HostName
);
1434 GetComputerNameExA(ComputerNameDnsHostname
, pFixedInfo
->HostName
, &size
);
1435 size
= sizeof(pFixedInfo
->DomainName
);
1436 GetComputerNameExA(ComputerNameDnsDomain
, pFixedInfo
->DomainName
, &size
);
1438 TRACE("GetComputerNameExA: %s\n", pFixedInfo
->DomainName
);
1440 if (resInfo
->riCount
> 0)
1442 CopyMemory(&pFixedInfo
->DnsServerList
, resInfo
->DnsList
, sizeof(IP_ADDR_STRING
));
1443 if (resInfo
->riCount
> 1)
1445 IP_ADDR_STRING
*pSrc
= resInfo
->DnsList
->Next
;
1446 IP_ADDR_STRING
*pTarget
= (struct _IP_ADDR_STRING
*)((char*)pFixedInfo
+ sizeof(FIXED_INFO
));
1448 pFixedInfo
->DnsServerList
.Next
= pTarget
;
1452 CopyMemory(pTarget
, pSrc
, sizeof(IP_ADDR_STRING
));
1454 if (resInfo
->riCount
> 1)
1456 pTarget
->Next
= (IP_ADDR_STRING
*)((char*)pTarget
+ sizeof(IP_ADDR_STRING
));
1457 pTarget
= pTarget
->Next
;
1462 pTarget
->Next
= NULL
;
1470 pFixedInfo
->DnsServerList
.Next
= NULL
;
1474 pFixedInfo
->NodeType
= HYBRID_NODETYPE
;
1475 regReturn
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
1476 "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", 0, KEY_READ
, &hKey
);
1477 if (regReturn
!= ERROR_SUCCESS
)
1478 regReturn
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
1479 "SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ
,
1481 if (regReturn
== ERROR_SUCCESS
)
1483 DWORD size
= sizeof(pFixedInfo
->ScopeId
);
1485 RegQueryValueExA(hKey
, "ScopeID", NULL
, NULL
, (PBYTE
)pFixedInfo
->ScopeId
, &size
);
1489 disposeResInfo( resInfo
);
1490 /* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
1491 I suppose could also check for a listener on port 53 to set EnableDns */
1493 TRACE("returning %ld\n", ret
);
1499 /******************************************************************
1500 * GetNumberOfInterfaces (IPHLPAPI.@)
1512 DWORD WINAPI
GetNumberOfInterfaces(PDWORD pdwNumIf
)
1516 TRACE("pdwNumIf %p\n", pdwNumIf
);
1518 ret
= ERROR_INVALID_PARAMETER
;
1520 *pdwNumIf
= getNumInterfaces();
1523 TRACE("returning %ld\n", ret
);
1528 /******************************************************************
1529 * GetOwnerModuleFromTcpEntry (IPHLPAPI.@)
1531 * Get data about the module that issued the context bind for a specific IPv4 TCP endpoint in a MIB table row
1534 * pTcpEntry [in] pointer to a MIB_TCPROW_OWNER_MODULE structure
1535 * Class [in] TCPIP_OWNER_MODULE_INFO_CLASS enumeration value
1536 * Buffer [out] pointer a buffer containing a TCPIP_OWNER_MODULE_BASIC_INFO structure with the owner module data.
1537 * pdwSize [in, out] estimated size of the structure returned in Buffer, in bytes
1541 * Failure: ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY
1542 * ERROR_NOT_FOUND or ERROR_PARTIAL_COPY
1545 * The type of data returned in Buffer is indicated by the value of the Class parameter.
1547 DWORD WINAPI
GetOwnerModuleFromTcpEntry( PMIB_TCPROW_OWNER_MODULE pTcpEntry
, TCPIP_OWNER_MODULE_INFO_CLASS Class
, PVOID Buffer
, PDWORD pdwSize
)
1549 DWORD ret
= NO_ERROR
;
1554 static void CreateNameServerListEnumNamesFunc( PWCHAR Interface
, PWCHAR Server
, PVOID Data
)
1556 IP_ADDR_STRING
*pNext
;
1557 PNAME_SERVER_LIST_CONTEXT Context
= (PNAME_SERVER_LIST_CONTEXT
)Data
;
1559 if (!Context
->NumServers
)
1561 if (Context
->uSizeAvailable
>= Context
->uSizeRequired
)
1563 WideCharToMultiByte(CP_ACP
, 0, Server
, -1, Context
->pData
->DnsServerList
.IpAddress
.String
, 16, NULL
, NULL
);
1564 Context
->pData
->DnsServerList
.IpAddress
.String
[15] = '\0';
1565 Context
->pLastAddr
= &Context
->pData
->DnsServerList
;
1570 Context
->uSizeRequired
+= sizeof(IP_ADDR_STRING
);
1571 if (Context
->uSizeAvailable
>= Context
->uSizeRequired
)
1573 pNext
= (IP_ADDR_STRING
*)(((char*)Context
->pLastAddr
) + sizeof(IP_ADDR_STRING
));
1574 WideCharToMultiByte(CP_ACP
, 0, Server
, -1, pNext
->IpAddress
.String
, 16, NULL
, NULL
);
1575 pNext
->IpAddress
.String
[15] = '\0';
1576 Context
->pLastAddr
->Next
= pNext
;
1577 Context
->pLastAddr
= pNext
;
1581 Context
->NumServers
++;
1584 /******************************************************************
1585 * GetPerAdapterInfo (IPHLPAPI.@)
1591 * pPerAdapterInfo [In/Out]
1592 * pOutBufLen [In/Out]
1599 DWORD WINAPI
GetPerAdapterInfo(ULONG IfIndex
, PIP_PER_ADAPTER_INFO pPerAdapterInfo
, PULONG pOutBufLen
)
1604 NAME_SERVER_LIST_CONTEXT Context
;
1605 WCHAR keyname
[200] = L
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\";
1608 return ERROR_INVALID_PARAMETER
;
1610 if (!pPerAdapterInfo
|| *pOutBufLen
< sizeof(IP_PER_ADAPTER_INFO
))
1612 *pOutBufLen
= sizeof(IP_PER_ADAPTER_INFO
);
1613 return ERROR_BUFFER_OVERFLOW
;
1616 ifName
= getInterfaceNameByIndex(IfIndex
);
1618 return ERROR_INVALID_PARAMETER
;
1620 MultiByteToWideChar(CP_ACP
, 0, ifName
, -1, &keyname
[62], sizeof(keyname
)/sizeof(WCHAR
) - 63);
1621 HeapFree(GetProcessHeap(), 0, (LPVOID
)ifName
);
1623 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, keyname
, 0, KEY_READ
, &hkey
) != ERROR_SUCCESS
)
1625 return ERROR_NOT_SUPPORTED
;
1627 Context
.NumServers
= 0;
1628 Context
.uSizeAvailable
= *pOutBufLen
;
1629 Context
.uSizeRequired
= sizeof(IP_PER_ADAPTER_INFO
);
1630 Context
.pData
= pPerAdapterInfo
;
1632 if (*pOutBufLen
>= sizeof(IP_PER_ADAPTER_INFO
))
1633 ZeroMemory(pPerAdapterInfo
, sizeof(IP_PER_ADAPTER_INFO
));
1635 EnumNameServers(hkey
, &keyname
[62], &Context
, CreateNameServerListEnumNamesFunc
);
1637 if (Context
.uSizeRequired
> Context
.uSizeAvailable
)
1639 *pOutBufLen
= Context
.uSizeRequired
;
1641 return ERROR_BUFFER_OVERFLOW
;
1644 if(RegQueryValueExW(hkey
, L
"NameServer", NULL
, NULL
, NULL
, &dwSize
) == ERROR_SUCCESS
)
1646 pPerAdapterInfo
->AutoconfigActive
= FALSE
;
1650 pPerAdapterInfo
->AutoconfigActive
= TRUE
;
1658 /******************************************************************
1659 * GetRTTAndHopCount (IPHLPAPI.@)
1664 * DestIpAddress [In]
1674 BOOL WINAPI
GetRTTAndHopCount(IPAddr DestIpAddress
, PULONG HopCount
, ULONG MaxHops
, PULONG RTT
)
1676 TRACE("DestIpAddress 0x%08lx, HopCount %p, MaxHops %ld, RTT %p\n",
1677 DestIpAddress
, HopCount
, MaxHops
, RTT
);
1683 /******************************************************************
1684 * GetTcpStatisticsEx (IPHLPAPI.@)
1697 DWORD WINAPI
GetTcpStatisticsEx(PMIB_TCPSTATS pStats
, DWORD dwFamily
)
1701 TRACE("pStats %p\n", pStats
);
1702 ret
= getTCPStats(pStats
, dwFamily
);
1703 TRACE("returning %ld\n", ret
);
1707 /******************************************************************
1708 * GetTcpStatistics (IPHLPAPI.@)
1720 DWORD WINAPI
GetTcpStatistics(PMIB_TCPSTATS pStats
)
1722 return GetTcpStatisticsEx(pStats
, PF_INET
);
1726 static int TcpTableSorter(const void *a
, const void *b
)
1731 PMIB_TCPROW rowA
= (PMIB_TCPROW
)a
, rowB
= (PMIB_TCPROW
)b
;
1733 ret
= rowA
->dwLocalAddr
- rowB
->dwLocalAddr
;
1735 ret
= rowA
->dwLocalPort
- rowB
->dwLocalPort
;
1737 ret
= rowA
->dwRemoteAddr
- rowB
->dwRemoteAddr
;
1739 ret
= rowA
->dwRemotePort
- rowB
->dwRemotePort
;
1749 /******************************************************************
1750 * GetTcpTable (IPHLPAPI.@)
1752 * Get the table of active TCP connections.
1755 * pTcpTable [Out] buffer for TCP connections table
1756 * pdwSize [In/Out] length of output buffer
1757 * bOrder [In] whether to order the table
1761 * Failure: error code from winerror.h
1764 * If pdwSize is less than required, the function will return
1765 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to
1766 * the required byte size.
1767 * If bOrder is true, the returned table will be sorted, first by
1768 * local address and port number, then by remote address and port
1771 DWORD WINAPI
GetTcpTable(PMIB_TCPTABLE pTcpTable
, PDWORD pdwSize
, BOOL bOrder
)
1773 DWORD ret
= ERROR_NO_DATA
;
1775 TRACE("pTcpTable %p, pdwSize %p, bOrder %d\n", pTcpTable
, pdwSize
,
1778 ret
= ERROR_INVALID_PARAMETER
;
1780 DWORD numEntries
= getNumTcpEntries();
1781 DWORD size
= sizeof(MIB_TCPTABLE
);
1784 size
+= (numEntries
- 1) * sizeof(MIB_TCPROW
);
1785 if (!pTcpTable
|| *pdwSize
< size
) {
1787 ret
= ERROR_INSUFFICIENT_BUFFER
;
1790 PMIB_TCPTABLE pOurTcpTable
= getTcpTable();
1793 size
= sizeof(MIB_TCPTABLE
);
1794 if (pOurTcpTable
->dwNumEntries
> 1)
1795 size
+= (pOurTcpTable
->dwNumEntries
- 1) * sizeof(MIB_TCPROW
);
1797 if (*pdwSize
< size
)
1801 ret
= ERROR_INSUFFICIENT_BUFFER
;
1805 memcpy(pTcpTable
, pOurTcpTable
, size
);
1808 qsort(pTcpTable
->table
, pTcpTable
->dwNumEntries
,
1809 sizeof(MIB_TCPROW
), TcpTableSorter
);
1818 TRACE("returning %d\n", ret
);
1823 /******************************************************************
1824 * GetUdpStatisticsEx (IPHLPAPI.@)
1837 DWORD WINAPI
GetUdpStatisticsEx(PMIB_UDPSTATS pStats
, DWORD dwFamily
)
1841 TRACE("pStats %p\n", pStats
);
1842 ret
= getUDPStats(pStats
, dwFamily
);
1843 TRACE("returning %ld\n", ret
);
1847 /******************************************************************
1848 * GetUdpStatistics (IPHLPAPI.@)
1860 DWORD WINAPI
GetUdpStatistics(PMIB_UDPSTATS pStats
)
1862 return GetUdpStatisticsEx(pStats
, PF_INET
);
1866 static int UdpTableSorter(const void *a
, const void *b
)
1871 PMIB_UDPROW rowA
= (PMIB_UDPROW
)a
, rowB
= (PMIB_UDPROW
)b
;
1873 ret
= rowA
->dwLocalAddr
- rowB
->dwLocalAddr
;
1875 ret
= rowA
->dwLocalPort
- rowB
->dwLocalPort
;
1883 /******************************************************************
1884 * GetUdpTable (IPHLPAPI.@)
1889 * pUdpTable [In/Out]
1898 DWORD WINAPI
GetUdpTable(PMIB_UDPTABLE pUdpTable
, PDWORD pdwSize
, BOOL bOrder
)
1902 TRACE("pUdpTable %p, pdwSize %p, bOrder %ld\n", pUdpTable
, pdwSize
,
1905 ret
= ERROR_INVALID_PARAMETER
;
1907 DWORD numEntries
= getNumUdpEntries();
1908 ULONG size
= sizeof(MIB_UDPTABLE
) + (numEntries
- 1) * sizeof(MIB_UDPROW
);
1910 if (!pUdpTable
|| *pdwSize
< size
) {
1912 ret
= ERROR_INSUFFICIENT_BUFFER
;
1915 PMIB_UDPTABLE table
= getUdpTable();
1918 size
= sizeof(MIB_UDPTABLE
) + (table
->dwNumEntries
- 1) *
1920 if (*pdwSize
< size
) {
1922 ret
= ERROR_INSUFFICIENT_BUFFER
;
1925 memcpy(pUdpTable
, table
, size
);
1927 qsort(pUdpTable
->table
, pUdpTable
->dwNumEntries
,
1928 sizeof(MIB_UDPROW
), UdpTableSorter
);
1934 ret
= ERROR_OUTOFMEMORY
;
1937 TRACE("returning %ld\n", ret
);
1942 /******************************************************************
1943 * GetUniDirectionalAdapterInfo (IPHLPAPI.@)
1945 * This is a Win98-only function to get information on "unidirectional"
1946 * adapters. Since this is pretty nonsensical in other contexts, it
1947 * never returns anything.
1950 * pIPIfInfo [Out] buffer for adapter infos
1951 * dwOutBufLen [Out] length of the output buffer
1955 * Failure: error code from winerror.h
1958 * Stub, returns ERROR_NOT_SUPPORTED.
1960 DWORD WINAPI
GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo
, PULONG dwOutBufLen
)
1962 TRACE("pIPIfInfo %p, dwOutBufLen %p\n", pIPIfInfo
, dwOutBufLen
);
1963 /* a unidirectional adapter?? not bloody likely! */
1964 return ERROR_NOT_SUPPORTED
;
1968 /******************************************************************
1969 * IpReleaseAddress (IPHLPAPI.@)
1971 * Release an IP obtained through DHCP,
1974 * AdapterInfo [In] adapter to release IP address
1978 * Failure: error code from winerror.h
1981 DWORD WINAPI
IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo
)
1983 DWORD Status
, Version
= 0;
1985 if (!AdapterInfo
|| !AdapterInfo
->Name
)
1986 return ERROR_INVALID_PARAMETER
;
1988 /* Maybe we should do this in DllMain */
1989 if (DhcpCApiInitialize(&Version
) != ERROR_SUCCESS
)
1990 return ERROR_PROC_NOT_FOUND
;
1992 if (DhcpReleaseIpAddressLease(AdapterInfo
->Index
))
1993 Status
= ERROR_SUCCESS
;
1995 Status
= ERROR_PROC_NOT_FOUND
;
2003 /******************************************************************
2004 * IpRenewAddress (IPHLPAPI.@)
2006 * Renew an IP obtained through DHCP.
2009 * AdapterInfo [In] adapter to renew IP address
2013 * Failure: error code from winerror.h
2015 DWORD WINAPI
IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo
)
2017 DWORD Status
, Version
= 0;
2019 if (!AdapterInfo
|| !AdapterInfo
->Name
)
2020 return ERROR_INVALID_PARAMETER
;
2022 /* Maybe we should do this in DllMain */
2023 if (DhcpCApiInitialize(&Version
) != ERROR_SUCCESS
)
2024 return ERROR_PROC_NOT_FOUND
;
2026 if (DhcpRenewIpAddressLease(AdapterInfo
->Index
))
2027 Status
= ERROR_SUCCESS
;
2029 Status
= ERROR_PROC_NOT_FOUND
;
2037 /******************************************************************
2038 * NotifyAddrChange (IPHLPAPI.@)
2040 * Notify caller whenever the ip-interface map is changed.
2043 * Handle [Out] handle usable in asynchronous notification
2044 * overlapped [In] overlapped structure that notifies the caller
2048 * Failure: error code from winerror.h
2051 * Stub, returns ERROR_NOT_SUPPORTED.
2053 DWORD WINAPI
NotifyAddrChange(PHANDLE Handle
, LPOVERLAPPED overlapped
)
2055 FIXME("(Handle %p, overlapped %p): stub\n", Handle
, overlapped
);
2056 if (Handle
) *Handle
= INVALID_HANDLE_VALUE
;
2057 if (overlapped
) ((IO_STATUS_BLOCK
*) overlapped
)->Status
= STATUS_PENDING
;
2058 return ERROR_IO_PENDING
;
2062 /******************************************************************
2063 * NotifyRouteChange (IPHLPAPI.@)
2065 * Notify caller whenever the ip routing table is changed.
2068 * Handle [Out] handle usable in asynchronous notification
2069 * overlapped [In] overlapped structure that notifies the caller
2073 * Failure: error code from winerror.h
2076 * Stub, returns ERROR_NOT_SUPPORTED.
2078 DWORD WINAPI
NotifyRouteChange(PHANDLE Handle
, LPOVERLAPPED overlapped
)
2080 FIXME("(Handle %p, overlapped %p): stub\n", Handle
, overlapped
);
2081 return ERROR_NOT_SUPPORTED
;
2084 /******************************************************************
2085 * SendARP (IPHLPAPI.@)
2087 * Send an ARP request.
2090 * DestIP [In] attempt to obtain this IP
2091 * SrcIP [In] optional sender IP address
2092 * pMacAddr [Out] buffer for the mac address
2093 * PhyAddrLen [In/Out] length of the output buffer
2097 * Failure: error code from winerror.h
2099 DWORD WINAPI
SendARP(IPAddr DestIP
, IPAddr SrcIP
, PULONG pMacAddr
, PULONG PhyAddrLen
)
2104 if (IsBadWritePtr(pMacAddr
, sizeof(ULONG
)) || IsBadWritePtr(PhyAddrLen
, sizeof(ULONG
)))
2105 return ERROR_INVALID_PARAMETER
;
2110 return TCPSendIoctl(INVALID_HANDLE_VALUE
, IOCTL_QUERY_IP_HW_ADDRESS
, IPs
, &Size
, pMacAddr
, PhyAddrLen
);
2114 /******************************************************************
2115 * SetIfEntry (IPHLPAPI.@)
2117 * Set the administrative status of an interface.
2120 * pIfRow [In] dwAdminStatus member specifies the new status.
2124 * Failure: error code from winerror.h
2127 * Stub, returns ERROR_NOT_SUPPORTED.
2129 DWORD WINAPI
SetIfEntry(PMIB_IFROW pIfRow
)
2131 FIXME("(pIfRow %p): stub\n", pIfRow
);
2132 /* this is supposed to set an interface administratively up or down.
2133 Could do SIOCSIFFLAGS and set/clear IFF_UP, but, not sure I want to, and
2134 this sort of down is indistinguishable from other sorts of down (e.g. no
2136 return ERROR_NOT_SUPPORTED
;
2140 /******************************************************************
2141 * SetIpForwardEntry (IPHLPAPI.@)
2143 * Modify an existing route.
2146 * pRoute [In] route with the new information
2150 * Failure: error code from winerror.h
2153 DWORD WINAPI
SetIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
2155 return setIpForwardEntry( pRoute
);
2159 /******************************************************************
2160 * SetIpNetEntry (IPHLPAPI.@)
2162 * Modify an existing ARP entry.
2165 * pArpEntry [In] ARP entry with the new information
2169 * Failure: error code from winerror.h
2171 DWORD WINAPI
SetIpNetEntry(PMIB_IPNETROW pArpEntry
)
2175 TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY req
=
2176 TCP_REQUEST_SET_INFORMATION_INIT
;
2179 PMIB_IPNETROW arpBuff
;
2182 return ERROR_INVALID_PARAMETER
;
2184 if (!NT_SUCCESS(openTcpFile( &tcpFile
, FILE_READ_DATA
| FILE_WRITE_DATA
)))
2185 return ERROR_NOT_SUPPORTED
;
2187 if (!NT_SUCCESS(getNthIpEntity( tcpFile
, pArpEntry
->dwIndex
, &id
)))
2189 closeTcpFile(tcpFile
);
2190 return ERROR_INVALID_PARAMETER
;
2193 req
.Req
.ID
.toi_class
= INFO_CLASS_PROTOCOL
;
2194 req
.Req
.ID
.toi_type
= INFO_TYPE_PROVIDER
;
2195 req
.Req
.ID
.toi_id
= IP_MIB_ARPTABLE_ENTRY_ID
;
2196 req
.Req
.ID
.toi_entity
.tei_instance
= id
.tei_instance
;
2197 req
.Req
.ID
.toi_entity
.tei_entity
= AT_ENTITY
;
2198 req
.Req
.BufferSize
= sizeof(MIB_IPNETROW
);
2199 arpBuff
= (PMIB_IPNETROW
)&req
.Req
.Buffer
[0];
2201 RtlCopyMemory(arpBuff
, pArpEntry
, sizeof(MIB_IPNETROW
));
2203 status
= DeviceIoControl( tcpFile
,
2204 IOCTL_TCP_SET_INFORMATION_EX
,
2212 closeTcpFile(tcpFile
);
2217 return ERROR_INVALID_PARAMETER
;
2221 /******************************************************************
2222 * SetIpStatistics (IPHLPAPI.@)
2224 * Toggle IP forwarding and det the default TTL value.
2227 * pIpStats [In] IP statistics with the new information
2231 * Failure: error code from winerror.h
2234 * Stub, returns NO_ERROR.
2236 DWORD WINAPI
SetIpStatistics(PMIB_IPSTATS pIpStats
)
2238 FIXME("(pIpStats %p): stub\n", pIpStats
);
2243 /******************************************************************
2244 * SetIpTTL (IPHLPAPI.@)
2246 * Set the default TTL value.
2249 * nTTL [In] new TTL value
2253 * Failure: error code from winerror.h
2256 * Stub, returns NO_ERROR.
2258 DWORD WINAPI
SetIpTTL(UINT nTTL
)
2260 FIXME("(nTTL %d): stub\n", nTTL
);
2265 /******************************************************************
2266 * SetTcpEntry (IPHLPAPI.@)
2268 * Set the state of a TCP connection.
2271 * pTcpRow [In] specifies connection with new state
2275 * Failure: error code from winerror.h
2278 * Stub, returns NO_ERROR.
2280 DWORD WINAPI
SetTcpEntry(PMIB_TCPROW pTcpRow
)
2282 FIXME("(pTcpRow %p): stub\n", pTcpRow
);
2287 /******************************************************************
2288 * UnenableRouter (IPHLPAPI.@)
2290 * Decrement the IP-forwarding reference count. Turn off IP-forwarding
2291 * if it reaches zero.
2294 * pOverlapped [In/Out] should be the same as in EnableRouter()
2295 * lpdwEnableCount [Out] optional, receives reference count
2299 * Failure: error code from winerror.h
2302 * Stub, returns ERROR_NOT_SUPPORTED.
2304 DWORD WINAPI
UnenableRouter(OVERLAPPED
* pOverlapped
, LPDWORD lpdwEnableCount
)
2306 FIXME("(pOverlapped %p, lpdwEnableCount %p): stub\n", pOverlapped
,
2308 return ERROR_NOT_SUPPORTED
;
2314 DWORD WINAPI
GetIpErrorString(IP_STATUS ErrorCode
,PWCHAR Buffer
,PDWORD Size
)
2324 PIP_ADAPTER_ORDER_MAP WINAPI
GetAdapterOrderMap(VOID
)
2333 #ifdef GetAdaptersAddressesV1
2334 DWORD WINAPI DECLSPEC_HOTPATCH
GetAdaptersAddresses(ULONG Family
,ULONG Flags
,PVOID Reserved
,PIP_ADAPTER_ADDRESSES pAdapterAddresses
,PULONG pOutBufLen
)
2336 InterfaceIndexTable
*indexTable
;
2339 ULONG ret
, requiredSize
= 0;
2340 PIP_ADAPTER_ADDRESSES currentAddress
;
2341 PUCHAR currentLocation
;
2344 if (!pOutBufLen
) return ERROR_INVALID_PARAMETER
;
2345 if (Reserved
) return ERROR_INVALID_PARAMETER
;
2347 indexTable
= getInterfaceIndexTable();
2349 return ERROR_NOT_ENOUGH_MEMORY
;
2351 ret
= openTcpFile(&tcpFile
, FILE_READ_DATA
);
2352 if (!NT_SUCCESS(ret
))
2353 return ERROR_NO_DATA
;
2355 for (i
= indexTable
->numIndexes
; i
>= 0; i
--)
2357 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile
,
2359 indexTable
->indexes
[i
],
2362 /* The whole struct */
2363 requiredSize
+= sizeof(IP_ADAPTER_ADDRESSES
);
2366 if (!(Flags
& GAA_FLAG_SKIP_FRIENDLY_NAME
))
2367 requiredSize
+= strlen((char *)ifInfo
.if_info
.ent
.if_descr
) + 1; //FIXME
2370 requiredSize
+= strlen((char *)ifInfo
.if_info
.ent
.if_descr
) + 1;
2372 /* Unicast address */
2373 if (!(Flags
& GAA_FLAG_SKIP_UNICAST
))
2374 requiredSize
+= sizeof(IP_ADAPTER_UNICAST_ADDRESS
);
2376 /* FIXME: Implement multicast, anycast, and dns server stuff */
2378 /* FIXME: Implement dns suffix and description */
2379 requiredSize
+= 2 * sizeof(WCHAR
);
2381 /* We're only going to implement what's required for XP SP0 */
2384 TRACE("size: %d, requiredSize: %d\n", *pOutBufLen
, requiredSize
);
2385 if (!pAdapterAddresses
|| *pOutBufLen
< requiredSize
)
2387 *pOutBufLen
= requiredSize
;
2388 closeTcpFile(tcpFile
);
2390 return ERROR_BUFFER_OVERFLOW
;
2393 RtlZeroMemory(pAdapterAddresses
, requiredSize
);
2395 /* Let's set up the pointers */
2396 currentAddress
= pAdapterAddresses
;
2397 for (i
= indexTable
->numIndexes
; i
>= 0; i
--)
2399 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile
,
2401 indexTable
->indexes
[i
],
2404 currentLocation
= (PUCHAR
)currentAddress
+ (ULONG_PTR
)sizeof(IP_ADAPTER_ADDRESSES
);
2406 /* FIXME: Friendly name */
2407 if (!(Flags
& GAA_FLAG_SKIP_FRIENDLY_NAME
))
2409 currentAddress
->FriendlyName
= (PVOID
)currentLocation
;
2410 currentLocation
+= sizeof(WCHAR
);
2414 currentAddress
->AdapterName
= (PVOID
)currentLocation
;
2415 currentLocation
+= strlen((char *)ifInfo
.if_info
.ent
.if_descr
) + 1;
2417 /* Unicast address */
2418 if (!(Flags
& GAA_FLAG_SKIP_UNICAST
))
2420 currentAddress
->FirstUnicastAddress
= (PVOID
)currentLocation
;
2421 currentLocation
+= sizeof(IP_ADAPTER_UNICAST_ADDRESS
);
2422 currentAddress
->FirstUnicastAddress
->Address
.lpSockaddr
= (PVOID
)currentLocation
;
2423 currentLocation
+= sizeof(struct sockaddr
);
2426 /* FIXME: Implement multicast, anycast, and dns server stuff */
2428 /* FIXME: Implement dns suffix and description */
2429 currentAddress
->DnsSuffix
= (PVOID
)currentLocation
;
2430 currentLocation
+= sizeof(WCHAR
);
2432 currentAddress
->Description
= (PVOID
)currentLocation
;
2433 currentLocation
+= sizeof(WCHAR
);
2435 currentAddress
->Next
= (PVOID
)currentLocation
;
2436 /* Terminate the last address correctly */
2438 currentAddress
->Next
= NULL
;
2440 /* We're only going to implement what's required for XP SP0 */
2442 currentAddress
= currentAddress
->Next
;
2446 /* Now again, for real this time */
2448 currentAddress
= pAdapterAddresses
;
2449 for (i
= indexTable
->numIndexes
; i
>= 0; i
--)
2451 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile
,
2453 indexTable
->indexes
[i
],
2456 /* Make sure we're not looping more than we hoped for */
2457 ASSERT(currentAddress
);
2459 /* Alignment information */
2460 currentAddress
->Length
= sizeof(IP_ADAPTER_ADDRESSES
);
2461 currentAddress
->IfIndex
= indexTable
->indexes
[i
];
2464 strcpy(currentAddress
->AdapterName
, (char *)ifInfo
.if_info
.ent
.if_descr
);
2466 if (!(Flags
& GAA_FLAG_SKIP_UNICAST
))
2468 currentAddress
->FirstUnicastAddress
->Length
= sizeof(IP_ADAPTER_UNICAST_ADDRESS
);
2469 currentAddress
->FirstUnicastAddress
->Flags
= 0; //FIXME
2470 currentAddress
->FirstUnicastAddress
->Next
= NULL
; //FIXME: Support more than one address per adapter
2471 currentAddress
->FirstUnicastAddress
->Address
.lpSockaddr
->sa_family
= AF_INET
;
2472 memcpy(currentAddress
->FirstUnicastAddress
->Address
.lpSockaddr
->sa_data
,
2473 &ifInfo
.ip_addr
.iae_addr
,
2474 sizeof(ifInfo
.ip_addr
.iae_addr
));
2475 currentAddress
->FirstUnicastAddress
->Address
.iSockaddrLength
= sizeof(ifInfo
.ip_addr
.iae_addr
) + sizeof(USHORT
);
2476 currentAddress
->FirstUnicastAddress
->PrefixOrigin
= IpPrefixOriginOther
; //FIXME
2477 currentAddress
->FirstUnicastAddress
->SuffixOrigin
= IpPrefixOriginOther
; //FIXME
2478 currentAddress
->FirstUnicastAddress
->DadState
= IpDadStatePreferred
; //FIXME
2479 currentAddress
->FirstUnicastAddress
->ValidLifetime
= 0xFFFFFFFF; //FIXME
2480 currentAddress
->FirstUnicastAddress
->PreferredLifetime
= 0xFFFFFFFF; //FIXME
2481 currentAddress
->FirstUnicastAddress
->LeaseLifetime
= 0xFFFFFFFF; //FIXME
2484 /* FIXME: Implement multicast, anycast, and dns server stuff */
2485 currentAddress
->FirstAnycastAddress
= NULL
;
2486 currentAddress
->FirstMulticastAddress
= NULL
;
2487 currentAddress
->FirstDnsServerAddress
= NULL
;
2489 /* FIXME: Implement dns suffix, description, and friendly name */
2490 currentAddress
->DnsSuffix
[0] = UNICODE_NULL
;
2491 currentAddress
->Description
[0] = UNICODE_NULL
;
2492 currentAddress
->FriendlyName
[0] = UNICODE_NULL
;
2494 /* Physical Address */
2495 memcpy(currentAddress
->PhysicalAddress
, ifInfo
.if_info
.ent
.if_physaddr
, ifInfo
.if_info
.ent
.if_physaddrlen
);
2496 currentAddress
->PhysicalAddressLength
= ifInfo
.if_info
.ent
.if_physaddrlen
;
2499 currentAddress
->Flags
= 0; //FIXME
2502 currentAddress
->Mtu
= ifInfo
.if_info
.ent
.if_mtu
;
2504 /* Interface type */
2505 currentAddress
->IfType
= ifInfo
.if_info
.ent
.if_type
;
2507 /* Operational status */
2508 if(ifInfo
.if_info
.ent
.if_operstatus
>= IF_OPER_STATUS_CONNECTING
)
2509 currentAddress
->OperStatus
= IfOperStatusUp
;
2511 currentAddress
->OperStatus
= IfOperStatusDown
;
2513 /* We're only going to implement what's required for XP SP0 */
2515 /* Move to the next address */
2516 currentAddress
= currentAddress
->Next
;
2520 closeTcpFile(tcpFile
);
2530 BOOL WINAPI
CancelIPChangeNotify(LPOVERLAPPED notifyOverlapped
)
2539 DWORD WINAPI
GetBestInterfaceEx(struct sockaddr
*pDestAddr
,PDWORD pdwBestIfIndex
)
2548 DWORD WINAPI
NhpAllocateAndGetInterfaceInfoFromStack(IP_INTERFACE_NAME_INFO
**ppTable
,PDWORD pdwCount
,BOOL bOrder
,HANDLE hHeap
,DWORD dwFlags
)
2557 DWORD WINAPI
GetIcmpStatisticsEx(PMIB_ICMP_EX pStats
,DWORD dwFamily
)
2562 return ERROR_INVALID_PARAMETER
;
2564 if (dwFamily
!= AF_INET
&& dwFamily
!= AF_INET6
)
2565 return ERROR_INVALID_PARAMETER
;
2571 SetIpForwardEntryToStack(PMIB_IPFORWARDROW pRoute
)
2573 FIXME("SetIpForwardEntryToStack() stub\n");
2578 NhGetInterfaceNameFromDeviceGuid(DWORD dwUnknown1
,
2584 FIXME("NhGetInterfaceNameFromDeviceGuid() stub\n");