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
;
120 ret
= GetIfTable(*ppIfTable
, &dwSize
, bOrder
);
121 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
122 *ppIfTable
= (PMIB_IFTABLE
)HeapAlloc(heap
, flags
, dwSize
);
123 ret
= GetIfTable(*ppIfTable
, &dwSize
, bOrder
);
126 TRACE("returning %ld\n", ret
);
131 /******************************************************************
132 * AllocateAndGetIpAddrTableFromStack (IPHLPAPI.@)
137 * ppIpAddrTable [Out]
138 * bOrder [In] -- passed to GetIpAddrTable to order the table
139 * heap [In] -- heap from which the table is allocated
140 * flags [In] -- flags to HeapAlloc
147 DWORD WINAPI
AllocateAndGetIpAddrTableFromStack(PMIB_IPADDRTABLE
*ppIpAddrTable
,
148 BOOL bOrder
, HANDLE heap
, DWORD flags
)
152 TRACE("ppIpAddrTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
153 ppIpAddrTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
155 ret
= ERROR_INVALID_PARAMETER
;
159 ret
= GetIpAddrTable(*ppIpAddrTable
, &dwSize
, bOrder
);
160 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
161 *ppIpAddrTable
= (PMIB_IPADDRTABLE
)HeapAlloc(heap
, flags
, dwSize
);
162 ret
= GetIpAddrTable(*ppIpAddrTable
, &dwSize
, bOrder
);
165 TRACE("returning %ld\n", ret
);
170 /******************************************************************
171 * AllocateAndGetIpForwardTableFromStack (IPHLPAPI.@)
174 * ppIpForwardTable [Out] -- pointer into which the MIB_IPFORWARDTABLE is
175 * allocated and returned.
176 * bOrder [In] -- passed to GetIfTable to order the table
177 * heap [In] -- heap from which the table is allocated
178 * flags [In] -- flags to HeapAlloc
180 * RETURNS -- ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
181 * GetIpForwardTable returns otherwise
184 DWORD WINAPI
AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE
*
185 ppIpForwardTable
, BOOL bOrder
, HANDLE heap
, DWORD flags
)
189 TRACE("ppIpForwardTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
190 ppIpForwardTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
191 if (!ppIpForwardTable
)
192 ret
= ERROR_INVALID_PARAMETER
;
196 ret
= GetIpForwardTable(*ppIpForwardTable
, &dwSize
, bOrder
);
197 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
198 *ppIpForwardTable
= (PMIB_IPFORWARDTABLE
)HeapAlloc(heap
, flags
, dwSize
);
199 ret
= GetIpForwardTable(*ppIpForwardTable
, &dwSize
, bOrder
);
202 TRACE("returning %ld\n", ret
);
207 /******************************************************************
208 * AllocateAndGetIpNetTableFromStack (IPHLPAPI.@)
214 * bOrder [In] -- passed to GetIpNetTable to order the table
215 * heap [In] -- heap from which the table is allocated
216 * flags [In] -- flags to HeapAlloc
223 DWORD WINAPI
AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE
*ppIpNetTable
,
224 BOOL bOrder
, HANDLE heap
, DWORD flags
)
228 TRACE("ppIpNetTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
229 ppIpNetTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
231 ret
= ERROR_INVALID_PARAMETER
;
235 ret
= GetIpNetTable(*ppIpNetTable
, &dwSize
, bOrder
);
236 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
237 *ppIpNetTable
= (PMIB_IPNETTABLE
)HeapAlloc(heap
, flags
, dwSize
);
238 ret
= GetIpNetTable(*ppIpNetTable
, &dwSize
, bOrder
);
241 TRACE("returning %ld\n", ret
);
246 /******************************************************************
247 * AllocateAndGetTcpTableFromStack (IPHLPAPI.@)
253 * bOrder [In] -- passed to GetTcpTable to order the table
254 * heap [In] -- heap from which the table is allocated
255 * flags [In] -- flags to HeapAlloc
262 DWORD WINAPI
AllocateAndGetTcpTableFromStack(PMIB_TCPTABLE
*ppTcpTable
,
263 BOOL bOrder
, HANDLE heap
, DWORD flags
)
267 TRACE("ppTcpTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
268 ppTcpTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
270 ret
= ERROR_INVALID_PARAMETER
;
274 ret
= GetTcpTable(*ppTcpTable
, &dwSize
, bOrder
);
275 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
276 *ppTcpTable
= (PMIB_TCPTABLE
)HeapAlloc(heap
, flags
, dwSize
);
277 ret
= GetTcpTable(*ppTcpTable
, &dwSize
, bOrder
);
280 TRACE("returning %ld\n", ret
);
285 /******************************************************************
286 * AllocateAndGetUdpTableFromStack (IPHLPAPI.@)
292 * bOrder [In] -- passed to GetUdpTable to order the table
293 * heap [In] -- heap from which the table is allocated
294 * flags [In] -- flags to HeapAlloc
301 DWORD WINAPI
AllocateAndGetUdpTableFromStack(PMIB_UDPTABLE
*ppUdpTable
,
302 BOOL bOrder
, HANDLE heap
, DWORD flags
)
306 TRACE("ppUdpTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
307 ppUdpTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
309 ret
= ERROR_INVALID_PARAMETER
;
313 ret
= GetUdpTable(*ppUdpTable
, &dwSize
, bOrder
);
314 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
315 *ppUdpTable
= (PMIB_UDPTABLE
)HeapAlloc(heap
, flags
, dwSize
);
316 ret
= GetUdpTable(*ppUdpTable
, &dwSize
, bOrder
);
319 TRACE("returning %ld\n", ret
);
324 /******************************************************************
325 * CreateIpForwardEntry (IPHLPAPI.@)
337 DWORD WINAPI
CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
339 return createIpForwardEntry( pRoute
);
343 /******************************************************************
344 * CreateIpNetEntry (IPHLPAPI.@)
356 DWORD WINAPI
CreateIpNetEntry(PMIB_IPNETROW pArpEntry
)
358 TRACE("pArpEntry %p\n", pArpEntry
);
359 /* could use SIOCSARP on systems that support it, not sure I want to */
365 /******************************************************************
366 * CreateProxyArpEntry (IPHLPAPI.@)
380 DWORD WINAPI
CreateProxyArpEntry(DWORD dwAddress
, DWORD dwMask
, DWORD dwIfIndex
)
382 TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress
,
385 /* marking Win2K+ functions not supported */
386 return ERROR_NOT_SUPPORTED
;
390 /******************************************************************
391 * DeleteIPAddress (IPHLPAPI.@)
403 DWORD WINAPI
DeleteIPAddress(ULONG NTEContext
)
405 TRACE("NTEContext %ld\n", NTEContext
);
406 return RtlNtStatusToDosError(deleteIpAddress(NTEContext
));
410 /******************************************************************
411 * DeleteIpForwardEntry (IPHLPAPI.@)
423 DWORD WINAPI
DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
425 return deleteIpForwardEntry( pRoute
);
429 /******************************************************************
430 * DeleteIpNetEntry (IPHLPAPI.@)
442 DWORD WINAPI
DeleteIpNetEntry(PMIB_IPNETROW pArpEntry
)
444 TRACE("pArpEntry %p\n", pArpEntry
);
445 /* could use SIOCDARP on systems that support it, not sure I want to */
451 /******************************************************************
452 * DeleteProxyArpEntry (IPHLPAPI.@)
466 DWORD WINAPI
DeleteProxyArpEntry(DWORD dwAddress
, DWORD dwMask
, DWORD dwIfIndex
)
468 TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress
,
471 /* marking Win2K+ functions not supported */
472 return ERROR_NOT_SUPPORTED
;
475 /******************************************************************
476 * EnableRouter (IPHLPAPI.@)
482 * pOverlapped [In/Out]
489 DWORD WINAPI
EnableRouter(HANDLE
* pHandle
, OVERLAPPED
* pOverlapped
)
491 TRACE("pHandle %p, pOverlapped %p\n", pHandle
, pOverlapped
);
493 /* could echo "1" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
494 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
495 marking Win2K+ functions not supported */
496 return ERROR_NOT_SUPPORTED
;
500 /******************************************************************
501 * FlushIpNetTable (IPHLPAPI.@)
513 DWORD WINAPI
FlushIpNetTable(DWORD dwIfIndex
)
515 TRACE("dwIfIndex 0x%08lx\n", dwIfIndex
);
517 /* this flushes the arp cache of the given index
518 marking Win2K+ functions not supported */
519 return ERROR_NOT_SUPPORTED
;
523 /******************************************************************
524 * GetAdapterIndex (IPHLPAPI.@)
529 * AdapterName [In/Out]
537 DWORD WINAPI
GetAdapterIndex(LPWSTR AdapterName
, PULONG IfIndex
)
539 TRACE("AdapterName %p, IfIndex %p\n", AdapterName
, IfIndex
);
541 /* marking Win2K+ functions not supported */
542 return ERROR_NOT_SUPPORTED
;
546 /******************************************************************
547 * GetAdaptersInfo (IPHLPAPI.@)
552 * pAdapterInfo [In/Out]
553 * pOutBufLen [In/Out]
560 DWORD WINAPI
GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo
, PULONG pOutBufLen
)
566 TRACE("pAdapterInfo %p, pOutBufLen %p\n", pAdapterInfo
, pOutBufLen
);
568 ret
= ERROR_INVALID_PARAMETER
;
570 DWORD numNonLoopbackInterfaces
= getNumNonLoopbackInterfaces();
572 if (numNonLoopbackInterfaces
> 0) {
573 /* this calculation assumes only one address in the IP_ADDR_STRING lists.
574 that's okay, because:
575 - we don't get multiple addresses per adapter anyway
576 - we don't know about per-adapter gateways
577 - DHCP and WINS servers can have max one entry per list */
578 ULONG size
= sizeof(IP_ADAPTER_INFO
) * numNonLoopbackInterfaces
;
580 if (!pAdapterInfo
|| *pOutBufLen
< size
) {
582 ret
= ERROR_BUFFER_OVERFLOW
;
585 InterfaceIndexTable
*table
= getNonLoopbackInterfaceIndexTable();
588 size
= sizeof(IP_ADAPTER_INFO
) * table
->numIndexes
;
589 if (*pOutBufLen
< size
) {
591 ret
= ERROR_INSUFFICIENT_BUFFER
;
596 BOOL winsEnabled
= FALSE
;
597 IP_ADDRESS_STRING primaryWINS
, secondaryWINS
;
599 memset(pAdapterInfo
, 0, size
);
600 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
601 "Software\\Wine\\Wine\\Config\\Network", 0, KEY_READ
,
602 &hKey
) == ERROR_SUCCESS
) {
603 DWORD size
= sizeof(primaryWINS
.String
);
606 RegQueryValueExA(hKey
, "WinsServer", NULL
, NULL
,
607 (PBYTE
)primaryWINS
.String
, &size
);
608 addr
= inet_addr(primaryWINS
.String
);
609 if (addr
!= INADDR_NONE
&& addr
!= INADDR_ANY
)
611 size
= sizeof(secondaryWINS
.String
);
612 RegQueryValueExA(hKey
, "BackupWinsServer", NULL
, NULL
,
613 (PBYTE
)secondaryWINS
.String
, &size
);
614 addr
= inet_addr(secondaryWINS
.String
);
615 if (addr
!= INADDR_NONE
&& addr
!= INADDR_ANY
)
619 TRACE("num of index is %lu\n", table
->numIndexes
);
620 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
621 PIP_ADAPTER_INFO ptr
= &pAdapterInfo
[ndx
];
622 DWORD addrLen
= sizeof(ptr
->Address
), type
;
624 getInterfaceNameByIndex(table
->indexes
[ndx
]);
626 ret
= ERROR_OUTOFMEMORY
;
630 /* on Win98 this is left empty, but whatever */
631 strncpy(ptr
->AdapterName
,ifname
,sizeof(ptr
->AdapterName
));
632 consumeInterfaceName(ifname
);
633 ptr
->AdapterName
[MAX_ADAPTER_NAME_LENGTH
] = '\0';
634 getInterfacePhysicalByIndex(table
->indexes
[ndx
], &addrLen
,
635 ptr
->Address
, &type
);
636 /* MS defines address length and type as UINT in some places and
637 DWORD in others, **sigh**. Don't want to assume that PUINT and
638 PDWORD are equiv (64-bit?) */
639 ptr
->AddressLength
= addrLen
;
641 ptr
->Index
= table
->indexes
[ndx
];
642 toIPAddressString(getInterfaceIPAddrByIndex(table
->indexes
[ndx
]),
643 ptr
->IpAddressList
.IpAddress
.String
);
644 toIPAddressString(getInterfaceMaskByIndex(table
->indexes
[ndx
]),
645 ptr
->IpAddressList
.IpMask
.String
);
646 ptr
->IpAddressList
.Context
= ptr
->Index
;
647 toIPAddressString(getInterfaceGatewayByIndex(table
->indexes
[ndx
]),
648 ptr
->GatewayList
.IpAddress
.String
);
649 getDhcpInfoForAdapter(table
->indexes
[ndx
], &dhcpEnabled
,
650 &dhcpServer
, &ptr
->LeaseObtained
,
652 ptr
->DhcpEnabled
= (DWORD
) dhcpEnabled
;
653 toIPAddressString(dhcpServer
,
654 ptr
->DhcpServer
.IpAddress
.String
);
656 ptr
->HaveWins
= TRUE
;
657 memcpy(ptr
->PrimaryWinsServer
.IpAddress
.String
,
658 primaryWINS
.String
, sizeof(primaryWINS
.String
));
659 memcpy(ptr
->SecondaryWinsServer
.IpAddress
.String
,
660 secondaryWINS
.String
, sizeof(secondaryWINS
.String
));
662 if (ndx
< table
->numIndexes
- 1)
663 ptr
->Next
= &pAdapterInfo
[ndx
+ 1];
672 ret
= ERROR_OUTOFMEMORY
;
678 TRACE("returning %ld\n", ret
);
683 /******************************************************************
684 * GetBestInterface (IPHLPAPI.@)
690 * pdwBestIfIndex [In/Out]
697 DWORD WINAPI
GetBestInterface(IPAddr dwDestAddr
, PDWORD pdwBestIfIndex
)
701 TRACE("dwDestAddr 0x%08lx, pdwBestIfIndex %p\n", dwDestAddr
, pdwBestIfIndex
);
703 ret
= ERROR_INVALID_PARAMETER
;
705 MIB_IPFORWARDROW ipRow
;
707 ret
= GetBestRoute(dwDestAddr
, 0, &ipRow
);
708 if (ret
== ERROR_SUCCESS
)
709 *pdwBestIfIndex
= ipRow
.dwForwardIfIndex
;
711 TRACE("returning %ld\n", ret
);
716 /******************************************************************
717 * GetBestRoute (IPHLPAPI.@)
731 DWORD WINAPI
GetBestRoute(DWORD dwDestAddr
, DWORD dwSourceAddr
, PMIB_IPFORWARDROW pBestRoute
)
733 PMIB_IPFORWARDTABLE table
;
736 TRACE("dwDestAddr 0x%08lx, dwSourceAddr 0x%08lx, pBestRoute %p\n", dwDestAddr
,
737 dwSourceAddr
, pBestRoute
);
739 return ERROR_INVALID_PARAMETER
;
741 AllocateAndGetIpForwardTableFromStack(&table
, FALSE
, GetProcessHeap(), 0);
743 DWORD ndx
, matchedBits
, matchedNdx
= 0;
745 for (ndx
= 0, matchedBits
= 0; ndx
< table
->dwNumEntries
; ndx
++) {
746 if ((dwDestAddr
& table
->table
[ndx
].dwForwardMask
) ==
747 (table
->table
[ndx
].dwForwardDest
& table
->table
[ndx
].dwForwardMask
)) {
748 DWORD numShifts
, mask
;
750 for (numShifts
= 0, mask
= table
->table
[ndx
].dwForwardMask
;
751 mask
&& !(mask
& 1); mask
>>= 1, numShifts
++)
753 if (numShifts
> matchedBits
) {
754 matchedBits
= numShifts
;
759 memcpy(pBestRoute
, &table
->table
[matchedNdx
], sizeof(MIB_IPFORWARDROW
));
760 HeapFree(GetProcessHeap(), 0, table
);
764 ret
= ERROR_OUTOFMEMORY
;
765 TRACE("returning %ld\n", ret
);
769 /******************************************************************
770 * GetExtendedTcpTable (IPHLPAPI.@)
772 * Get the table of TCP endpoints available to the application.
775 * pTcpTable [Out] table struct with the filtered TCP endpoints available to application
776 * pdwSize [In/Out] estimated size of the structure returned in pTcpTable, in bytes
777 * bOrder [In] whether to order the table
778 * ulAf [in] version of IP used by the TCP endpoints
779 * TableClass [in] type of the TCP table structure from TCP_TABLE_CLASS
780 * Reserved [in] reserved - this value must be zero
784 * Failure: either ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER
789 DWORD WINAPI
GetExtendedTcpTable(PVOID pTcpTable
, PDWORD pdwSize
, BOOL bOrder
, ULONG ulAf
, TCP_TABLE_CLASS TableClass
, ULONG Reserved
)
791 DWORD ret
= NO_ERROR
;
793 if (TableClass
== TCP_TABLE_OWNER_PID_ALL
) {
795 *pdwSize
= sizeof(MIB_TCPTABLE_OWNER_PID
);
796 return ERROR_INSUFFICIENT_BUFFER
;
798 ZeroMemory(pTcpTable
, sizeof(MIB_TCPTABLE_OWNER_PID
));
809 /******************************************************************
810 * GetFriendlyIfIndex (IPHLPAPI.@)
822 DWORD WINAPI
GetFriendlyIfIndex(DWORD IfIndex
)
824 /* windows doesn't validate these, either, just makes sure the top byte is
825 cleared. I assume my ifenum module never gives an index with the top
827 TRACE("returning %ld\n", IfIndex
);
832 /******************************************************************
833 * GetIcmpStatistics (IPHLPAPI.@)
845 DWORD WINAPI
GetIcmpStatistics(PMIB_ICMP pStats
)
849 TRACE("pStats %p\n", pStats
);
850 ret
= getICMPStats(pStats
);
851 TRACE("returning %ld\n", ret
);
856 /******************************************************************
857 * GetIfEntry (IPHLPAPI.@)
869 DWORD WINAPI
GetIfEntry(PMIB_IFROW pIfRow
)
874 TRACE("pIfRow %p\n", pIfRow
);
876 return ERROR_INVALID_PARAMETER
;
878 name
= getInterfaceNameByIndex(pIfRow
->dwIndex
);
880 ret
= getInterfaceEntryByIndex(pIfRow
->dwIndex
, pIfRow
);
882 ret
= getInterfaceStatsByName(name
, pIfRow
);
883 consumeInterfaceName(name
);
886 ret
= ERROR_INVALID_DATA
;
887 TRACE("returning %ld\n", ret
);
892 static int IfTableSorter(const void *a
, const void *b
)
897 ret
= ((PMIB_IFROW
)a
)->dwIndex
- ((PMIB_IFROW
)b
)->dwIndex
;
904 /******************************************************************
905 * GetIfTable (IPHLPAPI.@)
919 DWORD WINAPI
GetIfTable(PMIB_IFTABLE pIfTable
, PULONG pdwSize
, BOOL bOrder
)
923 TRACE("pIfTable %p, pdwSize %p, bOrder %ld\n", pdwSize
, pdwSize
,
926 ret
= ERROR_INVALID_PARAMETER
;
928 DWORD numInterfaces
= getNumInterfaces();
930 TRACE("GetIfTable: numInterfaces = %d\n", (int)numInterfaces
);
931 size
= sizeof(MIB_IFTABLE
) + (numInterfaces
- 1) * sizeof(MIB_IFROW
);
933 if (!pIfTable
|| *pdwSize
< size
) {
935 ret
= ERROR_INSUFFICIENT_BUFFER
;
938 InterfaceIndexTable
*table
= getInterfaceIndexTable();
941 size
= sizeof(MIB_IFTABLE
) + (table
->numIndexes
- 1) *
943 if (*pdwSize
< size
) {
945 ret
= ERROR_INSUFFICIENT_BUFFER
;
950 pIfTable
->dwNumEntries
= 0;
951 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
952 pIfTable
->table
[ndx
].dwIndex
= table
->indexes
[ndx
];
953 GetIfEntry(&pIfTable
->table
[ndx
]);
954 pIfTable
->dwNumEntries
++;
957 qsort(pIfTable
->table
, pIfTable
->dwNumEntries
, sizeof(MIB_IFROW
),
964 ret
= ERROR_OUTOFMEMORY
;
967 TRACE("returning %ld\n", ret
);
972 /******************************************************************
973 * GetInterfaceInfo (IPHLPAPI.@)
979 * dwOutBufLen [In/Out]
986 DWORD WINAPI
GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable
, PULONG dwOutBufLen
)
990 TRACE("pIfTable %p, dwOutBufLen %p\n", pIfTable
, dwOutBufLen
);
992 ret
= ERROR_INVALID_PARAMETER
;
994 DWORD numNonLoopbackInterfaces
= getNumNonLoopbackInterfaces();
996 TRACE("numNonLoopbackInterfaces == 0x%x\n", numNonLoopbackInterfaces
);
997 size
= sizeof(IP_INTERFACE_INFO
) + (numNonLoopbackInterfaces
) *
998 sizeof(IP_ADAPTER_INDEX_MAP
);
1000 if (!pIfTable
|| *dwOutBufLen
< size
) {
1001 *dwOutBufLen
= size
;
1002 ret
= ERROR_INSUFFICIENT_BUFFER
;
1005 InterfaceIndexTable
*table
= getNonLoopbackInterfaceIndexTable();
1008 TRACE("table->numIndexes == 0x%x\n", table
->numIndexes
);
1009 size
= sizeof(IP_INTERFACE_INFO
) + (table
->numIndexes
) *
1010 sizeof(IP_ADAPTER_INDEX_MAP
);
1011 if (*dwOutBufLen
< size
) {
1012 *dwOutBufLen
= size
;
1013 ret
= ERROR_INSUFFICIENT_BUFFER
;
1018 pIfTable
->NumAdapters
= 0;
1019 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
1020 const char *walker
, *name
;
1023 pIfTable
->Adapter
[ndx
].Index
= table
->indexes
[ndx
];
1024 name
= getInterfaceNameByIndex(table
->indexes
[ndx
]);
1025 for (walker
= name
, assigner
= pIfTable
->Adapter
[ndx
].Name
;
1026 walker
&& *walker
&&
1027 assigner
- pIfTable
->Adapter
[ndx
].Name
< MAX_ADAPTER_NAME
- 1;
1028 walker
++, assigner
++)
1029 *assigner
= *walker
;
1031 consumeInterfaceName(name
);
1032 pIfTable
->NumAdapters
++;
1039 ret
= ERROR_OUTOFMEMORY
;
1042 TRACE("returning %ld\n", ret
);
1047 static int IpAddrTableSorter(const void *a
, const void *b
)
1052 ret
= ((PMIB_IPADDRROW
)a
)->dwAddr
- ((PMIB_IPADDRROW
)b
)->dwAddr
;
1059 /******************************************************************
1060 * GetIpAddrTable (IPHLPAPI.@)
1065 * pIpAddrTable [In/Out]
1074 DWORD WINAPI
GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable
, PULONG pdwSize
, BOOL bOrder
)
1078 TRACE("pIpAddrTable %p, pdwSize %p, bOrder %ld\n", pIpAddrTable
, pdwSize
,
1081 ret
= ERROR_INVALID_PARAMETER
;
1083 DWORD numInterfaces
= getNumInterfaces();
1084 ULONG size
= sizeof(MIB_IPADDRTABLE
) + (numInterfaces
- 1) *
1085 sizeof(MIB_IPADDRROW
);
1087 if (!pIpAddrTable
|| *pdwSize
< size
) {
1089 ret
= ERROR_INSUFFICIENT_BUFFER
;
1092 InterfaceIndexTable
*table
= getInterfaceIndexTable();
1095 size
= sizeof(MIB_IPADDRTABLE
) + (table
->numIndexes
- 1) *
1096 sizeof(MIB_IPADDRROW
);
1097 if (*pdwSize
< size
) {
1099 ret
= ERROR_INSUFFICIENT_BUFFER
;
1104 pIpAddrTable
->dwNumEntries
= 0;
1105 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
1106 pIpAddrTable
->table
[ndx
].dwIndex
= table
->indexes
[ndx
];
1107 pIpAddrTable
->table
[ndx
].dwAddr
=
1108 getInterfaceIPAddrByIndex(table
->indexes
[ndx
]);
1109 pIpAddrTable
->table
[ndx
].dwMask
=
1110 getInterfaceMaskByIndex(table
->indexes
[ndx
]);
1111 /* the dwBCastAddr member isn't the broadcast address, it indicates
1112 * whether the interface uses the 1's broadcast address (1) or the
1113 * 0's broadcast address (0).
1115 bcast
= getInterfaceBCastAddrByIndex(table
->indexes
[ndx
]);
1116 pIpAddrTable
->table
[ndx
].dwBCastAddr
=
1117 (bcast
& pIpAddrTable
->table
[ndx
].dwMask
) ? 1 : 0;
1118 /* FIXME: hardcoded reasm size, not sure where to get it */
1119 pIpAddrTable
->table
[ndx
].dwReasmSize
= 65535;
1120 pIpAddrTable
->table
[ndx
].unused1
= 0;
1121 pIpAddrTable
->table
[ndx
].wType
= 0; /* aka unused2 */
1122 pIpAddrTable
->dwNumEntries
++;
1125 qsort(pIpAddrTable
->table
, pIpAddrTable
->dwNumEntries
,
1126 sizeof(MIB_IPADDRROW
), IpAddrTableSorter
);
1132 ret
= ERROR_OUTOFMEMORY
;
1135 TRACE("returning %ld\n", ret
);
1140 static int IpForwardTableSorter(const void *a
, const void *b
)
1145 PMIB_IPFORWARDROW rowA
= (PMIB_IPFORWARDROW
)a
, rowB
= (PMIB_IPFORWARDROW
)b
;
1147 ret
= rowA
->dwForwardDest
- rowB
->dwForwardDest
;
1149 ret
= rowA
->dwForwardProto
- rowB
->dwForwardProto
;
1151 ret
= rowA
->dwForwardPolicy
- rowB
->dwForwardPolicy
;
1153 ret
= rowA
->dwForwardNextHop
- rowB
->dwForwardNextHop
;
1163 /******************************************************************
1164 * GetIpForwardTable (IPHLPAPI.@)
1169 * pIpForwardTable [In/Out]
1178 DWORD WINAPI
GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable
, PULONG pdwSize
, BOOL bOrder
)
1182 TRACE("pIpForwardTable %p, pdwSize %p, bOrder %ld\n", pIpForwardTable
,
1183 pdwSize
, (DWORD
)bOrder
);
1185 ret
= ERROR_INVALID_PARAMETER
;
1187 DWORD numRoutes
= getNumRoutes();
1188 ULONG sizeNeeded
= sizeof(MIB_IPFORWARDTABLE
) + (numRoutes
- 1) *
1189 sizeof(MIB_IPFORWARDROW
);
1191 if (!pIpForwardTable
|| *pdwSize
< sizeNeeded
) {
1192 *pdwSize
= sizeNeeded
;
1193 ret
= ERROR_INSUFFICIENT_BUFFER
;
1196 RouteTable
*table
= getRouteTable();
1198 sizeNeeded
= sizeof(MIB_IPFORWARDTABLE
) + (table
->numRoutes
- 1) *
1199 sizeof(MIB_IPFORWARDROW
);
1200 if (*pdwSize
< sizeNeeded
) {
1201 *pdwSize
= sizeNeeded
;
1202 ret
= ERROR_INSUFFICIENT_BUFFER
;
1207 pIpForwardTable
->dwNumEntries
= table
->numRoutes
;
1208 for (ndx
= 0; ndx
< numRoutes
; ndx
++) {
1209 pIpForwardTable
->table
[ndx
].dwForwardIfIndex
=
1210 table
->routes
[ndx
].ifIndex
;
1211 pIpForwardTable
->table
[ndx
].dwForwardDest
=
1212 table
->routes
[ndx
].dest
;
1213 pIpForwardTable
->table
[ndx
].dwForwardMask
=
1214 table
->routes
[ndx
].mask
;
1215 pIpForwardTable
->table
[ndx
].dwForwardPolicy
= 0;
1216 pIpForwardTable
->table
[ndx
].dwForwardNextHop
=
1217 table
->routes
[ndx
].gateway
;
1218 /* FIXME: this type is appropriate for local interfaces; may not
1219 always be appropriate */
1220 pIpForwardTable
->table
[ndx
].dwForwardType
= MIB_IPROUTE_TYPE_DIRECT
;
1221 /* FIXME: other protos might be appropriate, e.g. the default route
1222 is typically set with MIB_IPPROTO_NETMGMT instead */
1223 pIpForwardTable
->table
[ndx
].dwForwardProto
= MIB_IPPROTO_LOCAL
;
1224 /* punt on age and AS */
1225 pIpForwardTable
->table
[ndx
].dwForwardAge
= 0;
1226 pIpForwardTable
->table
[ndx
].dwForwardNextHopAS
= 0;
1227 pIpForwardTable
->table
[ndx
].dwForwardMetric1
=
1228 table
->routes
[ndx
].metric
;
1229 /* rest of the metrics are 0.. */
1230 pIpForwardTable
->table
[ndx
].dwForwardMetric2
= 0;
1231 pIpForwardTable
->table
[ndx
].dwForwardMetric3
= 0;
1232 pIpForwardTable
->table
[ndx
].dwForwardMetric4
= 0;
1233 pIpForwardTable
->table
[ndx
].dwForwardMetric5
= 0;
1236 qsort(pIpForwardTable
->table
, pIpForwardTable
->dwNumEntries
,
1237 sizeof(MIB_IPFORWARDROW
), IpForwardTableSorter
);
1240 HeapFree(GetProcessHeap(), 0, table
);
1243 ret
= ERROR_OUTOFMEMORY
;
1246 TRACE("returning %ld\n", ret
);
1251 static int IpNetTableSorter(const void *a
, const void *b
)
1256 ret
= ((PMIB_IPNETROW
)a
)->dwAddr
- ((PMIB_IPNETROW
)b
)->dwAddr
;
1263 /******************************************************************
1264 * GetIpNetTable (IPHLPAPI.@)
1269 * pIpNetTable [In/Out]
1278 DWORD WINAPI
GetIpNetTable(PMIB_IPNETTABLE pIpNetTable
, PULONG pdwSize
, BOOL bOrder
)
1280 DWORD ret
= NO_ERROR
;
1282 TRACE("pIpNetTable %p, pdwSize %p, bOrder %d\n", pIpNetTable
, pdwSize
,
1285 ret
= ERROR_INVALID_PARAMETER
;
1287 DWORD numEntries
= getNumArpEntries();
1288 ULONG size
= sizeof(MIB_IPNETTABLE
);
1291 size
+= (numEntries
- 1) * sizeof(MIB_IPNETROW
);
1292 if (!pIpNetTable
|| *pdwSize
< size
) {
1294 ret
= ERROR_INSUFFICIENT_BUFFER
;
1297 PMIB_IPNETTABLE table
= getArpTable();
1299 size
= sizeof(MIB_IPNETTABLE
);
1300 if (table
->dwNumEntries
> 1)
1301 size
+= (table
->dwNumEntries
- 1) * sizeof(MIB_IPNETROW
);
1302 if (*pdwSize
< size
) {
1304 ret
= ERROR_INSUFFICIENT_BUFFER
;
1308 memcpy(pIpNetTable
, table
, size
);
1310 qsort(pIpNetTable
->table
, pIpNetTable
->dwNumEntries
,
1311 sizeof(MIB_IPNETROW
), IpNetTableSorter
);
1314 HeapFree(GetProcessHeap(), 0, table
);
1318 TRACE("returning %d\n", ret
);
1323 /******************************************************************
1324 * GetIpStatistics (IPHLPAPI.@)
1336 DWORD WINAPI
GetIpStatistics(PMIB_IPSTATS pStats
)
1338 return GetIpStatisticsEx(pStats
, PF_INET
);
1341 /******************************************************************
1342 * GetIpStatisticsEx (IPHLPAPI.@)
1355 DWORD WINAPI
GetIpStatisticsEx(PMIB_IPSTATS pStats
, DWORD dwFamily
)
1359 TRACE("pStats %p\n", pStats
);
1360 ret
= getIPStats(pStats
, dwFamily
);
1361 TRACE("returning %ld\n", ret
);
1365 /******************************************************************
1366 * GetNetworkParams (IPHLPAPI.@)
1371 * pFixedInfo [In/Out]
1372 * pOutBufLen [In/Out]
1379 DWORD WINAPI
GetNetworkParams(PFIXED_INFO pFixedInfo
, PULONG pOutBufLen
)
1384 PIPHLP_RES_INFO resInfo
;
1386 TRACE("pFixedInfo %p, pOutBufLen %p\n", pFixedInfo
, pOutBufLen
);
1388 return ERROR_INVALID_PARAMETER
;
1390 resInfo
= getResInfo();
1392 return ERROR_OUTOFMEMORY
;
1394 size
= sizeof(FIXED_INFO
) + (resInfo
->riCount
> 1 ? (resInfo
->riCount
-1) *
1395 sizeof(IP_ADDR_STRING
) : 0);
1396 if (!pFixedInfo
|| *pOutBufLen
< size
) {
1398 disposeResInfo( resInfo
);
1399 return ERROR_BUFFER_OVERFLOW
;
1402 memset(pFixedInfo
, 0, size
);
1403 size
= sizeof(pFixedInfo
->HostName
);
1404 GetComputerNameExA(ComputerNameDnsHostname
, pFixedInfo
->HostName
, &size
);
1405 size
= sizeof(pFixedInfo
->DomainName
);
1406 GetComputerNameExA(ComputerNameDnsDomain
, pFixedInfo
->DomainName
, &size
);
1408 TRACE("GetComputerNameExA: %s\n", pFixedInfo
->DomainName
);
1410 if (resInfo
->riCount
> 0)
1412 CopyMemory(&pFixedInfo
->DnsServerList
, resInfo
->DnsList
, sizeof(IP_ADDR_STRING
));
1413 if (resInfo
->riCount
> 1)
1415 IP_ADDR_STRING
*pSrc
= resInfo
->DnsList
->Next
;
1416 IP_ADDR_STRING
*pTarget
= (struct _IP_ADDR_STRING
*)((char*)pFixedInfo
+ sizeof(FIXED_INFO
));
1418 pFixedInfo
->DnsServerList
.Next
= pTarget
;
1422 CopyMemory(pTarget
, pSrc
, sizeof(IP_ADDR_STRING
));
1424 if (resInfo
->riCount
> 1)
1426 pTarget
->Next
= (IP_ADDR_STRING
*)((char*)pTarget
+ sizeof(IP_ADDR_STRING
));
1427 pTarget
= pTarget
->Next
;
1432 pTarget
->Next
= NULL
;
1440 pFixedInfo
->DnsServerList
.Next
= NULL
;
1444 pFixedInfo
->NodeType
= HYBRID_NODETYPE
;
1445 regReturn
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
1446 "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", 0, KEY_READ
, &hKey
);
1447 if (regReturn
!= ERROR_SUCCESS
)
1448 regReturn
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
1449 "SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ
,
1451 if (regReturn
== ERROR_SUCCESS
)
1453 DWORD size
= sizeof(pFixedInfo
->ScopeId
);
1455 RegQueryValueExA(hKey
, "ScopeID", NULL
, NULL
, (PBYTE
)pFixedInfo
->ScopeId
, &size
);
1459 disposeResInfo( resInfo
);
1460 /* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
1461 I suppose could also check for a listener on port 53 to set EnableDns */
1463 TRACE("returning %ld\n", ret
);
1469 /******************************************************************
1470 * GetNumberOfInterfaces (IPHLPAPI.@)
1482 DWORD WINAPI
GetNumberOfInterfaces(PDWORD pdwNumIf
)
1486 TRACE("pdwNumIf %p\n", pdwNumIf
);
1488 ret
= ERROR_INVALID_PARAMETER
;
1490 *pdwNumIf
= getNumInterfaces();
1493 TRACE("returning %ld\n", ret
);
1498 /******************************************************************
1499 * GetOwnerModuleFromTcpEntry (IPHLPAPI.@)
1501 * Get data about the module that issued the context bind for a specific IPv4 TCP endpoint in a MIB table row
1504 * pTcpEntry [in] pointer to a MIB_TCPROW_OWNER_MODULE structure
1505 * Class [in] TCPIP_OWNER_MODULE_INFO_CLASS enumeration value
1506 * Buffer [out] pointer a buffer containing a TCPIP_OWNER_MODULE_BASIC_INFO structure with the owner module data.
1507 * pdwSize [in, out] estimated size of the structure returned in Buffer, in bytes
1511 * Failure: ERROR_INSUFFICIENT_BUFFER, ERROR_INVALID_PARAMETER, ERROR_NOT_ENOUGH_MEMORY
1512 * ERROR_NOT_FOUND or ERROR_PARTIAL_COPY
1515 * The type of data returned in Buffer is indicated by the value of the Class parameter.
1517 DWORD WINAPI
GetOwnerModuleFromTcpEntry( PMIB_TCPROW_OWNER_MODULE pTcpEntry
, TCPIP_OWNER_MODULE_INFO_CLASS Class
, PVOID Buffer
, PDWORD pdwSize
)
1519 DWORD ret
= NO_ERROR
;
1524 static void CreateNameServerListEnumNamesFunc( PWCHAR Interface
, PWCHAR Server
, PVOID Data
)
1526 IP_ADDR_STRING
*pNext
;
1527 PNAME_SERVER_LIST_CONTEXT Context
= (PNAME_SERVER_LIST_CONTEXT
)Data
;
1529 if (!Context
->NumServers
)
1531 if (Context
->uSizeAvailable
>= Context
->uSizeRequired
)
1533 WideCharToMultiByte(CP_ACP
, 0, Server
, -1, Context
->pData
->DnsServerList
.IpAddress
.String
, 16, NULL
, NULL
);
1534 Context
->pData
->DnsServerList
.IpAddress
.String
[15] = '\0';
1535 Context
->pLastAddr
= &Context
->pData
->DnsServerList
;
1540 Context
->uSizeRequired
+= sizeof(IP_ADDR_STRING
);
1541 if (Context
->uSizeAvailable
>= Context
->uSizeRequired
)
1543 pNext
= (IP_ADDR_STRING
*)(((char*)Context
->pLastAddr
) + sizeof(IP_ADDR_STRING
));
1544 WideCharToMultiByte(CP_ACP
, 0, Server
, -1, pNext
->IpAddress
.String
, 16, NULL
, NULL
);
1545 pNext
->IpAddress
.String
[15] = '\0';
1546 Context
->pLastAddr
->Next
= pNext
;
1547 Context
->pLastAddr
= pNext
;
1551 Context
->NumServers
++;
1554 /******************************************************************
1555 * GetPerAdapterInfo (IPHLPAPI.@)
1561 * pPerAdapterInfo [In/Out]
1562 * pOutBufLen [In/Out]
1569 DWORD WINAPI
GetPerAdapterInfo(ULONG IfIndex
, PIP_PER_ADAPTER_INFO pPerAdapterInfo
, PULONG pOutBufLen
)
1574 NAME_SERVER_LIST_CONTEXT Context
;
1575 WCHAR keyname
[200] = L
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\";
1578 return ERROR_INVALID_PARAMETER
;
1580 if (!pPerAdapterInfo
|| *pOutBufLen
< sizeof(IP_PER_ADAPTER_INFO
))
1582 *pOutBufLen
= sizeof(IP_PER_ADAPTER_INFO
);
1583 return ERROR_BUFFER_OVERFLOW
;
1586 ifName
= getInterfaceNameByIndex(IfIndex
);
1588 return ERROR_INVALID_PARAMETER
;
1590 MultiByteToWideChar(CP_ACP
, 0, ifName
, -1, &keyname
[62], sizeof(keyname
)/sizeof(WCHAR
) - 63);
1591 HeapFree(GetProcessHeap(), 0, (LPVOID
)ifName
);
1593 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
, keyname
, 0, KEY_READ
, &hkey
) != ERROR_SUCCESS
)
1595 return ERROR_NOT_SUPPORTED
;
1597 Context
.NumServers
= 0;
1598 Context
.uSizeAvailable
= *pOutBufLen
;
1599 Context
.uSizeRequired
= sizeof(IP_PER_ADAPTER_INFO
);
1600 Context
.pData
= pPerAdapterInfo
;
1602 if (*pOutBufLen
>= sizeof(IP_PER_ADAPTER_INFO
))
1603 ZeroMemory(pPerAdapterInfo
, sizeof(IP_PER_ADAPTER_INFO
));
1605 EnumNameServers(hkey
, &keyname
[62], &Context
, CreateNameServerListEnumNamesFunc
);
1607 if (Context
.uSizeRequired
> Context
.uSizeAvailable
)
1609 *pOutBufLen
= Context
.uSizeRequired
;
1611 return ERROR_BUFFER_OVERFLOW
;
1614 if(RegQueryValueExW(hkey
, L
"NameServer", NULL
, NULL
, NULL
, &dwSize
) == ERROR_SUCCESS
)
1616 pPerAdapterInfo
->AutoconfigActive
= FALSE
;
1620 pPerAdapterInfo
->AutoconfigActive
= TRUE
;
1628 /******************************************************************
1629 * GetRTTAndHopCount (IPHLPAPI.@)
1634 * DestIpAddress [In]
1644 BOOL WINAPI
GetRTTAndHopCount(IPAddr DestIpAddress
, PULONG HopCount
, ULONG MaxHops
, PULONG RTT
)
1646 TRACE("DestIpAddress 0x%08lx, HopCount %p, MaxHops %ld, RTT %p\n",
1647 DestIpAddress
, HopCount
, MaxHops
, RTT
);
1653 /******************************************************************
1654 * GetTcpStatisticsEx (IPHLPAPI.@)
1667 DWORD WINAPI
GetTcpStatisticsEx(PMIB_TCPSTATS pStats
, DWORD dwFamily
)
1671 TRACE("pStats %p\n", pStats
);
1672 ret
= getTCPStats(pStats
, dwFamily
);
1673 TRACE("returning %ld\n", ret
);
1677 /******************************************************************
1678 * GetTcpStatistics (IPHLPAPI.@)
1690 DWORD WINAPI
GetTcpStatistics(PMIB_TCPSTATS pStats
)
1692 return GetTcpStatisticsEx(pStats
, PF_INET
);
1696 static int TcpTableSorter(const void *a
, const void *b
)
1701 PMIB_TCPROW rowA
= (PMIB_TCPROW
)a
, rowB
= (PMIB_TCPROW
)b
;
1703 ret
= rowA
->dwLocalAddr
- rowB
->dwLocalAddr
;
1705 ret
= rowA
->dwLocalPort
- rowB
->dwLocalPort
;
1707 ret
= rowA
->dwRemoteAddr
- rowB
->dwRemoteAddr
;
1709 ret
= rowA
->dwRemotePort
- rowB
->dwRemotePort
;
1719 /******************************************************************
1720 * GetTcpTable (IPHLPAPI.@)
1722 * Get the table of active TCP connections.
1725 * pTcpTable [Out] buffer for TCP connections table
1726 * pdwSize [In/Out] length of output buffer
1727 * bOrder [In] whether to order the table
1731 * Failure: error code from winerror.h
1734 * If pdwSize is less than required, the function will return
1735 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to
1736 * the required byte size.
1737 * If bOrder is true, the returned table will be sorted, first by
1738 * local address and port number, then by remote address and port
1741 DWORD WINAPI
GetTcpTable(PMIB_TCPTABLE pTcpTable
, PDWORD pdwSize
, BOOL bOrder
)
1743 DWORD ret
= ERROR_NO_DATA
;
1745 TRACE("pTcpTable %p, pdwSize %p, bOrder %d\n", pTcpTable
, pdwSize
,
1748 ret
= ERROR_INVALID_PARAMETER
;
1750 DWORD numEntries
= getNumTcpEntries();
1751 DWORD size
= sizeof(MIB_TCPTABLE
);
1754 size
+= (numEntries
- 1) * sizeof(MIB_TCPROW
);
1755 if (!pTcpTable
|| *pdwSize
< size
) {
1757 ret
= ERROR_INSUFFICIENT_BUFFER
;
1760 PMIB_TCPTABLE pOurTcpTable
= getTcpTable();
1763 size
= sizeof(MIB_TCPTABLE
);
1764 if (pOurTcpTable
->dwNumEntries
> 1)
1765 size
+= (pOurTcpTable
->dwNumEntries
- 1) * sizeof(MIB_TCPROW
);
1767 if (*pdwSize
< size
)
1771 ret
= ERROR_INSUFFICIENT_BUFFER
;
1775 memcpy(pTcpTable
, pOurTcpTable
, size
);
1778 qsort(pTcpTable
->table
, pTcpTable
->dwNumEntries
,
1779 sizeof(MIB_TCPROW
), TcpTableSorter
);
1788 TRACE("returning %d\n", ret
);
1793 /******************************************************************
1794 * GetUdpStatisticsEx (IPHLPAPI.@)
1807 DWORD WINAPI
GetUdpStatisticsEx(PMIB_UDPSTATS pStats
, DWORD dwFamily
)
1811 TRACE("pStats %p\n", pStats
);
1812 ret
= getUDPStats(pStats
, dwFamily
);
1813 TRACE("returning %ld\n", ret
);
1817 /******************************************************************
1818 * GetUdpStatistics (IPHLPAPI.@)
1830 DWORD WINAPI
GetUdpStatistics(PMIB_UDPSTATS pStats
)
1832 return GetUdpStatisticsEx(pStats
, PF_INET
);
1836 static int UdpTableSorter(const void *a
, const void *b
)
1841 PMIB_UDPROW rowA
= (PMIB_UDPROW
)a
, rowB
= (PMIB_UDPROW
)b
;
1843 ret
= rowA
->dwLocalAddr
- rowB
->dwLocalAddr
;
1845 ret
= rowA
->dwLocalPort
- rowB
->dwLocalPort
;
1853 /******************************************************************
1854 * GetUdpTable (IPHLPAPI.@)
1859 * pUdpTable [In/Out]
1868 DWORD WINAPI
GetUdpTable(PMIB_UDPTABLE pUdpTable
, PDWORD pdwSize
, BOOL bOrder
)
1872 TRACE("pUdpTable %p, pdwSize %p, bOrder %ld\n", pUdpTable
, pdwSize
,
1875 ret
= ERROR_INVALID_PARAMETER
;
1877 DWORD numEntries
= getNumUdpEntries();
1878 ULONG size
= sizeof(MIB_UDPTABLE
) + (numEntries
- 1) * sizeof(MIB_UDPROW
);
1880 if (!pUdpTable
|| *pdwSize
< size
) {
1882 ret
= ERROR_INSUFFICIENT_BUFFER
;
1885 PMIB_UDPTABLE table
= getUdpTable();
1888 size
= sizeof(MIB_UDPTABLE
) + (table
->dwNumEntries
- 1) *
1890 if (*pdwSize
< size
) {
1892 ret
= ERROR_INSUFFICIENT_BUFFER
;
1895 memcpy(pUdpTable
, table
, size
);
1897 qsort(pUdpTable
->table
, pUdpTable
->dwNumEntries
,
1898 sizeof(MIB_UDPROW
), UdpTableSorter
);
1904 ret
= ERROR_OUTOFMEMORY
;
1907 TRACE("returning %ld\n", ret
);
1912 /******************************************************************
1913 * GetUniDirectionalAdapterInfo (IPHLPAPI.@)
1915 * This is a Win98-only function to get information on "unidirectional"
1916 * adapters. Since this is pretty nonsensical in other contexts, it
1917 * never returns anything.
1920 * pIPIfInfo [Out] buffer for adapter infos
1921 * dwOutBufLen [Out] length of the output buffer
1925 * Failure: error code from winerror.h
1928 * Stub, returns ERROR_NOT_SUPPORTED.
1930 DWORD WINAPI
GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo
, PULONG dwOutBufLen
)
1932 TRACE("pIPIfInfo %p, dwOutBufLen %p\n", pIPIfInfo
, dwOutBufLen
);
1933 /* a unidirectional adapter?? not bloody likely! */
1934 return ERROR_NOT_SUPPORTED
;
1938 /******************************************************************
1939 * IpReleaseAddress (IPHLPAPI.@)
1941 * Release an IP obtained through DHCP,
1944 * AdapterInfo [In] adapter to release IP address
1948 * Failure: error code from winerror.h
1951 DWORD WINAPI
IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo
)
1953 DWORD Status
, Version
= 0;
1955 if (!AdapterInfo
|| !AdapterInfo
->Name
)
1956 return ERROR_INVALID_PARAMETER
;
1958 /* Maybe we should do this in DllMain */
1959 if (DhcpCApiInitialize(&Version
) != ERROR_SUCCESS
)
1960 return ERROR_PROC_NOT_FOUND
;
1962 if (DhcpReleaseIpAddressLease(AdapterInfo
->Index
))
1963 Status
= ERROR_SUCCESS
;
1965 Status
= ERROR_PROC_NOT_FOUND
;
1973 /******************************************************************
1974 * IpRenewAddress (IPHLPAPI.@)
1976 * Renew an IP obtained through DHCP.
1979 * AdapterInfo [In] adapter to renew IP address
1983 * Failure: error code from winerror.h
1985 DWORD WINAPI
IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo
)
1987 DWORD Status
, Version
= 0;
1989 if (!AdapterInfo
|| !AdapterInfo
->Name
)
1990 return ERROR_INVALID_PARAMETER
;
1992 /* Maybe we should do this in DllMain */
1993 if (DhcpCApiInitialize(&Version
) != ERROR_SUCCESS
)
1994 return ERROR_PROC_NOT_FOUND
;
1996 if (DhcpRenewIpAddressLease(AdapterInfo
->Index
))
1997 Status
= ERROR_SUCCESS
;
1999 Status
= ERROR_PROC_NOT_FOUND
;
2007 /******************************************************************
2008 * NotifyAddrChange (IPHLPAPI.@)
2010 * Notify caller whenever the ip-interface map is changed.
2013 * Handle [Out] handle usable in asynchronous notification
2014 * overlapped [In] overlapped structure that notifies the caller
2018 * Failure: error code from winerror.h
2021 * Stub, returns ERROR_NOT_SUPPORTED.
2023 DWORD WINAPI
NotifyAddrChange(PHANDLE Handle
, LPOVERLAPPED overlapped
)
2025 FIXME("(Handle %p, overlapped %p): stub\n", Handle
, overlapped
);
2026 if (Handle
) *Handle
= INVALID_HANDLE_VALUE
;
2027 if (overlapped
) ((IO_STATUS_BLOCK
*) overlapped
)->Status
= STATUS_PENDING
;
2028 return ERROR_IO_PENDING
;
2032 /******************************************************************
2033 * NotifyRouteChange (IPHLPAPI.@)
2035 * Notify caller whenever the ip routing table is changed.
2038 * Handle [Out] handle usable in asynchronous notification
2039 * overlapped [In] overlapped structure that notifies the caller
2043 * Failure: error code from winerror.h
2046 * Stub, returns ERROR_NOT_SUPPORTED.
2048 DWORD WINAPI
NotifyRouteChange(PHANDLE Handle
, LPOVERLAPPED overlapped
)
2050 FIXME("(Handle %p, overlapped %p): stub\n", Handle
, overlapped
);
2051 return ERROR_NOT_SUPPORTED
;
2054 /******************************************************************
2055 * SendARP (IPHLPAPI.@)
2057 * Send an ARP request.
2060 * DestIP [In] attempt to obtain this IP
2061 * SrcIP [In] optional sender IP address
2062 * pMacAddr [Out] buffer for the mac address
2063 * PhyAddrLen [In/Out] length of the output buffer
2067 * Failure: error code from winerror.h
2069 DWORD WINAPI
SendARP(IPAddr DestIP
, IPAddr SrcIP
, PULONG pMacAddr
, PULONG PhyAddrLen
)
2074 if (IsBadWritePtr(pMacAddr
, sizeof(ULONG
)) || IsBadWritePtr(PhyAddrLen
, sizeof(ULONG
)))
2075 return ERROR_INVALID_PARAMETER
;
2080 return TCPSendIoctl(INVALID_HANDLE_VALUE
, IOCTL_QUERY_IP_HW_ADDRESS
, IPs
, &Size
, pMacAddr
, PhyAddrLen
);
2084 /******************************************************************
2085 * SetIfEntry (IPHLPAPI.@)
2087 * Set the administrative status of an interface.
2090 * pIfRow [In] dwAdminStatus member specifies the new status.
2094 * Failure: error code from winerror.h
2097 * Stub, returns ERROR_NOT_SUPPORTED.
2099 DWORD WINAPI
SetIfEntry(PMIB_IFROW pIfRow
)
2101 FIXME("(pIfRow %p): stub\n", pIfRow
);
2102 /* this is supposed to set an interface administratively up or down.
2103 Could do SIOCSIFFLAGS and set/clear IFF_UP, but, not sure I want to, and
2104 this sort of down is indistinguishable from other sorts of down (e.g. no
2106 return ERROR_NOT_SUPPORTED
;
2110 /******************************************************************
2111 * SetIpForwardEntry (IPHLPAPI.@)
2113 * Modify an existing route.
2116 * pRoute [In] route with the new information
2120 * Failure: error code from winerror.h
2123 DWORD WINAPI
SetIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
2125 return setIpForwardEntry( pRoute
);
2129 /******************************************************************
2130 * SetIpNetEntry (IPHLPAPI.@)
2132 * Modify an existing ARP entry.
2135 * pArpEntry [In] ARP entry with the new information
2139 * Failure: error code from winerror.h
2141 DWORD WINAPI
SetIpNetEntry(PMIB_IPNETROW pArpEntry
)
2145 TCP_REQUEST_SET_INFORMATION_EX_ARP_ENTRY req
=
2146 TCP_REQUEST_SET_INFORMATION_INIT
;
2149 PMIB_IPNETROW arpBuff
;
2152 return ERROR_INVALID_PARAMETER
;
2154 if (!NT_SUCCESS(openTcpFile( &tcpFile
, FILE_READ_DATA
| FILE_WRITE_DATA
)))
2155 return ERROR_NOT_SUPPORTED
;
2157 if (!NT_SUCCESS(getNthIpEntity( tcpFile
, pArpEntry
->dwIndex
, &id
)))
2159 closeTcpFile(tcpFile
);
2160 return ERROR_INVALID_PARAMETER
;
2163 req
.Req
.ID
.toi_class
= INFO_CLASS_PROTOCOL
;
2164 req
.Req
.ID
.toi_type
= INFO_TYPE_PROVIDER
;
2165 req
.Req
.ID
.toi_id
= IP_MIB_ARPTABLE_ENTRY_ID
;
2166 req
.Req
.ID
.toi_entity
.tei_instance
= id
.tei_instance
;
2167 req
.Req
.ID
.toi_entity
.tei_entity
= AT_ENTITY
;
2168 req
.Req
.BufferSize
= sizeof(MIB_IPNETROW
);
2169 arpBuff
= (PMIB_IPNETROW
)&req
.Req
.Buffer
[0];
2171 RtlCopyMemory(arpBuff
, pArpEntry
, sizeof(MIB_IPNETROW
));
2173 status
= DeviceIoControl( tcpFile
,
2174 IOCTL_TCP_SET_INFORMATION_EX
,
2182 closeTcpFile(tcpFile
);
2187 return ERROR_INVALID_PARAMETER
;
2191 /******************************************************************
2192 * SetIpStatistics (IPHLPAPI.@)
2194 * Toggle IP forwarding and det the default TTL value.
2197 * pIpStats [In] IP statistics with the new information
2201 * Failure: error code from winerror.h
2204 * Stub, returns NO_ERROR.
2206 DWORD WINAPI
SetIpStatistics(PMIB_IPSTATS pIpStats
)
2208 FIXME("(pIpStats %p): stub\n", pIpStats
);
2213 /******************************************************************
2214 * SetIpTTL (IPHLPAPI.@)
2216 * Set the default TTL value.
2219 * nTTL [In] new TTL value
2223 * Failure: error code from winerror.h
2226 * Stub, returns NO_ERROR.
2228 DWORD WINAPI
SetIpTTL(UINT nTTL
)
2230 FIXME("(nTTL %d): stub\n", nTTL
);
2235 /******************************************************************
2236 * SetTcpEntry (IPHLPAPI.@)
2238 * Set the state of a TCP connection.
2241 * pTcpRow [In] specifies connection with new state
2245 * Failure: error code from winerror.h
2248 * Stub, returns NO_ERROR.
2250 DWORD WINAPI
SetTcpEntry(PMIB_TCPROW pTcpRow
)
2252 FIXME("(pTcpRow %p): stub\n", pTcpRow
);
2257 /******************************************************************
2258 * UnenableRouter (IPHLPAPI.@)
2260 * Decrement the IP-forwarding reference count. Turn off IP-forwarding
2261 * if it reaches zero.
2264 * pOverlapped [In/Out] should be the same as in EnableRouter()
2265 * lpdwEnableCount [Out] optional, receives reference count
2269 * Failure: error code from winerror.h
2272 * Stub, returns ERROR_NOT_SUPPORTED.
2274 DWORD WINAPI
UnenableRouter(OVERLAPPED
* pOverlapped
, LPDWORD lpdwEnableCount
)
2276 FIXME("(pOverlapped %p, lpdwEnableCount %p): stub\n", pOverlapped
,
2278 return ERROR_NOT_SUPPORTED
;
2284 DWORD WINAPI
GetIpErrorString(IP_STATUS ErrorCode
,PWCHAR Buffer
,PDWORD Size
)
2294 PIP_ADAPTER_ORDER_MAP WINAPI
GetAdapterOrderMap(VOID
)
2303 #ifdef GetAdaptersAddressesV1
2304 DWORD WINAPI DECLSPEC_HOTPATCH
GetAdaptersAddresses(ULONG Family
,ULONG Flags
,PVOID Reserved
,PIP_ADAPTER_ADDRESSES pAdapterAddresses
,PULONG pOutBufLen
)
2306 InterfaceIndexTable
*indexTable
;
2309 ULONG ret
, requiredSize
= 0;
2310 PIP_ADAPTER_ADDRESSES currentAddress
;
2311 PUCHAR currentLocation
;
2314 if (!pOutBufLen
) return ERROR_INVALID_PARAMETER
;
2315 if (Reserved
) return ERROR_INVALID_PARAMETER
;
2317 indexTable
= getInterfaceIndexTable();
2319 return ERROR_NOT_ENOUGH_MEMORY
;
2321 ret
= openTcpFile(&tcpFile
, FILE_READ_DATA
);
2322 if (!NT_SUCCESS(ret
))
2323 return ERROR_NO_DATA
;
2325 for (i
= indexTable
->numIndexes
; i
>= 0; i
--)
2327 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile
,
2329 indexTable
->indexes
[i
],
2332 /* The whole struct */
2333 requiredSize
+= sizeof(IP_ADAPTER_ADDRESSES
);
2336 if (!(Flags
& GAA_FLAG_SKIP_FRIENDLY_NAME
))
2337 requiredSize
+= strlen((char *)ifInfo
.if_info
.ent
.if_descr
) + 1; //FIXME
2340 requiredSize
+= strlen((char *)ifInfo
.if_info
.ent
.if_descr
) + 1;
2342 /* Unicast address */
2343 if (!(Flags
& GAA_FLAG_SKIP_UNICAST
))
2344 requiredSize
+= sizeof(IP_ADAPTER_UNICAST_ADDRESS
);
2346 /* FIXME: Implement multicast, anycast, and dns server stuff */
2348 /* FIXME: Implement dns suffix and description */
2349 requiredSize
+= 2 * sizeof(WCHAR
);
2351 /* We're only going to implement what's required for XP SP0 */
2354 TRACE("size: %d, requiredSize: %d\n", *pOutBufLen
, requiredSize
);
2355 if (!pAdapterAddresses
|| *pOutBufLen
< requiredSize
)
2357 *pOutBufLen
= requiredSize
;
2358 closeTcpFile(tcpFile
);
2360 return ERROR_BUFFER_OVERFLOW
;
2363 RtlZeroMemory(pAdapterAddresses
, requiredSize
);
2365 /* Let's set up the pointers */
2366 currentAddress
= pAdapterAddresses
;
2367 for (i
= indexTable
->numIndexes
; i
>= 0; i
--)
2369 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile
,
2371 indexTable
->indexes
[i
],
2374 currentLocation
= (PUCHAR
)currentAddress
+ (ULONG_PTR
)sizeof(IP_ADAPTER_ADDRESSES
);
2376 /* FIXME: Friendly name */
2377 if (!(Flags
& GAA_FLAG_SKIP_FRIENDLY_NAME
))
2379 currentAddress
->FriendlyName
= (PVOID
)currentLocation
;
2380 currentLocation
+= sizeof(WCHAR
);
2384 currentAddress
->AdapterName
= (PVOID
)currentLocation
;
2385 currentLocation
+= strlen((char *)ifInfo
.if_info
.ent
.if_descr
) + 1;
2387 /* Unicast address */
2388 if (!(Flags
& GAA_FLAG_SKIP_UNICAST
))
2390 currentAddress
->FirstUnicastAddress
= (PVOID
)currentLocation
;
2391 currentLocation
+= sizeof(IP_ADAPTER_UNICAST_ADDRESS
);
2392 currentAddress
->FirstUnicastAddress
->Address
.lpSockaddr
= (PVOID
)currentLocation
;
2393 currentLocation
+= sizeof(struct sockaddr
);
2396 /* FIXME: Implement multicast, anycast, and dns server stuff */
2398 /* FIXME: Implement dns suffix and description */
2399 currentAddress
->DnsSuffix
= (PVOID
)currentLocation
;
2400 currentLocation
+= sizeof(WCHAR
);
2402 currentAddress
->Description
= (PVOID
)currentLocation
;
2403 currentLocation
+= sizeof(WCHAR
);
2405 currentAddress
->Next
= (PVOID
)currentLocation
;
2406 /* Terminate the last address correctly */
2408 currentAddress
->Next
= NULL
;
2410 /* We're only going to implement what's required for XP SP0 */
2412 currentAddress
= currentAddress
->Next
;
2416 /* Now again, for real this time */
2418 currentAddress
= pAdapterAddresses
;
2419 for (i
= indexTable
->numIndexes
; i
>= 0; i
--)
2421 if (NT_SUCCESS(getIPAddrEntryForIf(tcpFile
,
2423 indexTable
->indexes
[i
],
2426 /* Make sure we're not looping more than we hoped for */
2427 ASSERT(currentAddress
);
2429 /* Alignment information */
2430 currentAddress
->Length
= sizeof(IP_ADAPTER_ADDRESSES
);
2431 currentAddress
->IfIndex
= indexTable
->indexes
[i
];
2434 strcpy(currentAddress
->AdapterName
, (char *)ifInfo
.if_info
.ent
.if_descr
);
2436 if (!(Flags
& GAA_FLAG_SKIP_UNICAST
))
2438 currentAddress
->FirstUnicastAddress
->Length
= sizeof(IP_ADAPTER_UNICAST_ADDRESS
);
2439 currentAddress
->FirstUnicastAddress
->Flags
= 0; //FIXME
2440 currentAddress
->FirstUnicastAddress
->Next
= NULL
; //FIXME: Support more than one address per adapter
2441 currentAddress
->FirstUnicastAddress
->Address
.lpSockaddr
->sa_family
= AF_INET
;
2442 memcpy(currentAddress
->FirstUnicastAddress
->Address
.lpSockaddr
->sa_data
,
2443 &ifInfo
.ip_addr
.iae_addr
,
2444 sizeof(ifInfo
.ip_addr
.iae_addr
));
2445 currentAddress
->FirstUnicastAddress
->Address
.iSockaddrLength
= sizeof(ifInfo
.ip_addr
.iae_addr
) + sizeof(USHORT
);
2446 currentAddress
->FirstUnicastAddress
->PrefixOrigin
= IpPrefixOriginOther
; //FIXME
2447 currentAddress
->FirstUnicastAddress
->SuffixOrigin
= IpPrefixOriginOther
; //FIXME
2448 currentAddress
->FirstUnicastAddress
->DadState
= IpDadStatePreferred
; //FIXME
2449 currentAddress
->FirstUnicastAddress
->ValidLifetime
= 0xFFFFFFFF; //FIXME
2450 currentAddress
->FirstUnicastAddress
->PreferredLifetime
= 0xFFFFFFFF; //FIXME
2451 currentAddress
->FirstUnicastAddress
->LeaseLifetime
= 0xFFFFFFFF; //FIXME
2454 /* FIXME: Implement multicast, anycast, and dns server stuff */
2455 currentAddress
->FirstAnycastAddress
= NULL
;
2456 currentAddress
->FirstMulticastAddress
= NULL
;
2457 currentAddress
->FirstDnsServerAddress
= NULL
;
2459 /* FIXME: Implement dns suffix, description, and friendly name */
2460 currentAddress
->DnsSuffix
[0] = UNICODE_NULL
;
2461 currentAddress
->Description
[0] = UNICODE_NULL
;
2462 currentAddress
->FriendlyName
[0] = UNICODE_NULL
;
2464 /* Physical Address */
2465 memcpy(currentAddress
->PhysicalAddress
, ifInfo
.if_info
.ent
.if_physaddr
, ifInfo
.if_info
.ent
.if_physaddrlen
);
2466 currentAddress
->PhysicalAddressLength
= ifInfo
.if_info
.ent
.if_physaddrlen
;
2469 currentAddress
->Flags
= 0; //FIXME
2472 currentAddress
->Mtu
= ifInfo
.if_info
.ent
.if_mtu
;
2474 /* Interface type */
2475 currentAddress
->IfType
= ifInfo
.if_info
.ent
.if_type
;
2477 /* Operational status */
2478 if(ifInfo
.if_info
.ent
.if_operstatus
>= IF_OPER_STATUS_CONNECTING
)
2479 currentAddress
->OperStatus
= IfOperStatusUp
;
2481 currentAddress
->OperStatus
= IfOperStatusDown
;
2483 /* We're only going to implement what's required for XP SP0 */
2485 /* Move to the next address */
2486 currentAddress
= currentAddress
->Next
;
2490 closeTcpFile(tcpFile
);
2500 BOOL WINAPI
CancelIPChangeNotify(LPOVERLAPPED notifyOverlapped
)
2509 DWORD WINAPI
GetBestInterfaceEx(struct sockaddr
*pDestAddr
,PDWORD pdwBestIfIndex
)
2518 DWORD WINAPI
NhpAllocateAndGetInterfaceInfoFromStack(IP_INTERFACE_NAME_INFO
**ppTable
,PDWORD pdwCount
,BOOL bOrder
,HANDLE hHeap
,DWORD dwFlags
)
2527 DWORD WINAPI
GetIcmpStatisticsEx(PMIB_ICMP_EX pStats
,DWORD dwFamily
)
2532 return ERROR_INVALID_PARAMETER
;
2534 if (dwFamily
!= AF_INET
&& dwFamily
!= AF_INET6
)
2535 return ERROR_INVALID_PARAMETER
;
2541 SetIpForwardEntryToStack(PMIB_IPFORWARDROW pRoute
)
2543 FIXME("SetIpForwardEntryToStack() stub\n");
2548 NhGetInterfaceNameFromDeviceGuid(DWORD dwUnknown1
,
2554 FIXME("NhGetInterfaceNameFromDeviceGuid() stub\n");