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
)
39 case DLL_PROCESS_ATTACH
:
40 DisableThreadLibraryCalls( hinstDLL
);
44 case DLL_PROCESS_DETACH
:
51 /******************************************************************
52 * AddIPAddress (IPHLPAPI.@)
61 * NTEInstance [In/Out]
68 DWORD WINAPI
AddIPAddress(IPAddr Address
, IPMask Netmask
, DWORD IfIndex
, PULONG NteContext
, PULONG NteInstance
)
70 return RtlNtStatusToDosError(addIPAddress(Address
, Netmask
, IfIndex
, NteContext
, NteInstance
));
73 DWORD
getInterfaceGatewayByIndex(DWORD index
)
75 DWORD ndx
, retVal
= 0, numRoutes
= getNumRoutes();
76 RouteTable
*table
= getRouteTable();
79 for (ndx
= 0; ndx
< numRoutes
; ndx
++)
81 if ((table
->routes
[ndx
].ifIndex
== (index
)) && (table
->routes
[ndx
].dest
== 0))
82 retVal
= table
->routes
[ndx
].gateway
;
84 HeapFree(GetProcessHeap(), 0, table
);
88 /******************************************************************
89 * AllocateAndGetIfTableFromStack (IPHLPAPI.@)
94 * ppIfTable [Out] -- pointer into which the MIB_IFTABLE is
95 * allocated and returned.
96 * bOrder [In] -- passed to GetIfTable to order the table
97 * heap [In] -- heap from which the table is allocated
98 * flags [In] -- flags to HeapAlloc
100 * RETURNS -- ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
101 * GetIfTable returns otherwise
104 DWORD WINAPI
AllocateAndGetIfTableFromStack(PMIB_IFTABLE
*ppIfTable
,
105 BOOL bOrder
, HANDLE heap
, DWORD flags
)
109 TRACE("ppIfTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n", ppIfTable
,
110 (DWORD
)bOrder
, (DWORD
)heap
, flags
);
112 ret
= ERROR_INVALID_PARAMETER
;
116 ret
= GetIfTable(*ppIfTable
, &dwSize
, bOrder
);
117 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
118 *ppIfTable
= (PMIB_IFTABLE
)HeapAlloc(heap
, flags
, dwSize
);
119 ret
= GetIfTable(*ppIfTable
, &dwSize
, bOrder
);
122 TRACE("returning %ld\n", ret
);
127 /******************************************************************
128 * AllocateAndGetIpAddrTableFromStack (IPHLPAPI.@)
133 * ppIpAddrTable [Out]
134 * bOrder [In] -- passed to GetIpAddrTable to order the table
135 * heap [In] -- heap from which the table is allocated
136 * flags [In] -- flags to HeapAlloc
143 DWORD WINAPI
AllocateAndGetIpAddrTableFromStack(PMIB_IPADDRTABLE
*ppIpAddrTable
,
144 BOOL bOrder
, HANDLE heap
, DWORD flags
)
148 TRACE("ppIpAddrTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
149 ppIpAddrTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
151 ret
= ERROR_INVALID_PARAMETER
;
155 ret
= GetIpAddrTable(*ppIpAddrTable
, &dwSize
, bOrder
);
156 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
157 *ppIpAddrTable
= (PMIB_IPADDRTABLE
)HeapAlloc(heap
, flags
, dwSize
);
158 ret
= GetIpAddrTable(*ppIpAddrTable
, &dwSize
, bOrder
);
161 TRACE("returning %ld\n", ret
);
166 /******************************************************************
167 * AllocateAndGetIpForwardTableFromStack (IPHLPAPI.@)
170 * ppIpForwardTable [Out] -- pointer into which the MIB_IPFORWARDTABLE is
171 * allocated and returned.
172 * bOrder [In] -- passed to GetIfTable to order the table
173 * heap [In] -- heap from which the table is allocated
174 * flags [In] -- flags to HeapAlloc
176 * RETURNS -- ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
177 * GetIpForwardTable returns otherwise
180 DWORD WINAPI
AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE
*
181 ppIpForwardTable
, BOOL bOrder
, HANDLE heap
, DWORD flags
)
185 TRACE("ppIpForwardTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
186 ppIpForwardTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
187 if (!ppIpForwardTable
)
188 ret
= ERROR_INVALID_PARAMETER
;
192 ret
= GetIpForwardTable(*ppIpForwardTable
, &dwSize
, bOrder
);
193 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
194 *ppIpForwardTable
= (PMIB_IPFORWARDTABLE
)HeapAlloc(heap
, flags
, dwSize
);
195 ret
= GetIpForwardTable(*ppIpForwardTable
, &dwSize
, bOrder
);
198 TRACE("returning %ld\n", ret
);
203 /******************************************************************
204 * AllocateAndGetIpNetTableFromStack (IPHLPAPI.@)
210 * bOrder [In] -- passed to GetIpNetTable to order the table
211 * heap [In] -- heap from which the table is allocated
212 * flags [In] -- flags to HeapAlloc
219 DWORD WINAPI
AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE
*ppIpNetTable
,
220 BOOL bOrder
, HANDLE heap
, DWORD flags
)
224 TRACE("ppIpNetTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
225 ppIpNetTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
227 ret
= ERROR_INVALID_PARAMETER
;
231 ret
= GetIpNetTable(*ppIpNetTable
, &dwSize
, bOrder
);
232 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
233 *ppIpNetTable
= (PMIB_IPNETTABLE
)HeapAlloc(heap
, flags
, dwSize
);
234 ret
= GetIpNetTable(*ppIpNetTable
, &dwSize
, bOrder
);
237 TRACE("returning %ld\n", ret
);
242 /******************************************************************
243 * AllocateAndGetTcpTableFromStack (IPHLPAPI.@)
249 * bOrder [In] -- passed to GetTcpTable to order the table
250 * heap [In] -- heap from which the table is allocated
251 * flags [In] -- flags to HeapAlloc
258 DWORD WINAPI
AllocateAndGetTcpTableFromStack(PMIB_TCPTABLE
*ppTcpTable
,
259 BOOL bOrder
, HANDLE heap
, DWORD flags
)
263 TRACE("ppTcpTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
264 ppTcpTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
266 ret
= ERROR_INVALID_PARAMETER
;
270 ret
= GetTcpTable(*ppTcpTable
, &dwSize
, bOrder
);
271 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
272 *ppTcpTable
= (PMIB_TCPTABLE
)HeapAlloc(heap
, flags
, dwSize
);
273 ret
= GetTcpTable(*ppTcpTable
, &dwSize
, bOrder
);
276 TRACE("returning %ld\n", ret
);
281 /******************************************************************
282 * AllocateAndGetUdpTableFromStack (IPHLPAPI.@)
288 * bOrder [In] -- passed to GetUdpTable to order the table
289 * heap [In] -- heap from which the table is allocated
290 * flags [In] -- flags to HeapAlloc
297 DWORD WINAPI
AllocateAndGetUdpTableFromStack(PMIB_UDPTABLE
*ppUdpTable
,
298 BOOL bOrder
, HANDLE heap
, DWORD flags
)
302 TRACE("ppUdpTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
303 ppUdpTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
305 ret
= ERROR_INVALID_PARAMETER
;
309 ret
= GetUdpTable(*ppUdpTable
, &dwSize
, bOrder
);
310 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
311 *ppUdpTable
= (PMIB_UDPTABLE
)HeapAlloc(heap
, flags
, dwSize
);
312 ret
= GetUdpTable(*ppUdpTable
, &dwSize
, bOrder
);
315 TRACE("returning %ld\n", ret
);
320 /******************************************************************
321 * CreateIpForwardEntry (IPHLPAPI.@)
333 DWORD WINAPI
CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
335 return createIpForwardEntry( pRoute
);
339 /******************************************************************
340 * CreateIpNetEntry (IPHLPAPI.@)
352 DWORD WINAPI
CreateIpNetEntry(PMIB_IPNETROW pArpEntry
)
354 TRACE("pArpEntry %p\n", pArpEntry
);
355 /* could use SIOCSARP on systems that support it, not sure I want to */
361 /******************************************************************
362 * CreateProxyArpEntry (IPHLPAPI.@)
376 DWORD WINAPI
CreateProxyArpEntry(DWORD dwAddress
, DWORD dwMask
, DWORD dwIfIndex
)
378 TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress
,
381 /* marking Win2K+ functions not supported */
382 return ERROR_NOT_SUPPORTED
;
386 /******************************************************************
387 * DeleteIPAddress (IPHLPAPI.@)
399 DWORD WINAPI
DeleteIPAddress(ULONG NTEContext
)
401 TRACE("NTEContext %ld\n", NTEContext
);
402 return RtlNtStatusToDosError(deleteIpAddress(NTEContext
));
406 /******************************************************************
407 * DeleteIpForwardEntry (IPHLPAPI.@)
419 DWORD WINAPI
DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
421 return deleteIpForwardEntry( pRoute
);
425 /******************************************************************
426 * DeleteIpNetEntry (IPHLPAPI.@)
438 DWORD WINAPI
DeleteIpNetEntry(PMIB_IPNETROW pArpEntry
)
440 TRACE("pArpEntry %p\n", pArpEntry
);
441 /* could use SIOCDARP on systems that support it, not sure I want to */
447 /******************************************************************
448 * DeleteProxyArpEntry (IPHLPAPI.@)
462 DWORD WINAPI
DeleteProxyArpEntry(DWORD dwAddress
, DWORD dwMask
, DWORD dwIfIndex
)
464 TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress
,
467 /* marking Win2K+ functions not supported */
468 return ERROR_NOT_SUPPORTED
;
471 /******************************************************************
472 * EnableRouter (IPHLPAPI.@)
478 * pOverlapped [In/Out]
485 DWORD WINAPI
EnableRouter(HANDLE
* pHandle
, OVERLAPPED
* pOverlapped
)
487 TRACE("pHandle %p, pOverlapped %p\n", pHandle
, pOverlapped
);
489 /* could echo "1" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
490 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
491 marking Win2K+ functions not supported */
492 return ERROR_NOT_SUPPORTED
;
496 /******************************************************************
497 * FlushIpNetTable (IPHLPAPI.@)
509 DWORD WINAPI
FlushIpNetTable(DWORD dwIfIndex
)
511 TRACE("dwIfIndex 0x%08lx\n", dwIfIndex
);
513 /* this flushes the arp cache of the given index
514 marking Win2K+ functions not supported */
515 return ERROR_NOT_SUPPORTED
;
519 /******************************************************************
520 * GetAdapterIndex (IPHLPAPI.@)
525 * AdapterName [In/Out]
533 DWORD WINAPI
GetAdapterIndex(LPWSTR AdapterName
, PULONG IfIndex
)
535 TRACE("AdapterName %p, IfIndex %p\n", AdapterName
, IfIndex
);
537 /* marking Win2K+ functions not supported */
538 return ERROR_NOT_SUPPORTED
;
542 /******************************************************************
543 * GetAdaptersInfo (IPHLPAPI.@)
548 * pAdapterInfo [In/Out]
549 * pOutBufLen [In/Out]
556 DWORD WINAPI
GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo
, PULONG pOutBufLen
)
562 TRACE("pAdapterInfo %p, pOutBufLen %p\n", pAdapterInfo
, pOutBufLen
);
564 ret
= ERROR_INVALID_PARAMETER
;
566 DWORD numNonLoopbackInterfaces
= getNumNonLoopbackInterfaces();
568 if (numNonLoopbackInterfaces
> 0) {
569 /* this calculation assumes only one address in the IP_ADDR_STRING lists.
570 that's okay, because:
571 - we don't get multiple addresses per adapter anyway
572 - we don't know about per-adapter gateways
573 - DHCP and WINS servers can have max one entry per list */
574 ULONG size
= sizeof(IP_ADAPTER_INFO
) * numNonLoopbackInterfaces
;
576 if (!pAdapterInfo
|| *pOutBufLen
< size
) {
578 ret
= ERROR_BUFFER_OVERFLOW
;
581 InterfaceIndexTable
*table
= getNonLoopbackInterfaceIndexTable();
584 size
= sizeof(IP_ADAPTER_INFO
) * table
->numIndexes
;
585 if (*pOutBufLen
< size
) {
587 ret
= ERROR_INSUFFICIENT_BUFFER
;
592 BOOL winsEnabled
= FALSE
;
593 IP_ADDRESS_STRING primaryWINS
, secondaryWINS
;
595 memset(pAdapterInfo
, 0, size
);
596 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
597 "Software\\Wine\\Wine\\Config\\Network", 0, KEY_READ
,
598 &hKey
) == ERROR_SUCCESS
) {
599 DWORD size
= sizeof(primaryWINS
.String
);
602 RegQueryValueExA(hKey
, "WinsServer", NULL
, NULL
,
603 (PBYTE
)primaryWINS
.String
, &size
);
604 addr
= inet_addr(primaryWINS
.String
);
605 if (addr
!= INADDR_NONE
&& addr
!= INADDR_ANY
)
607 size
= sizeof(secondaryWINS
.String
);
608 RegQueryValueExA(hKey
, "BackupWinsServer", NULL
, NULL
,
609 (PBYTE
)secondaryWINS
.String
, &size
);
610 addr
= inet_addr(secondaryWINS
.String
);
611 if (addr
!= INADDR_NONE
&& addr
!= INADDR_ANY
)
615 TRACE("num of index is %lu\n", table
->numIndexes
);
616 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
617 PIP_ADAPTER_INFO ptr
= &pAdapterInfo
[ndx
];
618 DWORD addrLen
= sizeof(ptr
->Address
), type
;
620 getInterfaceNameByIndex(table
->indexes
[ndx
]);
622 ret
= ERROR_OUTOFMEMORY
;
626 /* on Win98 this is left empty, but whatever */
627 strncpy(ptr
->AdapterName
,ifname
,sizeof(ptr
->AdapterName
));
628 consumeInterfaceName(ifname
);
629 ptr
->AdapterName
[MAX_ADAPTER_NAME_LENGTH
] = '\0';
630 getInterfacePhysicalByIndex(table
->indexes
[ndx
], &addrLen
,
631 ptr
->Address
, &type
);
632 /* MS defines address length and type as UINT in some places and
633 DWORD in others, **sigh**. Don't want to assume that PUINT and
634 PDWORD are equiv (64-bit?) */
635 ptr
->AddressLength
= addrLen
;
637 ptr
->Index
= table
->indexes
[ndx
];
638 toIPAddressString(getInterfaceIPAddrByIndex(table
->indexes
[ndx
]),
639 ptr
->IpAddressList
.IpAddress
.String
);
640 toIPAddressString(getInterfaceMaskByIndex(table
->indexes
[ndx
]),
641 ptr
->IpAddressList
.IpMask
.String
);
642 ptr
->IpAddressList
.Context
= ptr
->Index
;
643 toIPAddressString(getInterfaceGatewayByIndex(table
->indexes
[ndx
]),
644 ptr
->GatewayList
.IpAddress
.String
);
645 getDhcpInfoForAdapter(table
->indexes
[ndx
], &dhcpEnabled
,
646 &dhcpServer
, &ptr
->LeaseObtained
,
648 ptr
->DhcpEnabled
= (DWORD
) dhcpEnabled
;
649 toIPAddressString(dhcpServer
,
650 ptr
->DhcpServer
.IpAddress
.String
);
652 ptr
->HaveWins
= TRUE
;
653 memcpy(ptr
->PrimaryWinsServer
.IpAddress
.String
,
654 primaryWINS
.String
, sizeof(primaryWINS
.String
));
655 memcpy(ptr
->SecondaryWinsServer
.IpAddress
.String
,
656 secondaryWINS
.String
, sizeof(secondaryWINS
.String
));
658 if (ndx
< table
->numIndexes
- 1)
659 ptr
->Next
= &pAdapterInfo
[ndx
+ 1];
668 ret
= ERROR_OUTOFMEMORY
;
674 TRACE("returning %ld\n", ret
);
679 /******************************************************************
680 * GetBestInterface (IPHLPAPI.@)
686 * pdwBestIfIndex [In/Out]
693 DWORD WINAPI
GetBestInterface(IPAddr dwDestAddr
, PDWORD pdwBestIfIndex
)
697 TRACE("dwDestAddr 0x%08lx, pdwBestIfIndex %p\n", dwDestAddr
, pdwBestIfIndex
);
699 ret
= ERROR_INVALID_PARAMETER
;
701 MIB_IPFORWARDROW ipRow
;
703 ret
= GetBestRoute(dwDestAddr
, 0, &ipRow
);
704 if (ret
== ERROR_SUCCESS
)
705 *pdwBestIfIndex
= ipRow
.dwForwardIfIndex
;
707 TRACE("returning %ld\n", ret
);
712 /******************************************************************
713 * GetBestRoute (IPHLPAPI.@)
727 DWORD WINAPI
GetBestRoute(DWORD dwDestAddr
, DWORD dwSourceAddr
, PMIB_IPFORWARDROW pBestRoute
)
729 PMIB_IPFORWARDTABLE table
;
732 TRACE("dwDestAddr 0x%08lx, dwSourceAddr 0x%08lx, pBestRoute %p\n", dwDestAddr
,
733 dwSourceAddr
, pBestRoute
);
735 return ERROR_INVALID_PARAMETER
;
737 AllocateAndGetIpForwardTableFromStack(&table
, FALSE
, GetProcessHeap(), 0);
739 DWORD ndx
, matchedBits
, matchedNdx
= 0;
741 for (ndx
= 0, matchedBits
= 0; ndx
< table
->dwNumEntries
; ndx
++) {
742 if ((dwDestAddr
& table
->table
[ndx
].dwForwardMask
) ==
743 (table
->table
[ndx
].dwForwardDest
& table
->table
[ndx
].dwForwardMask
)) {
744 DWORD numShifts
, mask
;
746 for (numShifts
= 0, mask
= table
->table
[ndx
].dwForwardMask
;
747 mask
&& !(mask
& 1); mask
>>= 1, numShifts
++)
749 if (numShifts
> matchedBits
) {
750 matchedBits
= numShifts
;
755 memcpy(pBestRoute
, &table
->table
[matchedNdx
], sizeof(MIB_IPFORWARDROW
));
756 HeapFree(GetProcessHeap(), 0, table
);
760 ret
= ERROR_OUTOFMEMORY
;
761 TRACE("returning %ld\n", ret
);
765 /******************************************************************
766 * GetExtendedTcpTable (IPHLPAPI.@)
768 * Get the table of TCP endpoints available to the application.
771 * pTcpTable [Out] table struct with the filtered TCP endpoints available to application
772 * pdwSize [In/Out] estimated size of the structure returned in pTcpTable, in bytes
773 * bOrder [In] whether to order the table
774 * ulAf [in] version of IP used by the TCP endpoints
775 * TableClass [in] type of the TCP table structure from TCP_TABLE_CLASS
776 * Reserved [in] reserved - this value must be zero
780 * Failure: either ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER
784 DWORD WINAPI
GetExtendedTcpTable(PVOID pTcpTable
, PDWORD pdwSize
, BOOL bOrder
, ULONG ulAf
, TCP_TABLE_CLASS TableClass
, ULONG Reserved
)
786 DWORD ret
= NO_ERROR
;
792 /******************************************************************
793 * GetFriendlyIfIndex (IPHLPAPI.@)
805 DWORD WINAPI
GetFriendlyIfIndex(DWORD IfIndex
)
807 /* windows doesn't validate these, either, just makes sure the top byte is
808 cleared. I assume my ifenum module never gives an index with the top
810 TRACE("returning %ld\n", IfIndex
);
815 /******************************************************************
816 * GetIcmpStatistics (IPHLPAPI.@)
828 DWORD WINAPI
GetIcmpStatistics(PMIB_ICMP pStats
)
832 TRACE("pStats %p\n", pStats
);
833 ret
= getICMPStats(pStats
);
834 TRACE("returning %ld\n", ret
);
839 /******************************************************************
840 * GetIfEntry (IPHLPAPI.@)
852 DWORD WINAPI
GetIfEntry(PMIB_IFROW pIfRow
)
857 TRACE("pIfRow %p\n", pIfRow
);
859 return ERROR_INVALID_PARAMETER
;
861 name
= getInterfaceNameByIndex(pIfRow
->dwIndex
);
863 ret
= getInterfaceEntryByIndex(pIfRow
->dwIndex
, pIfRow
);
865 ret
= getInterfaceStatsByName(name
, pIfRow
);
866 consumeInterfaceName(name
);
869 ret
= ERROR_INVALID_DATA
;
870 TRACE("returning %ld\n", ret
);
875 static int IfTableSorter(const void *a
, const void *b
)
880 ret
= ((PMIB_IFROW
)a
)->dwIndex
- ((PMIB_IFROW
)b
)->dwIndex
;
887 /******************************************************************
888 * GetIfTable (IPHLPAPI.@)
902 DWORD WINAPI
GetIfTable(PMIB_IFTABLE pIfTable
, PULONG pdwSize
, BOOL bOrder
)
906 TRACE("pIfTable %p, pdwSize %p, bOrder %ld\n", pdwSize
, pdwSize
,
909 ret
= ERROR_INVALID_PARAMETER
;
911 DWORD numInterfaces
= getNumInterfaces();
913 TRACE("GetIfTable: numInterfaces = %d\n", (int)numInterfaces
);
914 size
= sizeof(MIB_IFTABLE
) + (numInterfaces
- 1) * sizeof(MIB_IFROW
);
916 if (!pIfTable
|| *pdwSize
< size
) {
918 ret
= ERROR_INSUFFICIENT_BUFFER
;
921 InterfaceIndexTable
*table
= getInterfaceIndexTable();
924 size
= sizeof(MIB_IFTABLE
) + (table
->numIndexes
- 1) *
926 if (*pdwSize
< size
) {
928 ret
= ERROR_INSUFFICIENT_BUFFER
;
933 pIfTable
->dwNumEntries
= 0;
934 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
935 pIfTable
->table
[ndx
].dwIndex
= table
->indexes
[ndx
];
936 GetIfEntry(&pIfTable
->table
[ndx
]);
937 pIfTable
->dwNumEntries
++;
940 qsort(pIfTable
->table
, pIfTable
->dwNumEntries
, sizeof(MIB_IFROW
),
947 ret
= ERROR_OUTOFMEMORY
;
950 TRACE("returning %ld\n", ret
);
955 /******************************************************************
956 * GetInterfaceInfo (IPHLPAPI.@)
962 * dwOutBufLen [In/Out]
969 DWORD WINAPI
GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable
, PULONG dwOutBufLen
)
973 TRACE("pIfTable %p, dwOutBufLen %p\n", pIfTable
, dwOutBufLen
);
975 ret
= ERROR_INVALID_PARAMETER
;
977 DWORD numNonLoopbackInterfaces
= getNumNonLoopbackInterfaces();
979 TRACE("numNonLoopbackInterfaces == 0x%x\n", numNonLoopbackInterfaces
);
980 size
= sizeof(IP_INTERFACE_INFO
) + (numNonLoopbackInterfaces
) *
981 sizeof(IP_ADAPTER_INDEX_MAP
);
983 if (!pIfTable
|| *dwOutBufLen
< size
) {
985 ret
= ERROR_INSUFFICIENT_BUFFER
;
988 InterfaceIndexTable
*table
= getNonLoopbackInterfaceIndexTable();
991 TRACE("table->numIndexes == 0x%x\n", table
->numIndexes
);
992 size
= sizeof(IP_INTERFACE_INFO
) + (table
->numIndexes
) *
993 sizeof(IP_ADAPTER_INDEX_MAP
);
994 if (*dwOutBufLen
< size
) {
996 ret
= ERROR_INSUFFICIENT_BUFFER
;
1001 pIfTable
->NumAdapters
= 0;
1002 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
1003 const char *walker
, *name
;
1006 pIfTable
->Adapter
[ndx
].Index
= table
->indexes
[ndx
];
1007 name
= getInterfaceNameByIndex(table
->indexes
[ndx
]);
1008 for (walker
= name
, assigner
= pIfTable
->Adapter
[ndx
].Name
;
1009 walker
&& *walker
&&
1010 assigner
- pIfTable
->Adapter
[ndx
].Name
< MAX_ADAPTER_NAME
- 1;
1011 walker
++, assigner
++)
1012 *assigner
= *walker
;
1014 consumeInterfaceName(name
);
1015 pIfTable
->NumAdapters
++;
1022 ret
= ERROR_OUTOFMEMORY
;
1025 TRACE("returning %ld\n", ret
);
1030 static int IpAddrTableSorter(const void *a
, const void *b
)
1035 ret
= ((PMIB_IPADDRROW
)a
)->dwAddr
- ((PMIB_IPADDRROW
)b
)->dwAddr
;
1042 /******************************************************************
1043 * GetIpAddrTable (IPHLPAPI.@)
1048 * pIpAddrTable [In/Out]
1057 DWORD WINAPI
GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable
, PULONG pdwSize
, BOOL bOrder
)
1061 TRACE("pIpAddrTable %p, pdwSize %p, bOrder %ld\n", pIpAddrTable
, pdwSize
,
1064 ret
= ERROR_INVALID_PARAMETER
;
1066 DWORD numInterfaces
= getNumInterfaces();
1067 ULONG size
= sizeof(MIB_IPADDRTABLE
) + (numInterfaces
- 1) *
1068 sizeof(MIB_IPADDRROW
);
1070 if (!pIpAddrTable
|| *pdwSize
< size
) {
1072 ret
= ERROR_INSUFFICIENT_BUFFER
;
1075 InterfaceIndexTable
*table
= getInterfaceIndexTable();
1078 size
= sizeof(MIB_IPADDRTABLE
) + (table
->numIndexes
- 1) *
1079 sizeof(MIB_IPADDRROW
);
1080 if (*pdwSize
< size
) {
1082 ret
= ERROR_INSUFFICIENT_BUFFER
;
1087 pIpAddrTable
->dwNumEntries
= 0;
1088 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
1089 pIpAddrTable
->table
[ndx
].dwIndex
= table
->indexes
[ndx
];
1090 pIpAddrTable
->table
[ndx
].dwAddr
=
1091 getInterfaceIPAddrByIndex(table
->indexes
[ndx
]);
1092 pIpAddrTable
->table
[ndx
].dwMask
=
1093 getInterfaceMaskByIndex(table
->indexes
[ndx
]);
1094 /* the dwBCastAddr member isn't the broadcast address, it indicates
1095 * whether the interface uses the 1's broadcast address (1) or the
1096 * 0's broadcast address (0).
1098 bcast
= getInterfaceBCastAddrByIndex(table
->indexes
[ndx
]);
1099 pIpAddrTable
->table
[ndx
].dwBCastAddr
=
1100 (bcast
& pIpAddrTable
->table
[ndx
].dwMask
) ? 1 : 0;
1101 /* FIXME: hardcoded reasm size, not sure where to get it */
1102 pIpAddrTable
->table
[ndx
].dwReasmSize
= 65535;
1103 pIpAddrTable
->table
[ndx
].unused1
= 0;
1104 pIpAddrTable
->table
[ndx
].wType
= 0; /* aka unused2 */
1105 pIpAddrTable
->dwNumEntries
++;
1108 qsort(pIpAddrTable
->table
, pIpAddrTable
->dwNumEntries
,
1109 sizeof(MIB_IPADDRROW
), IpAddrTableSorter
);
1115 ret
= ERROR_OUTOFMEMORY
;
1118 TRACE("returning %ld\n", ret
);
1123 static int IpForwardTableSorter(const void *a
, const void *b
)
1128 PMIB_IPFORWARDROW rowA
= (PMIB_IPFORWARDROW
)a
, rowB
= (PMIB_IPFORWARDROW
)b
;
1130 ret
= rowA
->dwForwardDest
- rowB
->dwForwardDest
;
1132 ret
= rowA
->dwForwardProto
- rowB
->dwForwardProto
;
1134 ret
= rowA
->dwForwardPolicy
- rowB
->dwForwardPolicy
;
1136 ret
= rowA
->dwForwardNextHop
- rowB
->dwForwardNextHop
;
1146 /******************************************************************
1147 * GetIpForwardTable (IPHLPAPI.@)
1152 * pIpForwardTable [In/Out]
1161 DWORD WINAPI
GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable
, PULONG pdwSize
, BOOL bOrder
)
1165 TRACE("pIpForwardTable %p, pdwSize %p, bOrder %ld\n", pIpForwardTable
,
1166 pdwSize
, (DWORD
)bOrder
);
1168 ret
= ERROR_INVALID_PARAMETER
;
1170 DWORD numRoutes
= getNumRoutes();
1171 ULONG sizeNeeded
= sizeof(MIB_IPFORWARDTABLE
) + (numRoutes
- 1) *
1172 sizeof(MIB_IPFORWARDROW
);
1174 if (!pIpForwardTable
|| *pdwSize
< sizeNeeded
) {
1175 *pdwSize
= sizeNeeded
;
1176 ret
= ERROR_INSUFFICIENT_BUFFER
;
1179 RouteTable
*table
= getRouteTable();
1181 sizeNeeded
= sizeof(MIB_IPFORWARDTABLE
) + (table
->numRoutes
- 1) *
1182 sizeof(MIB_IPFORWARDROW
);
1183 if (*pdwSize
< sizeNeeded
) {
1184 *pdwSize
= sizeNeeded
;
1185 ret
= ERROR_INSUFFICIENT_BUFFER
;
1190 pIpForwardTable
->dwNumEntries
= table
->numRoutes
;
1191 for (ndx
= 0; ndx
< numRoutes
; ndx
++) {
1192 pIpForwardTable
->table
[ndx
].dwForwardIfIndex
=
1193 table
->routes
[ndx
].ifIndex
;
1194 pIpForwardTable
->table
[ndx
].dwForwardDest
=
1195 table
->routes
[ndx
].dest
;
1196 pIpForwardTable
->table
[ndx
].dwForwardMask
=
1197 table
->routes
[ndx
].mask
;
1198 pIpForwardTable
->table
[ndx
].dwForwardPolicy
= 0;
1199 pIpForwardTable
->table
[ndx
].dwForwardNextHop
=
1200 table
->routes
[ndx
].gateway
;
1201 /* FIXME: this type is appropriate for local interfaces; may not
1202 always be appropriate */
1203 pIpForwardTable
->table
[ndx
].dwForwardType
= MIB_IPROUTE_TYPE_DIRECT
;
1204 /* FIXME: other protos might be appropriate, e.g. the default route
1205 is typically set with MIB_IPPROTO_NETMGMT instead */
1206 pIpForwardTable
->table
[ndx
].dwForwardProto
= MIB_IPPROTO_LOCAL
;
1207 /* punt on age and AS */
1208 pIpForwardTable
->table
[ndx
].dwForwardAge
= 0;
1209 pIpForwardTable
->table
[ndx
].dwForwardNextHopAS
= 0;
1210 pIpForwardTable
->table
[ndx
].dwForwardMetric1
=
1211 table
->routes
[ndx
].metric
;
1212 /* rest of the metrics are 0.. */
1213 pIpForwardTable
->table
[ndx
].dwForwardMetric2
= 0;
1214 pIpForwardTable
->table
[ndx
].dwForwardMetric3
= 0;
1215 pIpForwardTable
->table
[ndx
].dwForwardMetric4
= 0;
1216 pIpForwardTable
->table
[ndx
].dwForwardMetric5
= 0;
1219 qsort(pIpForwardTable
->table
, pIpForwardTable
->dwNumEntries
,
1220 sizeof(MIB_IPFORWARDROW
), IpForwardTableSorter
);
1223 HeapFree(GetProcessHeap(), 0, table
);
1226 ret
= ERROR_OUTOFMEMORY
;
1229 TRACE("returning %ld\n", ret
);
1234 static int IpNetTableSorter(const void *a
, const void *b
)
1239 ret
= ((PMIB_IPNETROW
)a
)->dwAddr
- ((PMIB_IPNETROW
)b
)->dwAddr
;
1246 /******************************************************************
1247 * GetIpNetTable (IPHLPAPI.@)
1252 * pIpNetTable [In/Out]
1261 DWORD WINAPI
GetIpNetTable(PMIB_IPNETTABLE pIpNetTable
, PULONG pdwSize
, BOOL bOrder
)
1263 DWORD ret
= NO_ERROR
;
1265 TRACE("pIpNetTable %p, pdwSize %p, bOrder %d\n", pIpNetTable
, pdwSize
,
1268 ret
= ERROR_INVALID_PARAMETER
;
1270 DWORD numEntries
= getNumArpEntries();
1271 ULONG size
= sizeof(MIB_IPNETTABLE
);
1274 size
+= (numEntries
- 1) * sizeof(MIB_IPNETROW
);
1275 if (!pIpNetTable
|| *pdwSize
< size
) {
1277 ret
= ERROR_INSUFFICIENT_BUFFER
;
1280 PMIB_IPNETTABLE table
= getArpTable();
1282 size
= sizeof(MIB_IPNETTABLE
);
1283 if (table
->dwNumEntries
> 1)
1284 size
+= (table
->dwNumEntries
- 1) * sizeof(MIB_IPNETROW
);
1285 if (*pdwSize
< size
) {
1287 ret
= ERROR_INSUFFICIENT_BUFFER
;
1291 memcpy(pIpNetTable
, table
, size
);
1293 qsort(pIpNetTable
->table
, pIpNetTable
->dwNumEntries
,
1294 sizeof(MIB_IPNETROW
), IpNetTableSorter
);
1297 HeapFree(GetProcessHeap(), 0, table
);
1301 TRACE("returning %d\n", ret
);
1306 /******************************************************************
1307 * GetIpStatistics (IPHLPAPI.@)
1319 DWORD WINAPI
GetIpStatistics(PMIB_IPSTATS pStats
)
1321 return GetIpStatisticsEx(pStats
, PF_INET
);
1324 /******************************************************************
1325 * GetIpStatisticsEx (IPHLPAPI.@)
1338 DWORD WINAPI
GetIpStatisticsEx(PMIB_IPSTATS pStats
, DWORD dwFamily
)
1342 TRACE("pStats %p\n", pStats
);
1343 ret
= getIPStats(pStats
, dwFamily
);
1344 TRACE("returning %ld\n", ret
);
1348 /******************************************************************
1349 * GetNetworkParams (IPHLPAPI.@)
1354 * pFixedInfo [In/Out]
1355 * pOutBufLen [In/Out]
1362 DWORD WINAPI
GetNetworkParams(PFIXED_INFO pFixedInfo
, PULONG pOutBufLen
)
1367 PIPHLP_RES_INFO resInfo
;
1369 TRACE("pFixedInfo %p, pOutBufLen %p\n", pFixedInfo
, pOutBufLen
);
1371 return ERROR_INVALID_PARAMETER
;
1373 resInfo
= getResInfo();
1375 return ERROR_OUTOFMEMORY
;
1377 size
= sizeof(FIXED_INFO
) + (resInfo
->riCount
> 1 ? (resInfo
->riCount
-1) *
1378 sizeof(IP_ADDR_STRING
) : 0);
1379 if (!pFixedInfo
|| *pOutBufLen
< size
) {
1381 disposeResInfo( resInfo
);
1382 return ERROR_BUFFER_OVERFLOW
;
1385 memset(pFixedInfo
, 0, size
);
1386 size
= sizeof(pFixedInfo
->HostName
);
1387 GetComputerNameExA(ComputerNameDnsHostname
, pFixedInfo
->HostName
, &size
);
1388 size
= sizeof(pFixedInfo
->DomainName
);
1389 GetComputerNameExA(ComputerNameDnsDomain
, pFixedInfo
->DomainName
, &size
);
1391 TRACE("GetComputerNameExA: %s\n", pFixedInfo
->DomainName
);
1393 if (resInfo
->riCount
> 0)
1395 CopyMemory(&pFixedInfo
->DnsServerList
, resInfo
->DnsList
, sizeof(IP_ADDR_STRING
));
1396 if (resInfo
->riCount
> 1)
1398 IP_ADDR_STRING
*pSrc
= resInfo
->DnsList
->Next
;
1399 IP_ADDR_STRING
*pTarget
= (struct _IP_ADDR_STRING
*)((char*)pFixedInfo
+ sizeof(FIXED_INFO
));
1401 pFixedInfo
->DnsServerList
.Next
= pTarget
;
1405 CopyMemory(pTarget
, pSrc
, sizeof(IP_ADDR_STRING
));
1407 if (resInfo
->riCount
> 1)
1409 pTarget
->Next
= (IP_ADDR_STRING
*)((char*)pTarget
+ sizeof(IP_ADDR_STRING
));
1410 pTarget
= pTarget
->Next
;
1415 pTarget
->Next
= NULL
;
1423 pFixedInfo
->DnsServerList
.Next
= NULL
;
1427 pFixedInfo
->NodeType
= HYBRID_NODETYPE
;
1428 regReturn
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
1429 "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", 0, KEY_READ
, &hKey
);
1430 if (regReturn
!= ERROR_SUCCESS
)
1431 regReturn
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
1432 "SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ
,
1434 if (regReturn
== ERROR_SUCCESS
)
1436 DWORD size
= sizeof(pFixedInfo
->ScopeId
);
1438 RegQueryValueExA(hKey
, "ScopeID", NULL
, NULL
, (PBYTE
)pFixedInfo
->ScopeId
, &size
);
1442 disposeResInfo( resInfo
);
1443 /* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
1444 I suppose could also check for a listener on port 53 to set EnableDns */
1446 TRACE("returning %ld\n", ret
);
1452 /******************************************************************
1453 * GetNumberOfInterfaces (IPHLPAPI.@)
1465 DWORD WINAPI
GetNumberOfInterfaces(PDWORD pdwNumIf
)
1469 TRACE("pdwNumIf %p\n", pdwNumIf
);
1471 ret
= ERROR_INVALID_PARAMETER
;
1473 *pdwNumIf
= getNumInterfaces();
1476 TRACE("returning %ld\n", ret
);
1481 /******************************************************************
1482 * GetOwnerModuleFromTcpEntry (IPHLPAPI.@)
1484 * Get data about the module that issued the context bind for a specific IPv4 TCP endpoint in a MIB table row
1487 * pTcpEntry [in] pointer to a MIB_TCPROW_OWNER_MODULE structure
1488 * Class [in] TCPIP_OWNER_MODULE_INFO_CLASS enumeration value
1489 * Buffer [out] pointer a buffer containing a TCPIP_OWNER_MODULE_BASIC_INFO structure with the owner module data.
1490 * pdwSize [in, out] estimated size of the structure returned in Buffer, in bytes
1494 * Failure: ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY
1495 * ERROR_NOT_FOUND or ERROR_PARTIAL_COPY
1498 * The type of data returned in Buffer is indicated by the value of the Class parameter.
1500 DWORD WINAPI
GetOwnerModuleFromTcpEntry( PMIB_TCPROW_OWNER_MODULE pTcpEntry
, TCPIP_OWNER_MODULE_INFO_CLASS Class
, PVOID Buffer
, PDWORD pdwSize
)
1502 DWORD ret
= NO_ERROR
;
1508 /******************************************************************
1509 * GetPerAdapterInfo (IPHLPAPI.@)
1515 * pPerAdapterInfo [In/Out]
1516 * pOutBufLen [In/Out]
1523 static void CreateNameServerListEnumNamesFunc( PWCHAR Interface
, PWCHAR Server
, PVOID Data
)
1525 IP_ADDR_STRING
*pNext
;
1526 PNAME_SERVER_LIST_CONTEXT Context
= (PNAME_SERVER_LIST_CONTEXT
)Data
;
1528 if (!Context
->NumServers
)
1530 if (Context
->uSizeAvailable
>= Context
->uSizeRequired
)
1532 WideCharToMultiByte(CP_ACP
, 0, Server
, -1, Context
->pData
->DnsServerList
.IpAddress
.String
, 16, NULL
, NULL
);
1533 Context
->pData
->DnsServerList
.IpAddress
.String
[15] = '\0';
1534 Context
->pLastAddr
= &Context
->pData
->DnsServerList
;
1539 Context
->uSizeRequired
+= sizeof(IP_ADDR_STRING
);
1540 if (Context
->uSizeAvailable
>= Context
->uSizeRequired
)
1542 pNext
= (IP_ADDR_STRING
*)(((char*)Context
->pLastAddr
) + sizeof(IP_ADDR_STRING
));
1543 WideCharToMultiByte(CP_ACP
, 0, Server
, -1, pNext
->IpAddress
.String
, 16, NULL
, NULL
);
1544 pNext
->IpAddress
.String
[15] = '\0';
1545 Context
->pLastAddr
->Next
= pNext
;
1546 Context
->pLastAddr
= pNext
;
1550 Context
->NumServers
++;
1553 DWORD WINAPI
GetPerAdapterInfo(ULONG IfIndex
, PIP_PER_ADAPTER_INFO pPerAdapterInfo
, PULONG pOutBufLen
)
1558 NAME_SERVER_LIST_CONTEXT Context
;
1559 WCHAR keyname
[200] = L
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\";
1562 return ERROR_INVALID_PARAMETER
;
1564 if (!pPerAdapterInfo
|| *pOutBufLen
< sizeof(IP_PER_ADAPTER_INFO
))
1566 *pOutBufLen
= sizeof(IP_PER_ADAPTER_INFO
);
1567 return ERROR_BUFFER_OVERFLOW
;
1570 ifName
= getInterfaceNameByIndex(IfIndex
);
1572 return ERROR_INVALID_PARAMETER
;
1574 MultiByteToWideChar(CP_ACP
, 0, ifName
, -1, &keyname
[62], sizeof(keyname
)/sizeof(WCHAR
) - 63);
1575 HeapFree(GetProcessHeap(), 0, (LPVOID
)ifName
);
1577 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, keyname
, 0, KEY_READ
, &hkey
) != ERROR_SUCCESS
)
1579 return ERROR_NOT_SUPPORTED
;
1581 Context
.NumServers
= 0;
1582 Context
.uSizeAvailable
= *pOutBufLen
;
1583 Context
.uSizeRequired
= sizeof(IP_PER_ADAPTER_INFO
);
1584 Context
.pData
= pPerAdapterInfo
;
1586 if (*pOutBufLen
>= sizeof(IP_PER_ADAPTER_INFO
))
1587 ZeroMemory(pPerAdapterInfo
, sizeof(IP_PER_ADAPTER_INFO
));
1589 EnumNameServers(hkey
, &keyname
[62], &Context
, CreateNameServerListEnumNamesFunc
);
1591 if (Context
.uSizeRequired
> Context
.uSizeAvailable
)
1593 *pOutBufLen
= Context
.uSizeRequired
;
1595 return ERROR_BUFFER_OVERFLOW
;
1598 if(RegQueryValueExW(hkey
, L
"NameServer", NULL
, NULL
, NULL
, &dwSize
) == ERROR_SUCCESS
)
1600 pPerAdapterInfo
->AutoconfigActive
= FALSE
;
1604 pPerAdapterInfo
->AutoconfigActive
= TRUE
;
1612 /******************************************************************
1613 * GetRTTAndHopCount (IPHLPAPI.@)
1618 * DestIpAddress [In]
1628 BOOL WINAPI
GetRTTAndHopCount(IPAddr DestIpAddress
, PULONG HopCount
, ULONG MaxHops
, PULONG RTT
)
1630 TRACE("DestIpAddress 0x%08lx, HopCount %p, MaxHops %ld, RTT %p\n",
1631 DestIpAddress
, HopCount
, MaxHops
, RTT
);
1637 /******************************************************************
1638 * GetTcpStatisticsEx (IPHLPAPI.@)
1651 DWORD WINAPI
GetTcpStatisticsEx(PMIB_TCPSTATS pStats
, DWORD dwFamily
)
1655 TRACE("pStats %p\n", pStats
);
1656 ret
= getTCPStats(pStats
, dwFamily
);
1657 TRACE("returning %ld\n", ret
);
1661 /******************************************************************
1662 * GetTcpStatistics (IPHLPAPI.@)
1674 DWORD WINAPI
GetTcpStatistics(PMIB_TCPSTATS pStats
)
1676 return GetTcpStatisticsEx(pStats
, PF_INET
);
1680 static int TcpTableSorter(const void *a
, const void *b
)
1685 PMIB_TCPROW rowA
= (PMIB_TCPROW
)a
, rowB
= (PMIB_TCPROW
)b
;
1687 ret
= rowA
->dwLocalAddr
- rowB
->dwLocalAddr
;
1689 ret
= rowA
->dwLocalPort
- rowB
->dwLocalPort
;
1691 ret
= rowA
->dwRemoteAddr
- rowB
->dwRemoteAddr
;
1693 ret
= rowA
->dwRemotePort
- rowB
->dwRemotePort
;
1703 /******************************************************************
1704 * GetTcpTable (IPHLPAPI.@)
1706 * Get the table of active TCP connections.
1709 * pTcpTable [Out] buffer for TCP connections table
1710 * pdwSize [In/Out] length of output buffer
1711 * bOrder [In] whether to order the table
1715 * Failure: error code from winerror.h
1718 * If pdwSize is less than required, the function will return
1719 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to
1720 * the required byte size.
1721 * If bOrder is true, the returned table will be sorted, first by
1722 * local address and port number, then by remote address and port
1725 DWORD WINAPI
GetTcpTable(PMIB_TCPTABLE pTcpTable
, PDWORD pdwSize
, BOOL bOrder
)
1727 DWORD ret
= ERROR_NO_DATA
;
1729 TRACE("pTcpTable %p, pdwSize %p, bOrder %d\n", pTcpTable
, pdwSize
,
1732 ret
= ERROR_INVALID_PARAMETER
;
1734 DWORD numEntries
= getNumTcpEntries();
1735 DWORD size
= sizeof(MIB_TCPTABLE
);
1738 size
+= (numEntries
- 1) * sizeof(MIB_TCPROW
);
1739 if (!pTcpTable
|| *pdwSize
< size
) {
1741 ret
= ERROR_INSUFFICIENT_BUFFER
;
1744 PMIB_TCPTABLE pOurTcpTable
= getTcpTable();
1747 size
= sizeof(MIB_TCPTABLE
);
1748 if (pOurTcpTable
->dwNumEntries
> 1)
1749 size
+= (pOurTcpTable
->dwNumEntries
- 1) * sizeof(MIB_TCPROW
);
1751 if (*pdwSize
< size
)
1755 ret
= ERROR_INSUFFICIENT_BUFFER
;
1759 memcpy(pTcpTable
, pOurTcpTable
, size
);
1762 qsort(pTcpTable
->table
, pTcpTable
->dwNumEntries
,
1763 sizeof(MIB_TCPROW
), TcpTableSorter
);
1772 TRACE("returning %d\n", ret
);
1777 /******************************************************************
1778 * GetUdpStatisticsEx (IPHLPAPI.@)
1791 DWORD WINAPI
GetUdpStatisticsEx(PMIB_UDPSTATS pStats
, DWORD dwFamily
)
1795 TRACE("pStats %p\n", pStats
);
1796 ret
= getUDPStats(pStats
, dwFamily
);
1797 TRACE("returning %ld\n", ret
);
1801 /******************************************************************
1802 * GetUdpStatistics (IPHLPAPI.@)
1814 DWORD WINAPI
GetUdpStatistics(PMIB_UDPSTATS pStats
)
1816 return GetUdpStatisticsEx(pStats
, PF_INET
);
1820 static int UdpTableSorter(const void *a
, const void *b
)
1825 PMIB_UDPROW rowA
= (PMIB_UDPROW
)a
, rowB
= (PMIB_UDPROW
)b
;
1827 ret
= rowA
->dwLocalAddr
- rowB
->dwLocalAddr
;
1829 ret
= rowA
->dwLocalPort
- rowB
->dwLocalPort
;
1837 /******************************************************************
1838 * GetUdpTable (IPHLPAPI.@)
1843 * pUdpTable [In/Out]
1852 DWORD WINAPI
GetUdpTable(PMIB_UDPTABLE pUdpTable
, PDWORD pdwSize
, BOOL bOrder
)
1856 TRACE("pUdpTable %p, pdwSize %p, bOrder %ld\n", pUdpTable
, pdwSize
,
1859 ret
= ERROR_INVALID_PARAMETER
;
1861 DWORD numEntries
= getNumUdpEntries();
1862 ULONG size
= sizeof(MIB_UDPTABLE
) + (numEntries
- 1) * sizeof(MIB_UDPROW
);
1864 if (!pUdpTable
|| *pdwSize
< size
) {
1866 ret
= ERROR_INSUFFICIENT_BUFFER
;
1869 PMIB_UDPTABLE table
= getUdpTable();
1872 size
= sizeof(MIB_UDPTABLE
) + (table
->dwNumEntries
- 1) *
1874 if (*pdwSize
< size
) {
1876 ret
= ERROR_INSUFFICIENT_BUFFER
;
1879 memcpy(pUdpTable
, table
, size
);
1881 qsort(pUdpTable
->table
, pUdpTable
->dwNumEntries
,
1882 sizeof(MIB_UDPROW
), UdpTableSorter
);
1888 ret
= ERROR_OUTOFMEMORY
;
1891 TRACE("returning %ld\n", ret
);
1896 /******************************************************************
1897 * GetUniDirectionalAdapterInfo (IPHLPAPI.@)
1899 * This is a Win98-only function to get information on "unidirectional"
1900 * adapters. Since this is pretty nonsensical in other contexts, it
1901 * never returns anything.
1904 * pIPIfInfo [Out] buffer for adapter infos
1905 * dwOutBufLen [Out] length of the output buffer
1909 * Failure: error code from winerror.h
1912 * Stub, returns ERROR_NOT_SUPPORTED.
1914 DWORD WINAPI
GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo
, PULONG dwOutBufLen
)
1916 TRACE("pIPIfInfo %p, dwOutBufLen %p\n", pIPIfInfo
, dwOutBufLen
);
1917 /* a unidirectional adapter?? not bloody likely! */
1918 return ERROR_NOT_SUPPORTED
;
1922 /******************************************************************
1923 * IpReleaseAddress (IPHLPAPI.@)
1925 * Release an IP obtained through DHCP,
1928 * AdapterInfo [In] adapter to release IP address
1932 * Failure: error code from winerror.h
1935 DWORD WINAPI
IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo
)
1937 DWORD Status
, Version
= 0;
1939 if (!AdapterInfo
|| !AdapterInfo
->Name
)
1940 return ERROR_INVALID_PARAMETER
;
1942 /* Maybe we should do this in DllMain */
1943 if (DhcpCApiInitialize(&Version
) != ERROR_SUCCESS
)
1944 return ERROR_PROC_NOT_FOUND
;
1946 if (DhcpReleaseIpAddressLease(AdapterInfo
->Index
))
1947 Status
= ERROR_SUCCESS
;
1949 Status
= ERROR_PROC_NOT_FOUND
;
1957 /******************************************************************
1958 * IpRenewAddress (IPHLPAPI.@)
1960 * Renew an IP obtained through DHCP.
1963 * AdapterInfo [In] adapter to renew IP address
1967 * Failure: error code from winerror.h
1969 DWORD WINAPI
IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo
)
1971 DWORD Status
, Version
= 0;
1973 if (!AdapterInfo
|| !AdapterInfo
->Name
)
1974 return ERROR_INVALID_PARAMETER
;
1976 /* Maybe we should do this in DllMain */
1977 if (DhcpCApiInitialize(&Version
) != ERROR_SUCCESS
)
1978 return ERROR_PROC_NOT_FOUND
;
1980 if (DhcpRenewIpAddressLease(AdapterInfo
->Index
))
1981 Status
= ERROR_SUCCESS
;
1983 Status
= ERROR_PROC_NOT_FOUND
;
1991 /******************************************************************
1992 * NotifyAddrChange (IPHLPAPI.@)
1994 * Notify caller whenever the ip-interface map is changed.
1997 * Handle [Out] handle usable in asynchronous notification
1998 * overlapped [In] overlapped structure that notifies the caller
2002 * Failure: error code from winerror.h
2005 * Stub, returns ERROR_NOT_SUPPORTED.
2007 DWORD WINAPI
NotifyAddrChange(PHANDLE Handle
, LPOVERLAPPED overlapped
)
2009 FIXME("(Handle %p, overlapped %p): stub\n", Handle
, overlapped
);
2010 return ERROR_NOT_SUPPORTED
;
2014 /******************************************************************
2015 * NotifyRouteChange (IPHLPAPI.@)
2017 * Notify caller whenever the ip routing table is changed.
2020 * Handle [Out] handle usable in asynchronous notification
2021 * overlapped [In] overlapped structure that notifies the caller
2025 * Failure: error code from winerror.h
2028 * Stub, returns ERROR_NOT_SUPPORTED.
2030 DWORD WINAPI
NotifyRouteChange(PHANDLE Handle
, LPOVERLAPPED overlapped
)
2032 FIXME("(Handle %p, overlapped %p): stub\n", Handle
, overlapped
);
2033 return ERROR_NOT_SUPPORTED
;
2037 /******************************************************************
2038 * SendARP (IPHLPAPI.@)
2040 * Send an ARP request.
2043 * DestIP [In] attempt to obtain this IP
2044 * SrcIP [In] optional sender IP address
2045 * pMacAddr [Out] buffer for the mac address
2046 * PhyAddrLen [In/Out] length of the output buffer
2050 * Failure: error code from winerror.h
2053 * Stub, returns ERROR_NOT_SUPPORTED.
2055 DWORD WINAPI
SendARP(IPAddr DestIP
, IPAddr SrcIP
, PULONG pMacAddr
, PULONG PhyAddrLen
)
2057 FIXME("(DestIP 0x%08x, SrcIP 0x%08x, pMacAddr %p, PhyAddrLen %p): stub\n",
2058 DestIP
, SrcIP
, pMacAddr
, PhyAddrLen
);
2059 return ERROR_NOT_SUPPORTED
;
2063 /******************************************************************
2064 * SetIfEntry (IPHLPAPI.@)
2066 * Set the administrative status of an interface.
2069 * pIfRow [In] dwAdminStatus member specifies the new status.
2073 * Failure: error code from winerror.h
2076 * Stub, returns ERROR_NOT_SUPPORTED.
2078 DWORD WINAPI
SetIfEntry(PMIB_IFROW pIfRow
)
2080 FIXME("(pIfRow %p): stub\n", pIfRow
);
2081 /* this is supposed to set an interface administratively up or down.
2082 Could do SIOCSIFFLAGS and set/clear IFF_UP, but, not sure I want to, and
2083 this sort of down is indistinguishable from other sorts of down (e.g. no
2085 return ERROR_NOT_SUPPORTED
;
2089 /******************************************************************
2090 * SetIpForwardEntry (IPHLPAPI.@)
2092 * Modify an existing route.
2095 * pRoute [In] route with the new information
2099 * Failure: error code from winerror.h
2102 DWORD WINAPI
SetIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
2104 return setIpForwardEntry( pRoute
);
2108 /******************************************************************
2109 * SetIpNetEntry (IPHLPAPI.@)
2111 * Modify an existing ARP entry.
2114 * pArpEntry [In] ARP entry with the new information
2118 * Failure: error code from winerror.h
2120 DWORD WINAPI
SetIpNetEntry(PMIB_IPNETROW pArpEntry
)
2124 TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY req
=
2125 TCP_REQUEST_SET_INFORMATION_INIT
;
2128 PMIB_IPNETROW arpBuff
;
2131 return ERROR_INVALID_PARAMETER
;
2133 if (!NT_SUCCESS(openTcpFile( &tcpFile
)))
2134 return ERROR_NOT_SUPPORTED
;
2136 if (!NT_SUCCESS(getNthIpEntity( tcpFile
, pArpEntry
->dwIndex
, &id
)))
2138 closeTcpFile(tcpFile
);
2139 return ERROR_INVALID_PARAMETER
;
2142 req
.Req
.ID
.toi_class
= INFO_CLASS_PROTOCOL
;
2143 req
.Req
.ID
.toi_type
= INFO_TYPE_PROVIDER
;
2144 req
.Req
.ID
.toi_id
= IP_MIB_ARPTABLE_ENTRY_ID
;
2145 req
.Req
.ID
.toi_entity
.tei_instance
= id
.tei_instance
;
2146 req
.Req
.ID
.toi_entity
.tei_entity
= AT_ENTITY
;
2147 req
.Req
.BufferSize
= sizeof(MIB_IPNETROW
);
2148 arpBuff
= (PMIB_IPNETROW
)&req
.Req
.Buffer
[0];
2150 RtlCopyMemory(arpBuff
, pArpEntry
, sizeof(MIB_IPNETROW
));
2152 status
= DeviceIoControl( tcpFile
,
2153 IOCTL_TCP_SET_INFORMATION_EX
,
2161 closeTcpFile(tcpFile
);
2166 return ERROR_INVALID_PARAMETER
;
2170 /******************************************************************
2171 * SetIpStatistics (IPHLPAPI.@)
2173 * Toggle IP forwarding and det the default TTL value.
2176 * pIpStats [In] IP statistics with the new information
2180 * Failure: error code from winerror.h
2183 * Stub, returns NO_ERROR.
2185 DWORD WINAPI
SetIpStatistics(PMIB_IPSTATS pIpStats
)
2187 FIXME("(pIpStats %p): stub\n", pIpStats
);
2192 /******************************************************************
2193 * SetIpTTL (IPHLPAPI.@)
2195 * Set the default TTL value.
2198 * nTTL [In] new TTL value
2202 * Failure: error code from winerror.h
2205 * Stub, returns NO_ERROR.
2207 DWORD WINAPI
SetIpTTL(UINT nTTL
)
2209 FIXME("(nTTL %d): stub\n", nTTL
);
2214 /******************************************************************
2215 * SetTcpEntry (IPHLPAPI.@)
2217 * Set the state of a TCP connection.
2220 * pTcpRow [In] specifies connection with new state
2224 * Failure: error code from winerror.h
2227 * Stub, returns NO_ERROR.
2229 DWORD WINAPI
SetTcpEntry(PMIB_TCPROW pTcpRow
)
2231 FIXME("(pTcpRow %p): stub\n", pTcpRow
);
2236 /******************************************************************
2237 * UnenableRouter (IPHLPAPI.@)
2239 * Decrement the IP-forwarding reference count. Turn off IP-forwarding
2240 * if it reaches zero.
2243 * pOverlapped [In/Out] should be the same as in EnableRouter()
2244 * lpdwEnableCount [Out] optional, receives reference count
2248 * Failure: error code from winerror.h
2251 * Stub, returns ERROR_NOT_SUPPORTED.
2253 DWORD WINAPI
UnenableRouter(OVERLAPPED
* pOverlapped
, LPDWORD lpdwEnableCount
)
2255 FIXME("(pOverlapped %p, lpdwEnableCount %p): stub\n", pOverlapped
,
2257 return ERROR_NOT_SUPPORTED
;
2263 DWORD WINAPI
GetIpErrorString(IP_STATUS ErrorCode
,PWCHAR Buffer
,PDWORD Size
)
2273 PIP_ADAPTER_ORDER_MAP WINAPI
GetAdapterOrderMap(VOID
)
2282 DWORD WINAPI
GetAdaptersAddresses(ULONG Family
,ULONG Flags
,PVOID Reserved
,PIP_ADAPTER_ADDRESSES pAdapterAddresses
,PULONG pOutBufLen
)
2285 InterfaceIndexTable
*indexTable
;
2288 ULONG ret
, requiredSize
= 0;
2289 PIP_ADAPTER_ADDRESSES currentAddress
;
2290 PUCHAR currentLocation
;
2293 if (!pOutBufLen
) return ERROR_INVALID_PARAMETER
;
2294 if (Reserved
) return ERROR_INVALID_PARAMETER
;
2296 indexTable
= getNonLoopbackInterfaceIndexTable(); //I think we want non-loopback here
2298 return ERROR_NOT_ENOUGH_MEMORY
;
2300 ret
= openTcpFile(&tcpFile
);
2301 if (!NT_SUCCESS(ret
))
2302 return ERROR_NO_DATA
;
2304 for (i
= indexTable
->numIndexes
; i
>= 0; i
--)
2306 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile
,
2308 indexTable
->indexes
[i
],
2311 /* The whole struct */
2312 requiredSize
+= sizeof(IP_ADAPTER_ADDRESSES
);
2315 if (!(Flags
& GAA_FLAG_SKIP_FRIENDLY_NAME
))
2316 requiredSize
+= strlen((char *)ifInfo
.if_info
.ent
.if_descr
) + 1; //FIXME
2319 requiredSize
+= strlen((char *)ifInfo
.if_info
.ent
.if_descr
) + 1;
2321 /* Unicast address */
2322 if (!(Flags
& GAA_FLAG_SKIP_UNICAST
))
2323 requiredSize
+= sizeof(IP_ADAPTER_UNICAST_ADDRESS
);
2325 /* FIXME: Implement multicast, anycast, and dns server stuff */
2327 /* FIXME: Implement dns suffix and description */
2328 requiredSize
+= 2 * sizeof(WCHAR
);
2330 /* We're only going to implement what's required for XP SP0 */
2334 if (*pOutBufLen
< requiredSize
)
2336 *pOutBufLen
= requiredSize
;
2337 closeTcpFile(tcpFile
);
2339 return ERROR_BUFFER_OVERFLOW
;
2342 RtlZeroMemory(pAdapterAddresses
, requiredSize
);
2344 /* Let's set up the pointers */
2345 currentAddress
= pAdapterAddresses
;
2346 for (i
= indexTable
->numIndexes
; i
>= 0; i
--)
2348 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile
,
2350 indexTable
->indexes
[i
],
2353 currentLocation
= (PUCHAR
)currentAddress
+ (ULONG_PTR
)sizeof(IP_ADAPTER_ADDRESSES
);
2355 /* FIXME: Friendly name */
2356 if (!(Flags
& GAA_FLAG_SKIP_FRIENDLY_NAME
))
2358 currentAddress
->FriendlyName
= (PVOID
)currentLocation
;
2359 currentLocation
+= sizeof(WCHAR
);
2363 currentAddress
->AdapterName
= (PVOID
)currentLocation
;
2364 currentLocation
+= strlen((char *)ifInfo
.if_info
.ent
.if_descr
) + 1;
2366 /* Unicast address */
2367 if (!(Flags
& GAA_FLAG_SKIP_UNICAST
))
2369 currentAddress
->FirstUnicastAddress
= (PVOID
)currentLocation
;
2370 currentLocation
+= sizeof(IP_ADAPTER_UNICAST_ADDRESS
);
2371 currentAddress
->FirstUnicastAddress
->Address
.lpSockaddr
= (PVOID
)currentLocation
;
2372 currentLocation
+= sizeof(struct sockaddr
);
2375 /* FIXME: Implement multicast, anycast, and dns server stuff */
2377 /* FIXME: Implement dns suffix and description */
2378 currentAddress
->DnsSuffix
= (PVOID
)currentLocation
;
2379 currentLocation
+= sizeof(WCHAR
);
2381 currentAddress
->Description
= (PVOID
)currentLocation
;
2382 currentLocation
+= sizeof(WCHAR
);
2384 currentAddress
->Next
= (PVOID
)currentLocation
;
2386 /* We're only going to implement what's required for XP SP0 */
2388 currentAddress
= currentAddress
->Next
;
2392 /* Terminate the last address correctly */
2394 currentAddress
->Next
= NULL
;
2396 /* Now again, for real this time */
2398 currentAddress
= pAdapterAddresses
;
2399 for (i
= indexTable
->numIndexes
; i
>= 0; i
--)
2401 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile
,
2403 indexTable
->indexes
[i
],
2406 /* Make sure we're not looping more than we hoped for */
2407 ASSERT(currentAddress
);
2409 /* Alignment information */
2410 currentAddress
->Length
= sizeof(IP_ADAPTER_ADDRESSES
);
2411 currentAddress
->IfIndex
= indexTable
->indexes
[i
];
2414 strcpy(currentAddress
->AdapterName
, (char *)ifInfo
.if_info
.ent
.if_descr
);
2416 if (!(Flags
& GAA_FLAG_SKIP_UNICAST
))
2418 currentAddress
->FirstUnicastAddress
->Length
= sizeof(IP_ADAPTER_UNICAST_ADDRESS
);
2419 currentAddress
->FirstUnicastAddress
->Flags
= 0; //FIXME
2420 currentAddress
->FirstUnicastAddress
->Next
= NULL
; //FIXME: Support more than one address per adapter
2421 currentAddress
->FirstUnicastAddress
->Address
.lpSockaddr
->sa_family
= AF_INET
;
2422 memcpy(currentAddress
->FirstUnicastAddress
->Address
.lpSockaddr
->sa_data
,
2423 &ifInfo
.ip_addr
.iae_addr
,
2424 sizeof(ifInfo
.ip_addr
.iae_addr
));
2425 currentAddress
->FirstUnicastAddress
->Address
.iSockaddrLength
= sizeof(ifInfo
.ip_addr
.iae_addr
) + sizeof(USHORT
);
2426 currentAddress
->FirstUnicastAddress
->PrefixOrigin
= IpPrefixOriginOther
; //FIXME
2427 currentAddress
->FirstUnicastAddress
->SuffixOrigin
= IpPrefixOriginOther
; //FIXME
2428 currentAddress
->FirstUnicastAddress
->DadState
= IpDadStatePreferred
; //FIXME
2429 currentAddress
->FirstUnicastAddress
->ValidLifetime
= 0xFFFFFFFF; //FIXME
2430 currentAddress
->FirstUnicastAddress
->PreferredLifetime
= 0xFFFFFFFF; //FIXME
2431 currentAddress
->FirstUnicastAddress
->LeaseLifetime
= 0xFFFFFFFF; //FIXME
2434 /* FIXME: Implement multicast, anycast, and dns server stuff */
2435 currentAddress
->FirstAnycastAddress
= NULL
;
2436 currentAddress
->FirstMulticastAddress
= NULL
;
2437 currentAddress
->FirstDnsServerAddress
= NULL
;
2439 /* FIXME: Implement dns suffix, description, and friendly name */
2440 currentAddress
->DnsSuffix
[0] = UNICODE_NULL
;
2441 currentAddress
->Description
[0] = UNICODE_NULL
;
2442 currentAddress
->FriendlyName
[0] = UNICODE_NULL
;
2444 /* Physical Address */
2445 memcpy(currentAddress
->PhysicalAddress
, ifInfo
.if_info
.ent
.if_physaddr
, ifInfo
.if_info
.ent
.if_physaddrlen
);
2446 currentAddress
->PhysicalAddressLength
= ifInfo
.if_info
.ent
.if_physaddrlen
;
2449 currentAddress
->Flags
= 0; //FIXME
2452 currentAddress
->Mtu
= ifInfo
.if_info
.ent
.if_mtu
;
2454 /* Interface type */
2455 currentAddress
->IfType
= ifInfo
.if_info
.ent
.if_type
;
2457 /* Operational status */
2458 currentAddress
->OperStatus
= ifInfo
.if_info
.ent
.if_operstatus
;
2460 /* We're only going to implement what's required for XP SP0 */
2462 /* Move to the next address */
2463 currentAddress
= currentAddress
->Next
;
2467 closeTcpFile(tcpFile
);
2472 if (!pOutBufLen
) return ERROR_INVALID_PARAMETER
;
2473 if (!pAdapterAddresses
|| *pOutBufLen
== 0)
2474 return ERROR_BUFFER_OVERFLOW
;
2475 if (Reserved
) return ERROR_INVALID_PARAMETER
;
2478 return ERROR_NO_DATA
;
2485 BOOL WINAPI
CancelIPChangeNotify(LPOVERLAPPED notifyOverlapped
)
2494 DWORD WINAPI
GetBestInterfaceEx(struct sockaddr
*pDestAddr
,PDWORD pdwBestIfIndex
)
2503 DWORD WINAPI
NhpAllocateAndGetInterfaceInfoFromStack(IP_INTERFACE_NAME_INFO
**ppTable
,PDWORD pdwCount
,BOOL bOrder
,HANDLE hHeap
,DWORD dwFlags
)
2512 DWORD WINAPI
GetIcmpStatisticsEx(PMIB_ICMP_EX pStats
,DWORD dwFamily
)
2518 /******************************************************************
2519 * GetIfTable2 (IPHLPAPI.@)
2525 NETIOAPI_API WINAPI
GetIfTable2(PMIB_IF_TABLE2
*pIfTable
)
2528 return ERROR_NOT_SUPPORTED
;
2531 /******************************************************************
2532 * GetIfEntry2 (IPHLPAPI.@)
2537 NETIOAPI_API WINAPI
GetIfEntry2(IN OUT PMIB_IF_ROW2 pIfRow
)
2539 TRACE("pIfRow %p\n", pIfRow
);
2541 return ERROR_INVALID_PARAMETER
;
2544 return ERROR_NOT_SUPPORTED
;
2548 SetIpForwardEntryToStack(PMIB_IPFORWARDROW pRoute
)
2550 FIXME("SetIpForwardEntryToStack() stub\n");
2555 NhGetInterfaceNameFromDeviceGuid(DWORD dwUnknown1
,
2561 FIXME("NhGetInterfaceNameFromDeviceGuid() stub\n");