2 * iphlpapi dll implementation
4 * Copyright (C) 2003,2006 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 St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include <sys/types.h>
26 #ifdef HAVE_NETINET_IN_H
27 # include <netinet/in.h>
29 #ifdef HAVE_ARPA_INET_H
30 # include <arpa/inet.h>
32 #ifdef HAVE_ARPA_NAMESER_H
33 # include <arpa/nameser.h>
48 #include "wine/debug.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi
);
53 #define INADDR_NONE ~0UL
56 static int resolver_initialised
;
58 /* call res_init() just once because of a bug in Mac OS X 10.4 */
59 static void initialise_resolver(void)
61 if (!resolver_initialised
)
64 resolver_initialised
= 1;
68 BOOL WINAPI
DllMain (HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
71 case DLL_PROCESS_ATTACH
:
72 DisableThreadLibraryCalls( hinstDLL
);
75 case DLL_PROCESS_DETACH
:
81 /******************************************************************
82 * AddIPAddress (IPHLPAPI.@)
84 * Add an IP address to an adapter.
87 * Address [In] IP address to add to the adapter
88 * IpMask [In] subnet mask for the IP address
89 * IfIndex [In] adapter index to add the address
90 * NTEContext [Out] Net Table Entry (NTE) context for the IP address
91 * NTEInstance [Out] NTE instance for the IP address
95 * Failure: error code from winerror.h
98 * Stub. Currently returns ERROR_NOT_SUPPORTED.
100 DWORD WINAPI
AddIPAddress(IPAddr Address
, IPMask IpMask
, DWORD IfIndex
, PULONG NTEContext
, PULONG NTEInstance
)
103 return ERROR_NOT_SUPPORTED
;
107 /******************************************************************
108 * AllocateAndGetIfTableFromStack (IPHLPAPI.@)
110 * Get table of local interfaces.
111 * Like GetIfTable(), but allocate the returned table from heap.
114 * ppIfTable [Out] pointer into which the MIB_IFTABLE is
115 * allocated and returned.
116 * bOrder [In] whether to sort the table
117 * heap [In] heap from which the table is allocated
118 * flags [In] flags to HeapAlloc
121 * ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
122 * GetIfTable() returns otherwise.
124 DWORD WINAPI
AllocateAndGetIfTableFromStack(PMIB_IFTABLE
*ppIfTable
,
125 BOOL bOrder
, HANDLE heap
, DWORD flags
)
129 TRACE("ppIfTable %p, bOrder %d, heap %p, flags 0x%08x\n", ppIfTable
,
130 bOrder
, heap
, flags
);
132 ret
= ERROR_INVALID_PARAMETER
;
136 ret
= GetIfTable(*ppIfTable
, &dwSize
, bOrder
);
137 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
138 *ppIfTable
= HeapAlloc(heap
, flags
, dwSize
);
139 ret
= GetIfTable(*ppIfTable
, &dwSize
, bOrder
);
142 TRACE("returning %d\n", ret
);
147 static int IpAddrTableSorter(const void *a
, const void *b
)
152 ret
= ((const MIB_IPADDRROW
*)a
)->dwAddr
- ((const MIB_IPADDRROW
*)b
)->dwAddr
;
159 /******************************************************************
160 * AllocateAndGetIpAddrTableFromStack (IPHLPAPI.@)
162 * Get interface-to-IP address mapping table.
163 * Like GetIpAddrTable(), but allocate the returned table from heap.
166 * ppIpAddrTable [Out] pointer into which the MIB_IPADDRTABLE is
167 * allocated and returned.
168 * bOrder [In] whether to sort the table
169 * heap [In] heap from which the table is allocated
170 * flags [In] flags to HeapAlloc
173 * ERROR_INVALID_PARAMETER if ppIpAddrTable is NULL, other error codes on
174 * failure, NO_ERROR on success.
176 DWORD WINAPI
AllocateAndGetIpAddrTableFromStack(PMIB_IPADDRTABLE
*ppIpAddrTable
,
177 BOOL bOrder
, HANDLE heap
, DWORD flags
)
181 TRACE("ppIpAddrTable %p, bOrder %d, heap %p, flags 0x%08x\n",
182 ppIpAddrTable
, bOrder
, heap
, flags
);
183 ret
= getIPAddrTable(ppIpAddrTable
, heap
, flags
);
185 qsort((*ppIpAddrTable
)->table
, (*ppIpAddrTable
)->dwNumEntries
,
186 sizeof(MIB_IPADDRROW
), IpAddrTableSorter
);
187 TRACE("returning %d\n", ret
);
192 /******************************************************************
193 * CreateIpForwardEntry (IPHLPAPI.@)
195 * Create a route in the local computer's IP table.
198 * pRoute [In] new route information
202 * Failure: error code from winerror.h
205 * Stub, always returns NO_ERROR.
207 DWORD WINAPI
CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
209 FIXME("(pRoute %p): stub\n", pRoute
);
210 /* could use SIOCADDRT, not sure I want to */
215 /******************************************************************
216 * CreateIpNetEntry (IPHLPAPI.@)
218 * Create entry in the ARP table.
221 * pArpEntry [In] new ARP entry
225 * Failure: error code from winerror.h
228 * Stub, always returns NO_ERROR.
230 DWORD WINAPI
CreateIpNetEntry(PMIB_IPNETROW pArpEntry
)
232 FIXME("(pArpEntry %p)\n", pArpEntry
);
233 /* could use SIOCSARP on systems that support it, not sure I want to */
238 /******************************************************************
239 * CreateProxyArpEntry (IPHLPAPI.@)
241 * Create a Proxy ARP (PARP) entry for an IP address.
244 * dwAddress [In] IP address for which this computer acts as a proxy.
245 * dwMask [In] subnet mask for dwAddress
246 * dwIfIndex [In] interface index
250 * Failure: error code from winerror.h
253 * Stub, returns ERROR_NOT_SUPPORTED.
255 DWORD WINAPI
CreateProxyArpEntry(DWORD dwAddress
, DWORD dwMask
, DWORD dwIfIndex
)
257 FIXME("(dwAddress 0x%08x, dwMask 0x%08x, dwIfIndex 0x%08x): stub\n",
258 dwAddress
, dwMask
, dwIfIndex
);
259 return ERROR_NOT_SUPPORTED
;
263 /******************************************************************
264 * DeleteIPAddress (IPHLPAPI.@)
266 * Delete an IP address added with AddIPAddress().
269 * NTEContext [In] NTE context from AddIPAddress();
273 * Failure: error code from winerror.h
276 * Stub, returns ERROR_NOT_SUPPORTED.
278 DWORD WINAPI
DeleteIPAddress(ULONG NTEContext
)
280 FIXME("(NTEContext %d): stub\n", NTEContext
);
281 return ERROR_NOT_SUPPORTED
;
285 /******************************************************************
286 * DeleteIpForwardEntry (IPHLPAPI.@)
291 * pRoute [In] route to delete
295 * Failure: error code from winerror.h
298 * Stub, returns NO_ERROR.
300 DWORD WINAPI
DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
302 FIXME("(pRoute %p): stub\n", pRoute
);
303 /* could use SIOCDELRT, not sure I want to */
308 /******************************************************************
309 * DeleteIpNetEntry (IPHLPAPI.@)
311 * Delete an ARP entry.
314 * pArpEntry [In] ARP entry to delete
318 * Failure: error code from winerror.h
321 * Stub, returns NO_ERROR.
323 DWORD WINAPI
DeleteIpNetEntry(PMIB_IPNETROW pArpEntry
)
325 FIXME("(pArpEntry %p): stub\n", pArpEntry
);
326 /* could use SIOCDARP on systems that support it, not sure I want to */
331 /******************************************************************
332 * DeleteProxyArpEntry (IPHLPAPI.@)
334 * Delete a Proxy ARP entry.
337 * dwAddress [In] IP address for which this computer acts as a proxy.
338 * dwMask [In] subnet mask for dwAddress
339 * dwIfIndex [In] interface index
343 * Failure: error code from winerror.h
346 * Stub, returns ERROR_NOT_SUPPORTED.
348 DWORD WINAPI
DeleteProxyArpEntry(DWORD dwAddress
, DWORD dwMask
, DWORD dwIfIndex
)
350 FIXME("(dwAddress 0x%08x, dwMask 0x%08x, dwIfIndex 0x%08x): stub\n",
351 dwAddress
, dwMask
, dwIfIndex
);
352 return ERROR_NOT_SUPPORTED
;
356 /******************************************************************
357 * EnableRouter (IPHLPAPI.@)
359 * Turn on ip forwarding.
363 * pOverlapped [In/Out] hEvent member should contain a valid handle.
366 * Success: ERROR_IO_PENDING
367 * Failure: error code from winerror.h
370 * Stub, returns ERROR_NOT_SUPPORTED.
372 DWORD WINAPI
EnableRouter(HANDLE
* pHandle
, OVERLAPPED
* pOverlapped
)
374 FIXME("(pHandle %p, pOverlapped %p): stub\n", pHandle
, pOverlapped
);
375 /* could echo "1" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
376 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
378 return ERROR_NOT_SUPPORTED
;
382 /******************************************************************
383 * FlushIpNetTable (IPHLPAPI.@)
385 * Delete all ARP entries of an interface
388 * dwIfIndex [In] interface index
392 * Failure: error code from winerror.h
395 * Stub, returns ERROR_NOT_SUPPORTED.
397 DWORD WINAPI
FlushIpNetTable(DWORD dwIfIndex
)
399 FIXME("(dwIfIndex 0x%08x): stub\n", dwIfIndex
);
400 /* this flushes the arp cache of the given index */
401 return ERROR_NOT_SUPPORTED
;
405 /******************************************************************
406 * GetAdapterIndex (IPHLPAPI.@)
408 * Get interface index from its name.
411 * AdapterName [In] unicode string with the adapter name
412 * IfIndex [Out] returns found interface index
416 * Failure: error code from winerror.h
418 DWORD WINAPI
GetAdapterIndex(LPWSTR AdapterName
, PULONG IfIndex
)
420 char adapterName
[MAX_ADAPTER_NAME
];
424 TRACE("(AdapterName %p, IfIndex %p)\n", AdapterName
, IfIndex
);
425 /* The adapter name is guaranteed not to have any unicode characters, so
426 * this translation is never lossy */
427 for (i
= 0; i
< sizeof(adapterName
) - 1 && AdapterName
[i
]; i
++)
428 adapterName
[i
] = (char)AdapterName
[i
];
429 adapterName
[i
] = '\0';
430 ret
= getInterfaceIndexByName(adapterName
, IfIndex
);
431 TRACE("returning %d\n", ret
);
436 /******************************************************************
437 * GetAdaptersInfo (IPHLPAPI.@)
439 * Get information about adapters.
442 * pAdapterInfo [Out] buffer for adapter infos
443 * pOutBufLen [In] length of output buffer
447 * Failure: error code from winerror.h
449 DWORD WINAPI
GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo
, PULONG pOutBufLen
)
453 TRACE("pAdapterInfo %p, pOutBufLen %p\n", pAdapterInfo
, pOutBufLen
);
455 ret
= ERROR_INVALID_PARAMETER
;
457 DWORD numNonLoopbackInterfaces
= getNumNonLoopbackInterfaces();
459 if (numNonLoopbackInterfaces
> 0) {
460 DWORD numIPAddresses
= getNumIPAddresses();
463 /* This may slightly overestimate the amount of space needed, because
464 * the IP addresses include the loopback address, but it's easier
465 * to make sure there's more than enough space than to make sure there's
466 * precisely enough space.
468 size
= sizeof(IP_ADAPTER_INFO
) * numNonLoopbackInterfaces
;
469 size
+= numIPAddresses
* sizeof(IP_ADDR_STRING
);
470 if (!pAdapterInfo
|| *pOutBufLen
< size
) {
472 ret
= ERROR_BUFFER_OVERFLOW
;
475 InterfaceIndexTable
*table
= NULL
;
476 PMIB_IPADDRTABLE ipAddrTable
= NULL
;
477 PMIB_IPFORWARDTABLE routeTable
= NULL
;
479 ret
= getIPAddrTable(&ipAddrTable
, GetProcessHeap(), 0);
481 ret
= AllocateAndGetIpForwardTableFromStack(&routeTable
, FALSE
, GetProcessHeap(), 0);
483 table
= getNonLoopbackInterfaceIndexTable();
485 size
= sizeof(IP_ADAPTER_INFO
) * table
->numIndexes
;
486 size
+= ipAddrTable
->dwNumEntries
* sizeof(IP_ADDR_STRING
);
487 if (*pOutBufLen
< size
) {
489 ret
= ERROR_INSUFFICIENT_BUFFER
;
494 BOOL winsEnabled
= FALSE
;
495 IP_ADDRESS_STRING primaryWINS
, secondaryWINS
;
496 PIP_ADDR_STRING nextIPAddr
= (PIP_ADDR_STRING
)((LPBYTE
)pAdapterInfo
497 + numNonLoopbackInterfaces
* sizeof(IP_ADAPTER_INFO
));
499 memset(pAdapterInfo
, 0, size
);
500 /* @@ Wine registry key: HKCU\Software\Wine\Network */
501 if (RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\Network",
502 &hKey
) == ERROR_SUCCESS
) {
503 DWORD size
= sizeof(primaryWINS
.String
);
506 RegQueryValueExA(hKey
, "WinsServer", NULL
, NULL
,
507 (LPBYTE
)primaryWINS
.String
, &size
);
508 addr
= inet_addr(primaryWINS
.String
);
509 if (addr
!= INADDR_NONE
&& addr
!= INADDR_ANY
)
511 size
= sizeof(secondaryWINS
.String
);
512 RegQueryValueExA(hKey
, "BackupWinsServer", NULL
, NULL
,
513 (LPBYTE
)secondaryWINS
.String
, &size
);
514 addr
= inet_addr(secondaryWINS
.String
);
515 if (addr
!= INADDR_NONE
&& addr
!= INADDR_ANY
)
519 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
520 PIP_ADAPTER_INFO ptr
= &pAdapterInfo
[ndx
];
522 PIP_ADDR_STRING currentIPAddr
= &ptr
->IpAddressList
;
523 BOOL firstIPAddr
= TRUE
;
525 /* on Win98 this is left empty, but whatever */
526 getInterfaceNameByIndex(table
->indexes
[ndx
], ptr
->AdapterName
);
527 getInterfaceNameByIndex(table
->indexes
[ndx
], ptr
->Description
);
528 ptr
->AddressLength
= sizeof(ptr
->Address
);
529 getInterfacePhysicalByIndex(table
->indexes
[ndx
],
530 &ptr
->AddressLength
, ptr
->Address
, &ptr
->Type
);
531 ptr
->Index
= table
->indexes
[ndx
];
532 for (i
= 0; i
< ipAddrTable
->dwNumEntries
; i
++) {
533 if (ipAddrTable
->table
[i
].dwIndex
== ptr
->Index
) {
535 toIPAddressString(ipAddrTable
->table
[i
].dwAddr
,
536 ptr
->IpAddressList
.IpAddress
.String
);
537 toIPAddressString(ipAddrTable
->table
[i
].dwMask
,
538 ptr
->IpAddressList
.IpMask
.String
);
542 currentIPAddr
->Next
= nextIPAddr
;
543 currentIPAddr
= nextIPAddr
;
544 toIPAddressString(ipAddrTable
->table
[i
].dwAddr
,
545 currentIPAddr
->IpAddress
.String
);
546 toIPAddressString(ipAddrTable
->table
[i
].dwMask
,
547 currentIPAddr
->IpMask
.String
);
552 /* Find first router through this interface, which we'll assume
553 * is the default gateway for this adapter */
554 for (i
= 0; i
< routeTable
->dwNumEntries
; i
++)
555 if (routeTable
->table
[i
].dwForwardIfIndex
== ptr
->Index
556 && routeTable
->table
[i
].dwForwardType
==
557 MIB_IPROUTE_TYPE_INDIRECT
)
558 toIPAddressString(routeTable
->table
[i
].dwForwardNextHop
,
559 ptr
->GatewayList
.IpAddress
.String
);
561 ptr
->HaveWins
= TRUE
;
562 memcpy(ptr
->PrimaryWinsServer
.IpAddress
.String
,
563 primaryWINS
.String
, sizeof(primaryWINS
.String
));
564 memcpy(ptr
->SecondaryWinsServer
.IpAddress
.String
,
565 secondaryWINS
.String
, sizeof(secondaryWINS
.String
));
567 if (ndx
< table
->numIndexes
- 1)
568 ptr
->Next
= &pAdapterInfo
[ndx
+ 1];
574 HeapFree(GetProcessHeap(), 0, table
);
577 ret
= ERROR_OUTOFMEMORY
;
578 HeapFree(GetProcessHeap(), 0, routeTable
);
579 HeapFree(GetProcessHeap(), 0, ipAddrTable
);
585 TRACE("returning %d\n", ret
);
590 /******************************************************************
591 * GetBestInterface (IPHLPAPI.@)
593 * Get the interface, with the best route for the given IP address.
596 * dwDestAddr [In] IP address to search the interface for
597 * pdwBestIfIndex [Out] found best interface
601 * Failure: error code from winerror.h
603 DWORD WINAPI
GetBestInterface(IPAddr dwDestAddr
, PDWORD pdwBestIfIndex
)
605 struct WS_sockaddr_in sa_in
;
606 memset(&sa_in
, 0, sizeof(sa_in
));
607 sa_in
.sin_family
= AF_INET
;
608 sa_in
.sin_addr
.S_un
.S_addr
= dwDestAddr
;
609 return GetBestInterfaceEx((struct WS_sockaddr
*)&sa_in
, pdwBestIfIndex
);
612 /******************************************************************
613 * GetBestInterfaceEx (IPHLPAPI.@)
615 * Get the interface, with the best route for the given IP address.
618 * dwDestAddr [In] IP address to search the interface for
619 * pdwBestIfIndex [Out] found best interface
623 * Failure: error code from winerror.h
625 DWORD WINAPI
GetBestInterfaceEx(struct WS_sockaddr
*pDestAddr
, PDWORD pdwBestIfIndex
)
629 TRACE("pDestAddr %p, pdwBestIfIndex %p\n", pDestAddr
, pdwBestIfIndex
);
630 if (!pDestAddr
|| !pdwBestIfIndex
)
631 ret
= ERROR_INVALID_PARAMETER
;
633 MIB_IPFORWARDROW ipRow
;
635 if (pDestAddr
->sa_family
== AF_INET
) {
636 ret
= GetBestRoute(((struct WS_sockaddr_in
*)pDestAddr
)->sin_addr
.S_un
.S_addr
, 0, &ipRow
);
637 if (ret
== ERROR_SUCCESS
)
638 *pdwBestIfIndex
= ipRow
.dwForwardIfIndex
;
640 FIXME("address family %d not supported\n", pDestAddr
->sa_family
);
641 ret
= ERROR_NOT_SUPPORTED
;
644 TRACE("returning %d\n", ret
);
649 /******************************************************************
650 * GetBestRoute (IPHLPAPI.@)
652 * Get the best route for the given IP address.
655 * dwDestAddr [In] IP address to search the best route for
656 * dwSourceAddr [In] optional source IP address
657 * pBestRoute [Out] found best route
661 * Failure: error code from winerror.h
663 DWORD WINAPI
GetBestRoute(DWORD dwDestAddr
, DWORD dwSourceAddr
, PMIB_IPFORWARDROW pBestRoute
)
665 PMIB_IPFORWARDTABLE table
;
668 TRACE("dwDestAddr 0x%08x, dwSourceAddr 0x%08x, pBestRoute %p\n", dwDestAddr
,
669 dwSourceAddr
, pBestRoute
);
671 return ERROR_INVALID_PARAMETER
;
673 ret
= AllocateAndGetIpForwardTableFromStack(&table
, FALSE
, GetProcessHeap(), 0);
675 DWORD ndx
, matchedBits
, matchedNdx
= table
->dwNumEntries
;
677 for (ndx
= 0, matchedBits
= 0; ndx
< table
->dwNumEntries
; ndx
++) {
678 if (table
->table
[ndx
].dwForwardType
!= MIB_IPROUTE_TYPE_INVALID
&&
679 (dwDestAddr
& table
->table
[ndx
].dwForwardMask
) ==
680 (table
->table
[ndx
].dwForwardDest
& table
->table
[ndx
].dwForwardMask
)) {
681 DWORD numShifts
, mask
;
683 for (numShifts
= 0, mask
= table
->table
[ndx
].dwForwardMask
;
684 mask
&& !(mask
& 1); mask
>>= 1, numShifts
++)
686 if (numShifts
> matchedBits
) {
687 matchedBits
= numShifts
;
690 else if (!matchedBits
&& table
->table
[ndx
].dwForwardType
==
691 MIB_IPROUTE_TYPE_INDIRECT
) {
692 /* default to a default gateway */
697 if (matchedNdx
< table
->dwNumEntries
) {
698 memcpy(pBestRoute
, &table
->table
[matchedNdx
], sizeof(MIB_IPFORWARDROW
));
702 /* No route matches, which can happen if there's no default route. */
703 ret
= ERROR_HOST_UNREACHABLE
;
705 HeapFree(GetProcessHeap(), 0, table
);
707 TRACE("returning %d\n", ret
);
712 /******************************************************************
713 * GetFriendlyIfIndex (IPHLPAPI.@)
715 * Get a "friendly" version of IfIndex, which is one that doesn't
716 * have the top byte set. Doesn't validate whether IfIndex is a valid
720 * IfIndex [In] interface index to get the friendly one for
723 * A friendly version of IfIndex.
725 DWORD WINAPI
GetFriendlyIfIndex(DWORD IfIndex
)
727 /* windows doesn't validate these, either, just makes sure the top byte is
728 cleared. I assume my ifenum module never gives an index with the top
730 TRACE("returning %d\n", IfIndex
);
735 /******************************************************************
736 * GetIfEntry (IPHLPAPI.@)
738 * Get information about an interface.
741 * pIfRow [In/Out] In: dwIndex of MIB_IFROW selects the interface.
742 * Out: interface information
746 * Failure: error code from winerror.h
748 DWORD WINAPI
GetIfEntry(PMIB_IFROW pIfRow
)
751 char nameBuf
[MAX_ADAPTER_NAME
];
754 TRACE("pIfRow %p\n", pIfRow
);
756 return ERROR_INVALID_PARAMETER
;
758 name
= getInterfaceNameByIndex(pIfRow
->dwIndex
, nameBuf
);
760 ret
= getInterfaceEntryByName(name
, pIfRow
);
762 ret
= getInterfaceStatsByName(name
, pIfRow
);
765 ret
= ERROR_INVALID_DATA
;
766 TRACE("returning %d\n", ret
);
771 static int IfTableSorter(const void *a
, const void *b
)
776 ret
= ((const MIB_IFROW
*)a
)->dwIndex
- ((const MIB_IFROW
*)b
)->dwIndex
;
783 /******************************************************************
784 * GetIfTable (IPHLPAPI.@)
786 * Get a table of local interfaces.
789 * pIfTable [Out] buffer for local interfaces table
790 * pdwSize [In/Out] length of output buffer
791 * bOrder [In] whether to sort the table
795 * Failure: error code from winerror.h
798 * If pdwSize is less than required, the function will return
799 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
801 * If bOrder is true, the returned table will be sorted by interface index.
803 DWORD WINAPI
GetIfTable(PMIB_IFTABLE pIfTable
, PULONG pdwSize
, BOOL bOrder
)
807 TRACE("pIfTable %p, pdwSize %p, bOrder %d\n", pdwSize
, pdwSize
,
810 ret
= ERROR_INVALID_PARAMETER
;
812 DWORD numInterfaces
= getNumInterfaces();
813 ULONG size
= sizeof(MIB_IFTABLE
);
815 if (numInterfaces
> 1)
816 size
+= (numInterfaces
- 1) * sizeof(MIB_IFROW
);
817 if (!pIfTable
|| *pdwSize
< size
) {
819 ret
= ERROR_INSUFFICIENT_BUFFER
;
822 InterfaceIndexTable
*table
= getInterfaceIndexTable();
825 size
= sizeof(MIB_IFTABLE
);
826 if (table
->numIndexes
> 1)
827 size
+= (table
->numIndexes
- 1) * sizeof(MIB_IFROW
);
828 if (*pdwSize
< size
) {
830 ret
= ERROR_INSUFFICIENT_BUFFER
;
836 pIfTable
->dwNumEntries
= 0;
837 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
838 pIfTable
->table
[ndx
].dwIndex
= table
->indexes
[ndx
];
839 GetIfEntry(&pIfTable
->table
[ndx
]);
840 pIfTable
->dwNumEntries
++;
843 qsort(pIfTable
->table
, pIfTable
->dwNumEntries
, sizeof(MIB_IFROW
),
847 HeapFree(GetProcessHeap(), 0, table
);
850 ret
= ERROR_OUTOFMEMORY
;
853 TRACE("returning %d\n", ret
);
858 /******************************************************************
859 * GetInterfaceInfo (IPHLPAPI.@)
861 * Get a list of network interface adapters.
864 * pIfTable [Out] buffer for interface adapters
865 * dwOutBufLen [Out] if buffer is too small, returns required size
869 * Failure: error code from winerror.h
872 * MSDN states this should return non-loopback interfaces only.
874 DWORD WINAPI
GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable
, PULONG dwOutBufLen
)
878 TRACE("pIfTable %p, dwOutBufLen %p\n", pIfTable
, dwOutBufLen
);
880 ret
= ERROR_INVALID_PARAMETER
;
882 DWORD numInterfaces
= getNumInterfaces();
883 ULONG size
= sizeof(IP_INTERFACE_INFO
);
885 if (numInterfaces
> 1)
886 size
+= (numInterfaces
- 1) * sizeof(IP_ADAPTER_INDEX_MAP
);
887 if (!pIfTable
|| *dwOutBufLen
< size
) {
889 ret
= ERROR_INSUFFICIENT_BUFFER
;
892 InterfaceIndexTable
*table
= getInterfaceIndexTable();
895 size
= sizeof(IP_INTERFACE_INFO
);
896 if (table
->numIndexes
> 1)
897 size
+= (table
->numIndexes
- 1) * sizeof(IP_ADAPTER_INDEX_MAP
);
898 if (*dwOutBufLen
< size
) {
900 ret
= ERROR_INSUFFICIENT_BUFFER
;
904 char nameBuf
[MAX_ADAPTER_NAME
];
907 pIfTable
->NumAdapters
= 0;
908 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
909 const char *walker
, *name
;
912 pIfTable
->Adapter
[ndx
].Index
= table
->indexes
[ndx
];
913 name
= getInterfaceNameByIndex(table
->indexes
[ndx
], nameBuf
);
914 for (walker
= name
, assigner
= pIfTable
->Adapter
[ndx
].Name
;
916 assigner
- pIfTable
->Adapter
[ndx
].Name
< MAX_ADAPTER_NAME
- 1;
917 walker
++, assigner
++)
920 pIfTable
->NumAdapters
++;
924 HeapFree(GetProcessHeap(), 0, table
);
927 ret
= ERROR_OUTOFMEMORY
;
930 TRACE("returning %d\n", ret
);
935 /******************************************************************
936 * GetIpAddrTable (IPHLPAPI.@)
938 * Get interface-to-IP address mapping table.
941 * pIpAddrTable [Out] buffer for mapping table
942 * pdwSize [In/Out] length of output buffer
943 * bOrder [In] whether to sort the table
947 * Failure: error code from winerror.h
950 * If pdwSize is less than required, the function will return
951 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
953 * If bOrder is true, the returned table will be sorted by the next hop and
954 * an assortment of arbitrary parameters.
956 DWORD WINAPI
GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable
, PULONG pdwSize
, BOOL bOrder
)
960 TRACE("pIpAddrTable %p, pdwSize %p, bOrder %d\n", pIpAddrTable
, pdwSize
,
963 ret
= ERROR_INVALID_PARAMETER
;
965 PMIB_IPADDRTABLE table
;
967 ret
= getIPAddrTable(&table
, GetProcessHeap(), 0);
970 ULONG size
= sizeof(MIB_IPADDRTABLE
);
972 if (table
->dwNumEntries
> 1)
973 size
+= (table
->dwNumEntries
- 1) * sizeof(MIB_IPADDRROW
);
974 if (!pIpAddrTable
|| *pdwSize
< size
) {
976 ret
= ERROR_INSUFFICIENT_BUFFER
;
980 memcpy(pIpAddrTable
, table
, size
);
982 qsort(pIpAddrTable
->table
, pIpAddrTable
->dwNumEntries
,
983 sizeof(MIB_IPADDRROW
), IpAddrTableSorter
);
986 HeapFree(GetProcessHeap(), 0, table
);
989 TRACE("returning %d\n", ret
);
994 /******************************************************************
995 * GetIpForwardTable (IPHLPAPI.@)
997 * Get the route table.
1000 * pIpForwardTable [Out] buffer for route table
1001 * pdwSize [In/Out] length of output buffer
1002 * bOrder [In] whether to sort the table
1006 * Failure: error code from winerror.h
1009 * If pdwSize is less than required, the function will return
1010 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
1012 * If bOrder is true, the returned table will be sorted by the next hop and
1013 * an assortment of arbitrary parameters.
1015 DWORD WINAPI
GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable
, PULONG pdwSize
, BOOL bOrder
)
1018 PMIB_IPFORWARDTABLE table
;
1020 TRACE("pIpForwardTable %p, pdwSize %p, bOrder %d\n", pIpForwardTable
, pdwSize
, bOrder
);
1022 if (!pdwSize
) return ERROR_INVALID_PARAMETER
;
1024 ret
= AllocateAndGetIpForwardTableFromStack(&table
, bOrder
, GetProcessHeap(), 0);
1026 DWORD size
= FIELD_OFFSET( MIB_IPFORWARDTABLE
, table
[table
->dwNumEntries
] );
1027 if (!pIpForwardTable
|| *pdwSize
< size
) {
1029 ret
= ERROR_INSUFFICIENT_BUFFER
;
1033 memcpy(pIpForwardTable
, table
, size
);
1035 HeapFree(GetProcessHeap(), 0, table
);
1037 TRACE("returning %d\n", ret
);
1042 /******************************************************************
1043 * GetIpNetTable (IPHLPAPI.@)
1045 * Get the IP-to-physical address mapping table.
1048 * pIpNetTable [Out] buffer for mapping table
1049 * pdwSize [In/Out] length of output buffer
1050 * bOrder [In] whether to sort the table
1054 * Failure: error code from winerror.h
1057 * If pdwSize is less than required, the function will return
1058 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
1060 * If bOrder is true, the returned table will be sorted by IP address.
1062 DWORD WINAPI
GetIpNetTable(PMIB_IPNETTABLE pIpNetTable
, PULONG pdwSize
, BOOL bOrder
)
1065 PMIB_IPNETTABLE table
;
1067 TRACE("pIpNetTable %p, pdwSize %p, bOrder %d\n", pIpNetTable
, pdwSize
, bOrder
);
1069 if (!pdwSize
) return ERROR_INVALID_PARAMETER
;
1071 ret
= AllocateAndGetIpNetTableFromStack( &table
, bOrder
, GetProcessHeap(), 0 );
1073 DWORD size
= FIELD_OFFSET( MIB_IPNETTABLE
, table
[table
->dwNumEntries
] );
1074 if (!pIpNetTable
|| *pdwSize
< size
) {
1076 ret
= ERROR_INSUFFICIENT_BUFFER
;
1080 memcpy(pIpNetTable
, table
, size
);
1082 HeapFree(GetProcessHeap(), 0, table
);
1084 TRACE("returning %d\n", ret
);
1089 /******************************************************************
1090 * GetNetworkParams (IPHLPAPI.@)
1092 * Get the network parameters for the local computer.
1095 * pFixedInfo [Out] buffer for network parameters
1096 * pOutBufLen [In/Out] length of output buffer
1100 * Failure: error code from winerror.h
1103 * If pOutBufLen is less than required, the function will return
1104 * ERROR_INSUFFICIENT_BUFFER, and pOutBufLen will be set to the required byte
1107 DWORD WINAPI
GetNetworkParams(PFIXED_INFO pFixedInfo
, PULONG pOutBufLen
)
1113 TRACE("pFixedInfo %p, pOutBufLen %p\n", pFixedInfo
, pOutBufLen
);
1115 return ERROR_INVALID_PARAMETER
;
1117 initialise_resolver();
1118 size
= sizeof(FIXED_INFO
) + (_res
.nscount
> 0 ? (_res
.nscount
- 1) *
1119 sizeof(IP_ADDR_STRING
) : 0);
1120 if (!pFixedInfo
|| *pOutBufLen
< size
) {
1122 return ERROR_BUFFER_OVERFLOW
;
1125 memset(pFixedInfo
, 0, size
);
1126 size
= sizeof(pFixedInfo
->HostName
);
1127 GetComputerNameExA(ComputerNameDnsHostname
, pFixedInfo
->HostName
, &size
);
1128 size
= sizeof(pFixedInfo
->DomainName
);
1129 GetComputerNameExA(ComputerNameDnsDomain
, pFixedInfo
->DomainName
, &size
);
1130 if (_res
.nscount
> 0) {
1131 PIP_ADDR_STRING ptr
;
1134 for (i
= 0, ptr
= &pFixedInfo
->DnsServerList
; i
< _res
.nscount
&& ptr
;
1135 i
++, ptr
= ptr
->Next
) {
1136 toIPAddressString(_res
.nsaddr_list
[i
].sin_addr
.s_addr
,
1137 ptr
->IpAddress
.String
);
1138 if (i
== _res
.nscount
- 1)
1141 ptr
->Next
= (PIP_ADDR_STRING
)((LPBYTE
)pFixedInfo
+ sizeof(FIXED_INFO
));
1143 ptr
->Next
= (PIP_ADDR_STRING
)((PBYTE
)ptr
+ sizeof(IP_ADDR_STRING
));
1146 pFixedInfo
->NodeType
= HYBRID_NODETYPE
;
1147 regReturn
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
1148 "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", 0, KEY_READ
, &hKey
);
1149 if (regReturn
!= ERROR_SUCCESS
)
1150 regReturn
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
1151 "SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ
,
1153 if (regReturn
== ERROR_SUCCESS
)
1155 DWORD size
= sizeof(pFixedInfo
->ScopeId
);
1157 RegQueryValueExA(hKey
, "ScopeID", NULL
, NULL
, (LPBYTE
)pFixedInfo
->ScopeId
, &size
);
1161 /* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
1162 I suppose could also check for a listener on port 53 to set EnableDns */
1164 TRACE("returning %d\n", ret
);
1169 /******************************************************************
1170 * GetNumberOfInterfaces (IPHLPAPI.@)
1172 * Get the number of interfaces.
1175 * pdwNumIf [Out] number of interfaces
1178 * NO_ERROR on success, ERROR_INVALID_PARAMETER if pdwNumIf is NULL.
1180 DWORD WINAPI
GetNumberOfInterfaces(PDWORD pdwNumIf
)
1184 TRACE("pdwNumIf %p\n", pdwNumIf
);
1186 ret
= ERROR_INVALID_PARAMETER
;
1188 *pdwNumIf
= getNumInterfaces();
1191 TRACE("returning %d\n", ret
);
1196 /******************************************************************
1197 * GetPerAdapterInfo (IPHLPAPI.@)
1199 * Get information about an adapter corresponding to an interface.
1202 * IfIndex [In] interface info
1203 * pPerAdapterInfo [Out] buffer for per adapter info
1204 * pOutBufLen [In/Out] length of output buffer
1208 * Failure: error code from winerror.h
1211 * Stub, returns empty IP_PER_ADAPTER_INFO in every case.
1213 DWORD WINAPI
GetPerAdapterInfo(ULONG IfIndex
, PIP_PER_ADAPTER_INFO pPerAdapterInfo
, PULONG pOutBufLen
)
1215 ULONG bytesNeeded
= sizeof(IP_PER_ADAPTER_INFO
);
1217 TRACE("(IfIndex %d, pPerAdapterInfo %p, pOutBufLen %p)\n", IfIndex
, pPerAdapterInfo
, pOutBufLen
);
1219 if (!pOutBufLen
) return ERROR_INVALID_PARAMETER
;
1221 if (!pPerAdapterInfo
|| *pOutBufLen
< bytesNeeded
)
1223 *pOutBufLen
= bytesNeeded
;
1224 return ERROR_BUFFER_OVERFLOW
;
1227 memset(pPerAdapterInfo
, 0, bytesNeeded
);
1232 /******************************************************************
1233 * GetRTTAndHopCount (IPHLPAPI.@)
1235 * Get round-trip time (RTT) and hop count.
1239 * DestIpAddress [In] destination address to get the info for
1240 * HopCount [Out] retrieved hop count
1241 * MaxHops [In] maximum hops to search for the destination
1242 * RTT [Out] RTT in milliseconds
1249 * Stub, returns FALSE.
1251 BOOL WINAPI
GetRTTAndHopCount(IPAddr DestIpAddress
, PULONG HopCount
, ULONG MaxHops
, PULONG RTT
)
1253 FIXME("(DestIpAddress 0x%08x, HopCount %p, MaxHops %d, RTT %p): stub\n",
1254 DestIpAddress
, HopCount
, MaxHops
, RTT
);
1259 /******************************************************************
1260 * GetTcpTable (IPHLPAPI.@)
1262 * Get the table of active TCP connections.
1265 * pTcpTable [Out] buffer for TCP connections table
1266 * pdwSize [In/Out] length of output buffer
1267 * bOrder [In] whether to order the table
1271 * Failure: error code from winerror.h
1274 * If pdwSize is less than required, the function will return
1275 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to
1276 * the required byte size.
1277 * If bOrder is true, the returned table will be sorted, first by
1278 * local address and port number, then by remote address and port
1281 DWORD WINAPI
GetTcpTable(PMIB_TCPTABLE pTcpTable
, PDWORD pdwSize
, BOOL bOrder
)
1284 PMIB_TCPTABLE table
;
1286 TRACE("pTcpTable %p, pdwSize %p, bOrder %d\n", pTcpTable
, pdwSize
, bOrder
);
1288 if (!pdwSize
) return ERROR_INVALID_PARAMETER
;
1290 ret
= AllocateAndGetTcpTableFromStack(&table
, bOrder
, GetProcessHeap(), 0);
1292 DWORD size
= FIELD_OFFSET( MIB_TCPTABLE
, table
[table
->dwNumEntries
] );
1293 if (!pTcpTable
|| *pdwSize
< size
) {
1295 ret
= ERROR_INSUFFICIENT_BUFFER
;
1299 memcpy(pTcpTable
, table
, size
);
1301 HeapFree(GetProcessHeap(), 0, table
);
1303 TRACE("returning %d\n", ret
);
1308 /******************************************************************
1309 * GetUdpTable (IPHLPAPI.@)
1311 * Get a table of active UDP connections.
1314 * pUdpTable [Out] buffer for UDP connections table
1315 * pdwSize [In/Out] length of output buffer
1316 * bOrder [In] whether to order the table
1320 * Failure: error code from winerror.h
1323 * If pdwSize is less than required, the function will return
1324 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the
1325 * required byte size.
1326 * If bOrder is true, the returned table will be sorted, first by
1327 * local address, then by local port number.
1329 DWORD WINAPI
GetUdpTable(PMIB_UDPTABLE pUdpTable
, PDWORD pdwSize
, BOOL bOrder
)
1332 PMIB_UDPTABLE table
;
1334 TRACE("pUdpTable %p, pdwSize %p, bOrder %d\n", pUdpTable
, pdwSize
, bOrder
);
1336 if (!pdwSize
) return ERROR_INVALID_PARAMETER
;
1338 ret
= AllocateAndGetUdpTableFromStack( &table
, bOrder
, GetProcessHeap(), 0 );
1340 DWORD size
= FIELD_OFFSET( MIB_UDPTABLE
, table
[table
->dwNumEntries
] );
1341 if (!pUdpTable
|| *pdwSize
< size
) {
1343 ret
= ERROR_INSUFFICIENT_BUFFER
;
1347 memcpy(pUdpTable
, table
, size
);
1349 HeapFree(GetProcessHeap(), 0, table
);
1351 TRACE("returning %d\n", ret
);
1356 /******************************************************************
1357 * GetUniDirectionalAdapterInfo (IPHLPAPI.@)
1359 * This is a Win98-only function to get information on "unidirectional"
1360 * adapters. Since this is pretty nonsensical in other contexts, it
1361 * never returns anything.
1364 * pIPIfInfo [Out] buffer for adapter infos
1365 * dwOutBufLen [Out] length of the output buffer
1369 * Failure: error code from winerror.h
1372 * Stub, returns ERROR_NOT_SUPPORTED.
1374 DWORD WINAPI
GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo
, PULONG dwOutBufLen
)
1376 TRACE("pIPIfInfo %p, dwOutBufLen %p\n", pIPIfInfo
, dwOutBufLen
);
1377 /* a unidirectional adapter?? not bloody likely! */
1378 return ERROR_NOT_SUPPORTED
;
1382 /******************************************************************
1383 * IpReleaseAddress (IPHLPAPI.@)
1385 * Release an IP obtained through DHCP,
1388 * AdapterInfo [In] adapter to release IP address
1392 * Failure: error code from winerror.h
1395 * Since GetAdaptersInfo never returns adapters that have DHCP enabled,
1396 * this function does nothing.
1399 * Stub, returns ERROR_NOT_SUPPORTED.
1401 DWORD WINAPI
IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo
)
1403 TRACE("AdapterInfo %p\n", AdapterInfo
);
1404 /* not a stub, never going to support this (and I never mark an adapter as
1405 DHCP enabled, see GetAdaptersInfo, so this should never get called) */
1406 return ERROR_NOT_SUPPORTED
;
1410 /******************************************************************
1411 * IpRenewAddress (IPHLPAPI.@)
1413 * Renew an IP obtained through DHCP.
1416 * AdapterInfo [In] adapter to renew IP address
1420 * Failure: error code from winerror.h
1423 * Since GetAdaptersInfo never returns adapters that have DHCP enabled,
1424 * this function does nothing.
1427 * Stub, returns ERROR_NOT_SUPPORTED.
1429 DWORD WINAPI
IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo
)
1431 TRACE("AdapterInfo %p\n", AdapterInfo
);
1432 /* not a stub, never going to support this (and I never mark an adapter as
1433 DHCP enabled, see GetAdaptersInfo, so this should never get called) */
1434 return ERROR_NOT_SUPPORTED
;
1438 /******************************************************************
1439 * NotifyAddrChange (IPHLPAPI.@)
1441 * Notify caller whenever the ip-interface map is changed.
1444 * Handle [Out] handle usable in asynchronous notification
1445 * overlapped [In] overlapped structure that notifies the caller
1449 * Failure: error code from winerror.h
1452 * Stub, returns ERROR_NOT_SUPPORTED.
1454 DWORD WINAPI
NotifyAddrChange(PHANDLE Handle
, LPOVERLAPPED overlapped
)
1456 FIXME("(Handle %p, overlapped %p): stub\n", Handle
, overlapped
);
1457 return ERROR_NOT_SUPPORTED
;
1461 /******************************************************************
1462 * NotifyRouteChange (IPHLPAPI.@)
1464 * Notify caller whenever the ip routing table is changed.
1467 * Handle [Out] handle usable in asynchronous notification
1468 * overlapped [In] overlapped structure that notifies the caller
1472 * Failure: error code from winerror.h
1475 * Stub, returns ERROR_NOT_SUPPORTED.
1477 DWORD WINAPI
NotifyRouteChange(PHANDLE Handle
, LPOVERLAPPED overlapped
)
1479 FIXME("(Handle %p, overlapped %p): stub\n", Handle
, overlapped
);
1480 return ERROR_NOT_SUPPORTED
;
1484 /******************************************************************
1485 * SendARP (IPHLPAPI.@)
1487 * Send an ARP request.
1490 * DestIP [In] attempt to obtain this IP
1491 * SrcIP [In] optional sender IP address
1492 * pMacAddr [Out] buffer for the mac address
1493 * PhyAddrLen [In/Out] length of the output buffer
1497 * Failure: error code from winerror.h
1500 * Stub, returns ERROR_NOT_SUPPORTED.
1502 DWORD WINAPI
SendARP(IPAddr DestIP
, IPAddr SrcIP
, PULONG pMacAddr
, PULONG PhyAddrLen
)
1504 FIXME("(DestIP 0x%08x, SrcIP 0x%08x, pMacAddr %p, PhyAddrLen %p): stub\n",
1505 DestIP
, SrcIP
, pMacAddr
, PhyAddrLen
);
1506 return ERROR_NOT_SUPPORTED
;
1510 /******************************************************************
1511 * SetIfEntry (IPHLPAPI.@)
1513 * Set the administrative status of an interface.
1516 * pIfRow [In] dwAdminStatus member specifies the new status.
1520 * Failure: error code from winerror.h
1523 * Stub, returns ERROR_NOT_SUPPORTED.
1525 DWORD WINAPI
SetIfEntry(PMIB_IFROW pIfRow
)
1527 FIXME("(pIfRow %p): stub\n", pIfRow
);
1528 /* this is supposed to set an interface administratively up or down.
1529 Could do SIOCSIFFLAGS and set/clear IFF_UP, but, not sure I want to, and
1530 this sort of down is indistinguishable from other sorts of down (e.g. no
1532 return ERROR_NOT_SUPPORTED
;
1536 /******************************************************************
1537 * SetIpForwardEntry (IPHLPAPI.@)
1539 * Modify an existing route.
1542 * pRoute [In] route with the new information
1546 * Failure: error code from winerror.h
1549 * Stub, returns NO_ERROR.
1551 DWORD WINAPI
SetIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
1553 FIXME("(pRoute %p): stub\n", pRoute
);
1554 /* this is to add a route entry, how's it distinguishable from
1555 CreateIpForwardEntry?
1556 could use SIOCADDRT, not sure I want to */
1561 /******************************************************************
1562 * SetIpNetEntry (IPHLPAPI.@)
1564 * Modify an existing ARP entry.
1567 * pArpEntry [In] ARP entry with the new information
1571 * Failure: error code from winerror.h
1574 * Stub, returns NO_ERROR.
1576 DWORD WINAPI
SetIpNetEntry(PMIB_IPNETROW pArpEntry
)
1578 FIXME("(pArpEntry %p): stub\n", pArpEntry
);
1579 /* same as CreateIpNetEntry here, could use SIOCSARP, not sure I want to */
1584 /******************************************************************
1585 * SetIpStatistics (IPHLPAPI.@)
1587 * Toggle IP forwarding and det the default TTL value.
1590 * pIpStats [In] IP statistics with the new information
1594 * Failure: error code from winerror.h
1597 * Stub, returns NO_ERROR.
1599 DWORD WINAPI
SetIpStatistics(PMIB_IPSTATS pIpStats
)
1601 FIXME("(pIpStats %p): stub\n", pIpStats
);
1606 /******************************************************************
1607 * SetIpTTL (IPHLPAPI.@)
1609 * Set the default TTL value.
1612 * nTTL [In] new TTL value
1616 * Failure: error code from winerror.h
1619 * Stub, returns NO_ERROR.
1621 DWORD WINAPI
SetIpTTL(UINT nTTL
)
1623 FIXME("(nTTL %d): stub\n", nTTL
);
1624 /* could echo nTTL > /proc/net/sys/net/ipv4/ip_default_ttl, not sure I
1625 want to. Could map EACCESS to ERROR_ACCESS_DENIED, I suppose */
1630 /******************************************************************
1631 * SetTcpEntry (IPHLPAPI.@)
1633 * Set the state of a TCP connection.
1636 * pTcpRow [In] specifies connection with new state
1640 * Failure: error code from winerror.h
1643 * Stub, returns NO_ERROR.
1645 DWORD WINAPI
SetTcpEntry(PMIB_TCPROW pTcpRow
)
1647 FIXME("(pTcpRow %p): stub\n", pTcpRow
);
1652 /******************************************************************
1653 * UnenableRouter (IPHLPAPI.@)
1655 * Decrement the IP-forwarding reference count. Turn off IP-forwarding
1656 * if it reaches zero.
1659 * pOverlapped [In/Out] should be the same as in EnableRouter()
1660 * lpdwEnableCount [Out] optional, receives reference count
1664 * Failure: error code from winerror.h
1667 * Stub, returns ERROR_NOT_SUPPORTED.
1669 DWORD WINAPI
UnenableRouter(OVERLAPPED
* pOverlapped
, LPDWORD lpdwEnableCount
)
1671 FIXME("(pOverlapped %p, lpdwEnableCount %p): stub\n", pOverlapped
,
1673 /* could echo "0" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
1674 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
1676 return ERROR_NOT_SUPPORTED
;