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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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>
45 #include "wine/debug.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
50 #define INADDR_NONE ~0UL
53 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
56 case DLL_PROCESS_ATTACH:
57 DisableThreadLibraryCalls( hinstDLL );
61 case DLL_PROCESS_DETACH:
68 /******************************************************************
69 * AddIPAddress (IPHLPAPI.@)
80 * NTEInstance [In/Out]
86 DWORD WINAPI AddIPAddress(IPAddr Address, IPMask IpMask, DWORD IfIndex, PULONG NTEContext, PULONG NTEInstance)
89 /* marking Win2K+ functions not supported */
90 return ERROR_NOT_SUPPORTED;
94 /******************************************************************
95 * AllocateAndGetIfTableFromStack (IPHLPAPI.@)
98 * Like GetIfTable, but allocates the returned table from heap.
102 * ppIfTable [Out] -- pointer into which the MIB_IFTABLE is
103 * allocated and returned.
104 * bOrder [In] -- passed to GetIfTable to order the table
105 * heap [In] -- heap from which the table is allocated
106 * flags [In] -- flags to HeapAlloc
108 * RETURNS -- ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
109 * GetIfTable returns otherwise
112 DWORD WINAPI AllocateAndGetIfTableFromStack(PMIB_IFTABLE *ppIfTable,
113 BOOL bOrder, HANDLE heap, DWORD flags)
117 TRACE("ppIfTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n", ppIfTable,
118 (DWORD)bOrder, (DWORD)heap, flags);
120 ret = ERROR_INVALID_PARAMETER;
124 ret = GetIfTable(*ppIfTable, &dwSize, bOrder);
125 if (ret == ERROR_INSUFFICIENT_BUFFER) {
126 *ppIfTable = HeapAlloc(heap, flags, dwSize);
127 ret = GetIfTable(*ppIfTable, &dwSize, bOrder);
130 TRACE("returning %ld\n", ret);
135 /******************************************************************
136 * AllocateAndGetIpAddrTableFromStack (IPHLPAPI.@)
139 * Like GetIpAddrTable, but allocates the returned table from heap.
143 * ppIpAddrTable [Out]
144 * bOrder [In] -- passed to GetIpAddrTable to order the table
145 * heap [In] -- heap from which the table is allocated
146 * flags [In] -- flags to HeapAlloc
149 * ERROR_INVALID_PARAMETER if ppIpAddrTable is NULL, whatever GetIpAddrTable
153 DWORD WINAPI AllocateAndGetIpAddrTableFromStack(PMIB_IPADDRTABLE *ppIpAddrTable,
154 BOOL bOrder, HANDLE heap, DWORD flags)
158 TRACE("ppIpAddrTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
159 ppIpAddrTable, (DWORD)bOrder, (DWORD)heap, flags);
161 ret = ERROR_INVALID_PARAMETER;
165 ret = GetIpAddrTable(*ppIpAddrTable, &dwSize, bOrder);
166 if (ret == ERROR_INSUFFICIENT_BUFFER) {
167 *ppIpAddrTable = HeapAlloc(heap, flags, dwSize);
168 ret = GetIpAddrTable(*ppIpAddrTable, &dwSize, bOrder);
171 TRACE("returning %ld\n", ret);
176 /******************************************************************
177 * AllocateAndGetIpForwardTableFromStack (IPHLPAPI.@)
180 * Like GetIpForwardTable, but allocates the returned table from heap.
184 * ppIpForwardTable [Out] -- pointer into which the MIB_IPFORWARDTABLE is
185 * allocated and returned.
186 * bOrder [In] -- passed to GetIfTable to order the table
187 * heap [In] -- heap from which the table is allocated
188 * flags [In] -- flags to HeapAlloc
190 * RETURNS -- ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
191 * GetIpForwardTable returns otherwise
194 DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *
195 ppIpForwardTable, BOOL bOrder, HANDLE heap, DWORD flags)
199 TRACE("ppIpForwardTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
200 ppIpForwardTable, (DWORD)bOrder, (DWORD)heap, flags);
201 if (!ppIpForwardTable)
202 ret = ERROR_INVALID_PARAMETER;
206 ret = GetIpForwardTable(*ppIpForwardTable, &dwSize, bOrder);
207 if (ret == ERROR_INSUFFICIENT_BUFFER) {
208 *ppIpForwardTable = HeapAlloc(heap, flags, dwSize);
209 ret = GetIpForwardTable(*ppIpForwardTable, &dwSize, bOrder);
212 TRACE("returning %ld\n", ret);
217 /******************************************************************
218 * AllocateAndGetIpNetTableFromStack (IPHLPAPI.@)
221 * Like GetIpNetTable, but allocates the returned table from heap.
226 * bOrder [In] -- passed to GetIpNetTable to order the table
227 * heap [In] -- heap from which the table is allocated
228 * flags [In] -- flags to HeapAlloc
231 * ERROR_INVALID_PARAMETER if ppIpNetTable is NULL, whatever GetIpNetTable
235 DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable,
236 BOOL bOrder, HANDLE heap, DWORD flags)
240 TRACE("ppIpNetTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
241 ppIpNetTable, (DWORD)bOrder, (DWORD)heap, flags);
243 ret = ERROR_INVALID_PARAMETER;
247 ret = GetIpNetTable(*ppIpNetTable, &dwSize, bOrder);
248 if (ret == ERROR_INSUFFICIENT_BUFFER) {
249 *ppIpNetTable = HeapAlloc(heap, flags, dwSize);
250 ret = GetIpNetTable(*ppIpNetTable, &dwSize, bOrder);
253 TRACE("returning %ld\n", ret);
258 /******************************************************************
259 * AllocateAndGetTcpTableFromStack (IPHLPAPI.@)
262 * Like GetTcpTable, but allocates the returned table from heap.
267 * bOrder [In] -- passed to GetTcpTable to order the table
268 * heap [In] -- heap from which the table is allocated
269 * flags [In] -- flags to HeapAlloc
272 * ERROR_INVALID_PARAMETER if ppTcpTable is NULL, whatever GetTcpTable
276 DWORD WINAPI AllocateAndGetTcpTableFromStack(PMIB_TCPTABLE *ppTcpTable,
277 BOOL bOrder, HANDLE heap, DWORD flags)
281 TRACE("ppTcpTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
282 ppTcpTable, (DWORD)bOrder, (DWORD)heap, flags);
284 ret = ERROR_INVALID_PARAMETER;
288 ret = GetTcpTable(*ppTcpTable, &dwSize, bOrder);
289 if (ret == ERROR_INSUFFICIENT_BUFFER) {
290 *ppTcpTable = HeapAlloc(heap, flags, dwSize);
291 ret = GetTcpTable(*ppTcpTable, &dwSize, bOrder);
294 TRACE("returning %ld\n", ret);
299 /******************************************************************
300 * AllocateAndGetUdpTableFromStack (IPHLPAPI.@)
303 * Like GetUdpTable, but allocates the returned table from heap.
308 * bOrder [In] -- passed to GetUdpTable to order the table
309 * heap [In] -- heap from which the table is allocated
310 * flags [In] -- flags to HeapAlloc
313 * ERROR_INVALID_PARAMETER if ppUdpTable is NULL, whatever GetUdpTable
317 DWORD WINAPI AllocateAndGetUdpTableFromStack(PMIB_UDPTABLE *ppUdpTable,
318 BOOL bOrder, HANDLE heap, DWORD flags)
322 TRACE("ppUdpTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
323 ppUdpTable, (DWORD)bOrder, (DWORD)heap, flags);
325 ret = ERROR_INVALID_PARAMETER;
329 ret = GetUdpTable(*ppUdpTable, &dwSize, bOrder);
330 if (ret == ERROR_INSUFFICIENT_BUFFER) {
331 *ppUdpTable = HeapAlloc(heap, flags, dwSize);
332 ret = GetUdpTable(*ppUdpTable, &dwSize, bOrder);
335 TRACE("returning %ld\n", ret);
340 /******************************************************************
341 * CreateIpForwardEntry (IPHLPAPI.@)
354 DWORD WINAPI CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute)
356 FIXME("(pRoute %p): stub\n", pRoute);
357 /* could use SIOCADDRT, not sure I want to */
362 /******************************************************************
363 * CreateIpNetEntry (IPHLPAPI.@)
376 DWORD WINAPI CreateIpNetEntry(PMIB_IPNETROW pArpEntry)
378 FIXME("(pArpEntry %p)\n", pArpEntry);
379 /* could use SIOCSARP on systems that support it, not sure I want to */
384 /******************************************************************
385 * CreateProxyArpEntry (IPHLPAPI.@)
397 * ERROR_NOT_SUPPORTED
400 DWORD WINAPI CreateProxyArpEntry(DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
402 FIXME("(dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx): stub\n",
403 dwAddress, dwMask, dwIfIndex);
404 /* marking Win2K+ functions not supported */
405 return ERROR_NOT_SUPPORTED;
409 /******************************************************************
410 * DeleteIPAddress (IPHLPAPI.@)
420 * ERROR_NOT_SUPPORTED
423 DWORD WINAPI DeleteIPAddress(ULONG NTEContext)
425 FIXME("(NTEContext %ld): stub\n", NTEContext);
426 /* marking Win2K+ functions not supported */
427 return ERROR_NOT_SUPPORTED;
431 /******************************************************************
432 * DeleteIpForwardEntry (IPHLPAPI.@)
445 DWORD WINAPI DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute)
447 FIXME("(pRoute %p): stub\n", pRoute);
448 /* could use SIOCDELRT, not sure I want to */
453 /******************************************************************
454 * DeleteIpNetEntry (IPHLPAPI.@)
467 DWORD WINAPI DeleteIpNetEntry(PMIB_IPNETROW pArpEntry)
469 FIXME("(pArpEntry %p): stub\n", pArpEntry);
470 /* could use SIOCDARP on systems that support it, not sure I want to */
475 /******************************************************************
476 * DeleteProxyArpEntry (IPHLPAPI.@)
488 * ERROR_NOT_SUPPORTED
491 DWORD WINAPI DeleteProxyArpEntry(DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
493 FIXME("(dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx): stub\n",
494 dwAddress, dwMask, dwIfIndex);
495 /* marking Win2K+ functions not supported */
496 return ERROR_NOT_SUPPORTED;
500 /******************************************************************
501 * EnableRouter (IPHLPAPI.@)
509 * pOverlapped [In/Out]
512 * ERROR_NOT_SUPPORTED
515 DWORD WINAPI EnableRouter(HANDLE * pHandle, OVERLAPPED * pOverlapped)
517 FIXME("(pHandle %p, pOverlapped %p): stub\n", pHandle, pOverlapped);
518 /* could echo "1" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
519 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
520 marking Win2K+ functions not supported */
521 return ERROR_NOT_SUPPORTED;
525 /******************************************************************
526 * FlushIpNetTable (IPHLPAPI.@)
536 * ERROR_NOT_SUPPORTED
539 DWORD WINAPI FlushIpNetTable(DWORD dwIfIndex)
541 FIXME("(dwIfIndex 0x%08lx): stub\n", dwIfIndex);
542 /* this flushes the arp cache of the given index
543 marking Win2K+ functions not supported */
544 return ERROR_NOT_SUPPORTED;
548 /******************************************************************
549 * GetAdapterIndex (IPHLPAPI.@)
556 * AdapterName [In/Out]
560 * ERROR_NOT_SUPPORTED
563 DWORD WINAPI GetAdapterIndex(LPWSTR AdapterName, PULONG IfIndex)
565 FIXME("(AdapterName %p, IfIndex %p): stub\n", AdapterName, IfIndex);
566 /* marking Win2K+ functions not supported */
567 return ERROR_NOT_SUPPORTED;
571 /******************************************************************
572 * GetAdaptersInfo (IPHLPAPI.@)
576 * pAdapterInfo [In/Out]
577 * pOutBufLen [In/Out]
584 DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
588 TRACE("pAdapterInfo %p, pOutBufLen %p\n", pAdapterInfo, pOutBufLen);
590 ret = ERROR_INVALID_PARAMETER;
592 DWORD numNonLoopbackInterfaces = getNumNonLoopbackInterfaces();
594 if (numNonLoopbackInterfaces > 0) {
595 /* this calculation assumes only one address in the IP_ADDR_STRING lists.
596 that's okay, because:
597 - we don't get multiple addresses per adapter anyway
598 - we don't know about per-adapter gateways
599 - DHCP and WINS servers can have max one entry per list */
600 ULONG size = sizeof(IP_ADAPTER_INFO) * numNonLoopbackInterfaces;
602 if (!pAdapterInfo || *pOutBufLen < size) {
604 ret = ERROR_BUFFER_OVERFLOW;
607 InterfaceIndexTable *table = getNonLoopbackInterfaceIndexTable();
610 size = sizeof(IP_ADAPTER_INFO) * table->numIndexes;
611 if (*pOutBufLen < size) {
613 ret = ERROR_INSUFFICIENT_BUFFER;
618 BOOL winsEnabled = FALSE;
619 IP_ADDRESS_STRING primaryWINS, secondaryWINS;
621 memset(pAdapterInfo, 0, size);
622 /* @@ Wine registry key: HKCU\Software\Wine\Network */
623 if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Network", &hKey) == ERROR_SUCCESS) {
624 DWORD size = sizeof(primaryWINS.String);
627 RegQueryValueExA(hKey, "WinsServer", NULL, NULL,
628 primaryWINS.String, &size);
629 addr = inet_addr(primaryWINS.String);
630 if (addr != INADDR_NONE && addr != INADDR_ANY)
632 size = sizeof(secondaryWINS.String);
633 RegQueryValueExA(hKey, "BackupWinsServer", NULL, NULL,
634 secondaryWINS.String, &size);
635 addr = inet_addr(secondaryWINS.String);
636 if (addr != INADDR_NONE && addr != INADDR_ANY)
640 for (ndx = 0; ndx < table->numIndexes; ndx++) {
641 PIP_ADAPTER_INFO ptr = &pAdapterInfo[ndx];
642 DWORD addrLen = sizeof(ptr->Address), type;
644 /* on Win98 this is left empty, but whatever */
645 lstrcpynA(ptr->AdapterName,
646 getInterfaceNameByIndex(table->indexes[ndx]),
647 MAX_ADAPTER_NAME_LENGTH+1);
648 getInterfacePhysicalByIndex(table->indexes[ndx], &addrLen,
649 ptr->Address, &type);
650 /* MS defines address length and type as UINT in some places and
651 DWORD in others, **sigh**. Don't want to assume that PUINT and
652 PDWORD are equiv (64-bit?) */
653 ptr->AddressLength = addrLen;
655 ptr->Index = table->indexes[ndx];
656 toIPAddressString(getInterfaceIPAddrByIndex(table->indexes[ndx]),
657 ptr->IpAddressList.IpAddress.String);
658 toIPAddressString(getInterfaceMaskByIndex(table->indexes[ndx]),
659 ptr->IpAddressList.IpMask.String);
661 ptr->HaveWins = TRUE;
662 memcpy(ptr->PrimaryWinsServer.IpAddress.String,
663 primaryWINS.String, sizeof(primaryWINS.String));
664 memcpy(ptr->SecondaryWinsServer.IpAddress.String,
665 secondaryWINS.String, sizeof(secondaryWINS.String));
667 if (ndx < table->numIndexes - 1)
668 ptr->Next = &pAdapterInfo[ndx + 1];
674 HeapFree(GetProcessHeap(), 0, table);
677 ret = ERROR_OUTOFMEMORY;
683 TRACE("returning %ld\n", ret);
688 /******************************************************************
689 * GetBestInterface (IPHLPAPI.@)
694 * pdwBestIfIndex [In/Out]
701 DWORD WINAPI GetBestInterface(IPAddr dwDestAddr, PDWORD pdwBestIfIndex)
705 TRACE("dwDestAddr 0x%08lx, pdwBestIfIndex %p\n", dwDestAddr, pdwBestIfIndex);
707 ret = ERROR_INVALID_PARAMETER;
709 MIB_IPFORWARDROW ipRow;
711 ret = GetBestRoute(dwDestAddr, 0, &ipRow);
712 if (ret == ERROR_SUCCESS)
713 *pdwBestIfIndex = ipRow.dwForwardIfIndex;
715 TRACE("returning %ld\n", ret);
720 /******************************************************************
721 * GetBestRoute (IPHLPAPI.@)
734 DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDROW pBestRoute)
736 PMIB_IPFORWARDTABLE table;
739 TRACE("dwDestAddr 0x%08lx, dwSourceAddr 0x%08lx, pBestRoute %p\n", dwDestAddr,
740 dwSourceAddr, pBestRoute);
742 return ERROR_INVALID_PARAMETER;
744 AllocateAndGetIpForwardTableFromStack(&table, FALSE, GetProcessHeap(), 0);
746 DWORD ndx, matchedBits, matchedNdx = 0;
748 for (ndx = 0, matchedBits = 0; ndx < table->dwNumEntries; ndx++) {
749 if ((dwDestAddr & table->table[ndx].dwForwardMask) ==
750 (table->table[ndx].dwForwardDest & table->table[ndx].dwForwardMask)) {
751 DWORD numShifts, mask;
753 for (numShifts = 0, mask = table->table[ndx].dwForwardMask;
754 mask && !(mask & 1); mask >>= 1, numShifts++)
756 if (numShifts > matchedBits) {
757 matchedBits = numShifts;
762 memcpy(pBestRoute, &table->table[matchedNdx], sizeof(MIB_IPFORWARDROW));
763 HeapFree(GetProcessHeap(), 0, table);
767 ret = ERROR_OUTOFMEMORY;
768 TRACE("returning %ld\n", ret);
773 /******************************************************************
774 * GetFriendlyIfIndex (IPHLPAPI.@)
777 * Returns a "friendly" version if IfIndex, which is one that doesn't
778 * have the top byte set. Doesn't validate whether IfIndex is a valid
786 * A friendly version of IfIndex.
789 DWORD WINAPI GetFriendlyIfIndex(DWORD IfIndex)
791 /* windows doesn't validate these, either, just makes sure the top byte is
792 cleared. I assume my ifenum module never gives an index with the top
794 TRACE("returning %ld\n", IfIndex);
799 /******************************************************************
800 * GetIcmpStatistics (IPHLPAPI.@)
811 DWORD WINAPI GetIcmpStatistics(PMIB_ICMP pStats)
815 TRACE("pStats %p\n", pStats);
816 ret = getICMPStats(pStats);
817 TRACE("returning %ld\n", ret);
822 /******************************************************************
823 * GetIfEntry (IPHLPAPI.@)
834 DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
839 TRACE("pIfRow %p\n", pIfRow);
841 return ERROR_INVALID_PARAMETER;
843 name = getInterfaceNameByIndex(pIfRow->dwIndex);
845 ret = getInterfaceEntryByName(name, pIfRow);
847 ret = getInterfaceStatsByName(name, pIfRow);
850 ret = ERROR_INVALID_DATA;
851 TRACE("returning %ld\n", ret);
856 static int IfTableSorter(const void *a, const void *b)
861 ret = ((const MIB_IFROW*)a)->dwIndex - ((const MIB_IFROW*)b)->dwIndex;
868 /******************************************************************
869 * GetIfTable (IPHLPAPI.@)
872 * Returns a table of local interfaces, *pdwSize is the size in bytes of
873 * pIfTable. If this is less than required, the function will return
874 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
876 * If bOrder is true, the returned table will be sorted by interface index.
885 * NO_ERROR on success, something else on failure.
888 DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
892 TRACE("pIfTable %p, pdwSize %p, bOrder %ld\n", pdwSize, pdwSize,
895 ret = ERROR_INVALID_PARAMETER;
897 DWORD numInterfaces = getNumInterfaces();
898 ULONG size = sizeof(MIB_IFTABLE) + (numInterfaces - 1) * sizeof(MIB_IFROW);
900 if (!pIfTable || *pdwSize < size) {
902 ret = ERROR_INSUFFICIENT_BUFFER;
905 InterfaceIndexTable *table = getInterfaceIndexTable();
908 size = sizeof(MIB_IFTABLE) + (table->numIndexes - 1) *
910 if (*pdwSize < size) {
912 ret = ERROR_INSUFFICIENT_BUFFER;
917 pIfTable->dwNumEntries = 0;
918 for (ndx = 0; ndx < table->numIndexes; ndx++) {
919 pIfTable->table[ndx].dwIndex = table->indexes[ndx];
920 GetIfEntry(&pIfTable->table[ndx]);
921 pIfTable->dwNumEntries++;
924 qsort(pIfTable->table, pIfTable->dwNumEntries, sizeof(MIB_IFROW),
928 HeapFree(GetProcessHeap(), 0, table);
931 ret = ERROR_OUTOFMEMORY;
934 TRACE("returning %ld\n", ret);
939 /******************************************************************
940 * GetInterfaceInfo (IPHLPAPI.@)
945 * dwOutBufLen [In/Out]
952 DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
956 TRACE("pIfTable %p, dwOutBufLen %p\n", pIfTable, dwOutBufLen);
958 ret = ERROR_INVALID_PARAMETER;
960 DWORD numInterfaces = getNumInterfaces();
961 ULONG size = sizeof(IP_INTERFACE_INFO) + (numInterfaces - 1) *
962 sizeof(IP_ADAPTER_INDEX_MAP);
964 if (!pIfTable || *dwOutBufLen < size) {
966 ret = ERROR_INSUFFICIENT_BUFFER;
969 InterfaceIndexTable *table = getInterfaceIndexTable();
972 size = sizeof(IP_INTERFACE_INFO) + (table->numIndexes - 1) *
973 sizeof(IP_ADAPTER_INDEX_MAP);
974 if (*dwOutBufLen < size) {
976 ret = ERROR_INSUFFICIENT_BUFFER;
981 pIfTable->NumAdapters = 0;
982 for (ndx = 0; ndx < table->numIndexes; ndx++) {
983 const char *walker, *name;
986 pIfTable->Adapter[ndx].Index = table->indexes[ndx];
987 name = getInterfaceNameByIndex(table->indexes[ndx]);
988 for (walker = name, assigner = pIfTable->Adapter[ndx].Name;
990 assigner - pIfTable->Adapter[ndx].Name < MAX_ADAPTER_NAME - 1;
991 walker++, assigner++)
994 pIfTable->NumAdapters++;
998 HeapFree(GetProcessHeap(), 0, table);
1001 ret = ERROR_OUTOFMEMORY;
1004 TRACE("returning %ld\n", ret);
1009 static int IpAddrTableSorter(const void *a, const void *b)
1014 ret = ((const MIB_IPADDRROW*)a)->dwAddr - ((const MIB_IPADDRROW*)b)->dwAddr;
1021 /******************************************************************
1022 * GetIpAddrTable (IPHLPAPI.@)
1025 * Returns the route table. On input, *pdwSize is the size in bytes of
1026 * pIpForwardTable. If this is less than required, the function will return
1027 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
1029 * If bOrder is true, the returned table will be sorted by the next hop and
1030 * an assortment of arbitrary parameters.
1034 * pIpAddrTable [In/Out]
1039 * NO_ERROR on success, something else on failure.
1042 DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)
1046 TRACE("pIpAddrTable %p, pdwSize %p, bOrder %ld\n", pIpAddrTable, pdwSize,
1049 ret = ERROR_INVALID_PARAMETER;
1051 DWORD numInterfaces = getNumInterfaces();
1052 ULONG size = sizeof(MIB_IPADDRTABLE) + (numInterfaces - 1) *
1053 sizeof(MIB_IPADDRROW);
1055 if (!pIpAddrTable || *pdwSize < size) {
1057 ret = ERROR_INSUFFICIENT_BUFFER;
1060 InterfaceIndexTable *table = getInterfaceIndexTable();
1063 size = sizeof(MIB_IPADDRTABLE) + (table->numIndexes - 1) *
1064 sizeof(MIB_IPADDRROW);
1065 if (*pdwSize < size) {
1067 ret = ERROR_INSUFFICIENT_BUFFER;
1072 pIpAddrTable->dwNumEntries = 0;
1073 for (ndx = 0; ndx < table->numIndexes; ndx++) {
1074 pIpAddrTable->table[ndx].dwIndex = table->indexes[ndx];
1075 pIpAddrTable->table[ndx].dwAddr =
1076 getInterfaceIPAddrByIndex(table->indexes[ndx]);
1077 pIpAddrTable->table[ndx].dwMask =
1078 getInterfaceMaskByIndex(table->indexes[ndx]);
1079 /* the dwBCastAddr member isn't the broadcast address, it indicates
1080 * whether the interface uses the 1's broadcast address (1) or the
1081 * 0's broadcast address (0).
1083 bcast = getInterfaceBCastAddrByIndex(table->indexes[ndx]);
1084 pIpAddrTable->table[ndx].dwBCastAddr =
1085 (bcast & pIpAddrTable->table[ndx].dwMask) ? 1 : 0;
1086 /* FIXME: hardcoded reasm size, not sure where to get it */
1087 pIpAddrTable->table[ndx].dwReasmSize = 65535;
1088 pIpAddrTable->table[ndx].unused1 = 0;
1089 pIpAddrTable->table[ndx].wType = 0; /* aka unused2 */
1090 pIpAddrTable->dwNumEntries++;
1093 qsort(pIpAddrTable->table, pIpAddrTable->dwNumEntries,
1094 sizeof(MIB_IPADDRROW), IpAddrTableSorter);
1097 HeapFree(GetProcessHeap(), 0, table);
1100 ret = ERROR_OUTOFMEMORY;
1103 TRACE("returning %ld\n", ret);
1108 static int IpForwardTableSorter(const void *a, const void *b)
1113 const MIB_IPFORWARDROW* rowA = (const MIB_IPFORWARDROW*)a;
1114 const MIB_IPFORWARDROW* rowB = (const MIB_IPFORWARDROW*)b;
1116 ret = rowA->dwForwardDest - rowB->dwForwardDest;
1118 ret = rowA->dwForwardProto - rowB->dwForwardProto;
1120 ret = rowA->dwForwardPolicy - rowB->dwForwardPolicy;
1122 ret = rowA->dwForwardNextHop - rowB->dwForwardNextHop;
1132 /******************************************************************
1133 * GetIpForwardTable (IPHLPAPI.@)
1136 * Returns the route table. On input, *pdwSize is the size in bytes of
1137 * pIpForwardTable. If this is less than required, the function will return
1138 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
1140 * If bOrder is true, the returned table will be sorted by the next hop and
1141 * an assortment of arbitrary parameters.
1145 * pIpForwardTable [In/Out]
1150 * NO_ERROR on success, something else on failure.
1153 DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSize, BOOL bOrder)
1157 TRACE("pIpForwardTable %p, pdwSize %p, bOrder %ld\n", pIpForwardTable,
1158 pdwSize, (DWORD)bOrder);
1160 ret = ERROR_INVALID_PARAMETER;
1162 DWORD numRoutes = getNumRoutes();
1163 ULONG sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (numRoutes - 1) *
1164 sizeof(MIB_IPFORWARDROW);
1166 if (!pIpForwardTable || *pdwSize < sizeNeeded) {
1167 *pdwSize = sizeNeeded;
1168 ret = ERROR_INSUFFICIENT_BUFFER;
1171 RouteTable *table = getRouteTable();
1173 sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (table->numRoutes - 1) *
1174 sizeof(MIB_IPFORWARDROW);
1175 if (*pdwSize < sizeNeeded) {
1176 *pdwSize = sizeNeeded;
1177 ret = ERROR_INSUFFICIENT_BUFFER;
1182 pIpForwardTable->dwNumEntries = table->numRoutes;
1183 for (ndx = 0; ndx < numRoutes; ndx++) {
1184 pIpForwardTable->table[ndx].dwForwardIfIndex =
1185 table->routes[ndx].ifIndex;
1186 pIpForwardTable->table[ndx].dwForwardDest =
1187 table->routes[ndx].dest;
1188 pIpForwardTable->table[ndx].dwForwardMask =
1189 table->routes[ndx].mask;
1190 pIpForwardTable->table[ndx].dwForwardPolicy = 0;
1191 pIpForwardTable->table[ndx].dwForwardNextHop =
1192 table->routes[ndx].gateway;
1193 /* FIXME: this type is appropriate for local interfaces; may not
1194 always be appropriate */
1195 pIpForwardTable->table[ndx].dwForwardType = MIB_IPROUTE_TYPE_DIRECT;
1196 /* FIXME: other protos might be appropriate, e.g. the default route
1197 is typically set with MIB_IPPROTO_NETMGMT instead */
1198 pIpForwardTable->table[ndx].dwForwardProto = MIB_IPPROTO_LOCAL;
1199 /* punt on age and AS */
1200 pIpForwardTable->table[ndx].dwForwardAge = 0;
1201 pIpForwardTable->table[ndx].dwForwardNextHopAS = 0;
1202 pIpForwardTable->table[ndx].dwForwardMetric1 =
1203 table->routes[ndx].metric;
1204 /* rest of the metrics are 0.. */
1205 pIpForwardTable->table[ndx].dwForwardMetric2 = 0;
1206 pIpForwardTable->table[ndx].dwForwardMetric3 = 0;
1207 pIpForwardTable->table[ndx].dwForwardMetric4 = 0;
1208 pIpForwardTable->table[ndx].dwForwardMetric5 = 0;
1211 qsort(pIpForwardTable->table, pIpForwardTable->dwNumEntries,
1212 sizeof(MIB_IPFORWARDROW), IpForwardTableSorter);
1215 HeapFree(GetProcessHeap(), 0, table);
1218 ret = ERROR_OUTOFMEMORY;
1221 TRACE("returning %ld\n", ret);
1226 static int IpNetTableSorter(const void *a, const void *b)
1231 ret = ((const MIB_IPNETROW*)a)->dwAddr - ((const MIB_IPNETROW*)b)->dwAddr;
1238 /******************************************************************
1239 * GetIpNetTable (IPHLPAPI.@)
1241 * Returns the ARP cache. On input, *pdwSize is the size in bytes of
1242 * pIpNetTable. If this is less than required, the function will return
1243 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
1245 * If bOrder is true, the returned table will be sorted by IP address.
1249 * pIpNetTable [In/Out]
1254 * NO_ERROR on success, something else on failure.
1257 DWORD WINAPI GetIpNetTable(PMIB_IPNETTABLE pIpNetTable, PULONG pdwSize, BOOL bOrder)
1261 TRACE("pIpNetTable %p, pdwSize %p, bOrder %ld\n", pIpNetTable, pdwSize,
1264 ret = ERROR_INVALID_PARAMETER;
1266 DWORD numEntries = getNumArpEntries();
1267 ULONG size = sizeof(MIB_IPNETTABLE) + (numEntries - 1) *
1268 sizeof(MIB_IPNETROW);
1270 if (!pIpNetTable || *pdwSize < size) {
1272 ret = ERROR_INSUFFICIENT_BUFFER;
1275 PMIB_IPNETTABLE table = getArpTable();
1278 size = sizeof(MIB_IPNETTABLE) + (table->dwNumEntries - 1) *
1279 sizeof(MIB_IPNETROW);
1280 if (*pdwSize < size) {
1282 ret = ERROR_INSUFFICIENT_BUFFER;
1285 memcpy(pIpNetTable, table, size);
1287 qsort(pIpNetTable->table, pIpNetTable->dwNumEntries,
1288 sizeof(MIB_IPNETROW), IpNetTableSorter);
1291 HeapFree(GetProcessHeap(), 0, table);
1294 ret = ERROR_OUTOFMEMORY;
1297 TRACE("returning %ld\n", ret);
1302 /******************************************************************
1303 * GetIpStatistics (IPHLPAPI.@)
1314 DWORD WINAPI GetIpStatistics(PMIB_IPSTATS pStats)
1318 TRACE("pStats %p\n", pStats);
1319 ret = getIPStats(pStats);
1320 TRACE("returning %ld\n", ret);
1325 /******************************************************************
1326 * GetNetworkParams (IPHLPAPI.@)
1330 * pFixedInfo [In/Out]
1331 * pOutBufLen [In/Out]
1338 DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
1344 TRACE("pFixedInfo %p, pOutBufLen %p\n", pFixedInfo, pOutBufLen);
1346 return ERROR_INVALID_PARAMETER;
1349 size = sizeof(FIXED_INFO) + (_res.nscount > 0 ? (_res.nscount - 1) *
1350 sizeof(IP_ADDR_STRING) : 0);
1351 if (!pFixedInfo || *pOutBufLen < size) {
1353 return ERROR_BUFFER_OVERFLOW;
1356 memset(pFixedInfo, 0, size);
1357 size = sizeof(pFixedInfo->HostName);
1358 GetComputerNameExA(ComputerNameDnsHostname, pFixedInfo->HostName, &size);
1359 size = sizeof(pFixedInfo->DomainName);
1360 GetComputerNameExA(ComputerNameDnsDomain, pFixedInfo->DomainName, &size);
1361 if (_res.nscount > 0) {
1362 PIP_ADDR_STRING ptr;
1365 for (i = 0, ptr = &pFixedInfo->DnsServerList; i < _res.nscount && ptr;
1366 i++, ptr = ptr->Next) {
1367 toIPAddressString(_res.nsaddr_list[i].sin_addr.s_addr,
1368 ptr->IpAddress.String);
1369 if (i == _res.nscount - 1)
1372 ptr->Next = (PIP_ADDR_STRING)((LPBYTE)pFixedInfo + sizeof(FIXED_INFO));
1374 ptr->Next = (PIP_ADDR_STRING)((PBYTE)ptr + sizeof(IP_ADDR_STRING));
1377 pFixedInfo->NodeType = HYBRID_NODETYPE;
1378 regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
1379 "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", 0, KEY_READ, &hKey);
1380 if (regReturn != ERROR_SUCCESS)
1381 regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
1382 "SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ,
1384 if (regReturn == ERROR_SUCCESS)
1386 DWORD size = sizeof(pFixedInfo->ScopeId);
1388 RegQueryValueExA(hKey, "ScopeID", NULL, NULL, pFixedInfo->ScopeId, &size);
1392 /* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
1393 I suppose could also check for a listener on port 53 to set EnableDns */
1395 TRACE("returning %ld\n", ret);
1400 /******************************************************************
1401 * GetNumberOfInterfaces (IPHLPAPI.@)
1404 * Returns the number of interfaces in *pdwNumIf.
1411 * NO_ERROR on success, ERROR_INVALID_PARAMETER if pdwNumIf is NULL.
1414 DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf)
1418 TRACE("pdwNumIf %p\n", pdwNumIf);
1420 ret = ERROR_INVALID_PARAMETER;
1422 *pdwNumIf = getNumInterfaces();
1425 TRACE("returning %ld\n", ret);
1430 /******************************************************************
1431 * GetPerAdapterInfo (IPHLPAPI.@)
1439 * pPerAdapterInfo [In/Out]
1440 * pOutBufLen [In/Out]
1443 * ERROR_NOT_SUPPORTED
1445 DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
1447 TRACE("(IfIndex %ld, pPerAdapterInfo %p, pOutBufLen %p)\n", IfIndex,
1448 pPerAdapterInfo, pOutBufLen);
1449 /* marking Win2K+ functions not supported */
1450 return ERROR_NOT_SUPPORTED;
1454 /******************************************************************
1455 * GetRTTAndHopCount (IPHLPAPI.@)
1462 * DestIpAddress [In]
1471 BOOL WINAPI GetRTTAndHopCount(IPAddr DestIpAddress, PULONG HopCount, ULONG MaxHops, PULONG RTT)
1473 FIXME("(DestIpAddress 0x%08lx, HopCount %p, MaxHops %ld, RTT %p): stub\n",
1474 DestIpAddress, HopCount, MaxHops, RTT);
1479 /******************************************************************
1480 * GetTcpStatistics (IPHLPAPI.@)
1491 DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS pStats)
1495 TRACE("pStats %p\n", pStats);
1496 ret = getTCPStats(pStats);
1497 TRACE("returning %ld\n", ret);
1502 static int TcpTableSorter(const void *a, const void *b)
1507 const MIB_TCPROW* rowA = a;
1508 const MIB_TCPROW* rowB = b;
1510 ret = rowA->dwLocalAddr - rowB->dwLocalAddr;
1512 ret = rowA->dwLocalPort - rowB->dwLocalPort;
1514 ret = rowA->dwRemoteAddr - rowB->dwRemoteAddr;
1516 ret = rowA->dwRemotePort - rowB->dwRemotePort;
1526 /******************************************************************
1527 * GetTcpTable (IPHLPAPI.@)
1529 * Returns a table of active TCP connections. On input, *pdwSize
1530 * is the size in bytes of pTcpTable. If this is less than required,
1531 * the function will return ERROR_INSUFFICIENT_BUFFER, and *pdwSize
1532 * will be set to the required byte size.
1533 * If bOrder is true, the returned table will be sorted, first by
1534 * local address and port number, then by remote address and port
1539 * pTcpTable [In/Out]
1544 * NO_ERROR on success, something else on failure.
1547 DWORD WINAPI GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder)
1551 TRACE("pTcpTable %p, pdwSize %p, bOrder %ld\n", pTcpTable, pdwSize,
1554 ret = ERROR_INVALID_PARAMETER;
1556 DWORD numEntries = getNumTcpEntries();
1557 ULONG size = sizeof(MIB_TCPTABLE) + (numEntries - 1) * sizeof(MIB_TCPROW);
1559 if (!pTcpTable || *pdwSize < size) {
1561 ret = ERROR_INSUFFICIENT_BUFFER;
1564 PMIB_TCPTABLE table = getTcpTable();
1567 size = sizeof(MIB_TCPTABLE) + (table->dwNumEntries - 1) *
1569 if (*pdwSize < size) {
1571 ret = ERROR_INSUFFICIENT_BUFFER;
1574 memcpy(pTcpTable, table, size);
1576 qsort(pTcpTable->table, pTcpTable->dwNumEntries,
1577 sizeof(MIB_TCPROW), TcpTableSorter);
1580 HeapFree(GetProcessHeap(), 0, table);
1583 ret = ERROR_OUTOFMEMORY;
1586 TRACE("returning %ld\n", ret);
1591 /******************************************************************
1592 * GetUdpStatistics (IPHLPAPI.@)
1603 DWORD WINAPI GetUdpStatistics(PMIB_UDPSTATS pStats)
1607 TRACE("pStats %p\n", pStats);
1608 ret = getUDPStats(pStats);
1609 TRACE("returning %ld\n", ret);
1614 static int UdpTableSorter(const void *a, const void *b)
1619 const MIB_UDPROW* rowA = (const MIB_UDPROW*)a;
1620 const MIB_UDPROW* rowB = (const MIB_UDPROW*)b;
1622 ret = rowA->dwLocalAddr - rowB->dwLocalAddr;
1624 ret = rowA->dwLocalPort - rowB->dwLocalPort;
1632 /******************************************************************
1633 * GetUdpTable (IPHLPAPI.@)
1635 * Returns a table of active UDP connections. On input, *pdwSize
1636 * is the size in bytes of pUdpTable. If this is less than required,
1637 * the function will return ERROR_INSUFFICIENT_BUFFER, and *pdwSize
1638 * will be set to the required byte size.
1639 * If bOrder is true, the returned table will be sorted, first by
1640 * local address, then by local port number.
1644 * pUdpTable [In/Out]
1649 * NO_ERROR on success, something else on failure.
1652 DWORD WINAPI GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
1656 TRACE("pUdpTable %p, pdwSize %p, bOrder %ld\n", pUdpTable, pdwSize,
1659 ret = ERROR_INVALID_PARAMETER;
1661 DWORD numEntries = getNumUdpEntries();
1662 ULONG size = sizeof(MIB_UDPTABLE) + (numEntries - 1) * sizeof(MIB_UDPROW);
1664 if (!pUdpTable || *pdwSize < size) {
1666 ret = ERROR_INSUFFICIENT_BUFFER;
1669 PMIB_UDPTABLE table = getUdpTable();
1672 size = sizeof(MIB_UDPTABLE) + (table->dwNumEntries - 1) *
1674 if (*pdwSize < size) {
1676 ret = ERROR_INSUFFICIENT_BUFFER;
1679 memcpy(pUdpTable, table, size);
1681 qsort(pUdpTable->table, pUdpTable->dwNumEntries,
1682 sizeof(MIB_UDPROW), UdpTableSorter);
1685 HeapFree(GetProcessHeap(), 0, table);
1688 ret = ERROR_OUTOFMEMORY;
1691 TRACE("returning %ld\n", ret);
1696 /******************************************************************
1697 * GetUniDirectionalAdapterInfo (IPHLPAPI.@)
1699 * This is a Win98-only function to get information on "unidirectional"
1700 * adapters. Since this is pretty nonsensical in other contexts, it
1701 * never returns anything.
1705 * pIPIfInfo [In/Out]
1706 * dwOutBufLen [In/Out]
1709 * ERROR_NOT_SUPPORTED
1712 DWORD WINAPI GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo, PULONG dwOutBufLen)
1714 TRACE("pIPIfInfo %p, dwOutBufLen %p\n", pIPIfInfo, dwOutBufLen);
1715 /* a unidirectional adapter?? not bloody likely! */
1716 return ERROR_NOT_SUPPORTED;
1720 /******************************************************************
1721 * IpReleaseAddress (IPHLPAPI.@)
1724 * Since GetAdaptersInfo never returns adapters that have DHCP enabled,
1725 * this function does nothing.
1729 * AdapterInfo [In/Out]
1732 * ERROR_NOT_SUPPORTED
1735 DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
1737 TRACE("AdapterInfo %p\n", AdapterInfo);
1738 /* not a stub, never going to support this (and I never mark an adapter as
1739 DHCP enabled, see GetAdaptersInfo, so this should never get called) */
1740 return ERROR_NOT_SUPPORTED;
1744 /******************************************************************
1745 * IpRenewAddress (IPHLPAPI.@)
1748 * Since GetAdaptersInfo never returns adapters that have DHCP enabled,
1749 * this function does nothing.
1753 * AdapterInfo [In/Out]
1756 * ERROR_NOT_SUPPORTED
1759 DWORD WINAPI IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
1761 TRACE("AdapterInfo %p\n", AdapterInfo);
1762 /* not a stub, never going to support this (and I never mark an adapter as
1763 DHCP enabled, see GetAdaptersInfo, so this should never get called) */
1764 return ERROR_NOT_SUPPORTED;
1768 /******************************************************************
1769 * NotifyAddrChange (IPHLPAPI.@)
1777 * overlapped [In/Out]
1780 * ERROR_NOT_SUPPORTED
1783 DWORD WINAPI NotifyAddrChange(PHANDLE Handle, LPOVERLAPPED overlapped)
1785 FIXME("(Handle %p, overlapped %p): stub\n", Handle, overlapped);
1786 /* marking Win2K+ functions not supported */
1787 return ERROR_NOT_SUPPORTED;
1791 /******************************************************************
1792 * NotifyRouteChange (IPHLPAPI.@)
1800 * overlapped [In/Out]
1803 * ERROR_NOT_SUPPORTED
1806 DWORD WINAPI NotifyRouteChange(PHANDLE Handle, LPOVERLAPPED overlapped)
1808 FIXME("(Handle %p, overlapped %p): stub\n", Handle, overlapped);
1809 /* marking Win2K+ functions not supported */
1810 return ERROR_NOT_SUPPORTED;
1814 /******************************************************************
1815 * SendARP (IPHLPAPI.@)
1825 * PhyAddrLen [In/Out]
1828 * ERROR_NOT_SUPPORTED
1831 DWORD WINAPI SendARP(IPAddr DestIP, IPAddr SrcIP, PULONG pMacAddr, PULONG PhyAddrLen)
1833 FIXME("(DestIP 0x%08lx, SrcIP 0x%08lx, pMacAddr %p, PhyAddrLen %p): stub\n",
1834 DestIP, SrcIP, pMacAddr, PhyAddrLen);
1835 /* marking Win2K+ functions not supported */
1836 return ERROR_NOT_SUPPORTED;
1840 /******************************************************************
1841 * SetIfEntry (IPHLPAPI.@)
1851 * ERROR_NOT_SUPPORTED
1854 DWORD WINAPI SetIfEntry(PMIB_IFROW pIfRow)
1856 FIXME("(pIfRow %p): stub\n", pIfRow);
1857 /* this is supposed to set an administratively interface up or down.
1858 Could do SIOCSIFFLAGS and set/clear IFF_UP, but, not sure I want to, and
1859 this sort of down is indistinguishable from other sorts of down (e.g. no
1861 return ERROR_NOT_SUPPORTED;
1865 /******************************************************************
1866 * SetIpForwardEntry (IPHLPAPI.@)
1879 DWORD WINAPI SetIpForwardEntry(PMIB_IPFORWARDROW pRoute)
1881 FIXME("(pRoute %p): stub\n", pRoute);
1882 /* this is to add a route entry, how's it distinguishable from
1883 CreateIpForwardEntry?
1884 could use SIOCADDRT, not sure I want to */
1889 /******************************************************************
1890 * SetIpNetEntry (IPHLPAPI.@)
1897 * pArpEntry [In/Out]
1903 DWORD WINAPI SetIpNetEntry(PMIB_IPNETROW pArpEntry)
1905 FIXME("(pArpEntry %p): stub\n", pArpEntry);
1906 /* same as CreateIpNetEntry here, could use SIOCSARP, not sure I want to */
1911 /******************************************************************
1912 * SetIpStatistics (IPHLPAPI.@)
1925 DWORD WINAPI SetIpStatistics(PMIB_IPSTATS pIpStats)
1927 FIXME("(pIpStats %p): stub\n", pIpStats);
1932 /******************************************************************
1933 * SetIpTTL (IPHLPAPI.@)
1946 DWORD WINAPI SetIpTTL(UINT nTTL)
1948 FIXME("(nTTL %d): stub\n", nTTL);
1949 /* could echo nTTL > /proc/net/sys/net/ipv4/ip_default_ttl, not sure I
1950 want to. Could map EACCESS to ERROR_ACCESS_DENIED, I suppose */
1955 /******************************************************************
1956 * SetTcpEntry (IPHLPAPI.@)
1969 DWORD WINAPI SetTcpEntry(PMIB_TCPROW pTcpRow)
1971 FIXME("(pTcpRow %p): stub\n", pTcpRow);
1976 /******************************************************************
1977 * UnenableRouter (IPHLPAPI.@)
1984 * pOverlapped [In/Out]
1985 * lpdwEnableCount [In/Out]
1988 * ERROR_NOT_SUPPORTED
1991 DWORD WINAPI UnenableRouter(OVERLAPPED * pOverlapped, LPDWORD lpdwEnableCount)
1993 FIXME("(pOverlapped %p, lpdwEnableCount %p): stub\n", pOverlapped,
1995 /* could echo "0" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
1996 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
1997 marking Win2K+ functions not supported */
1998 return ERROR_NOT_SUPPORTED;