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: HKLM\Software\Wine\Wine\Config\Network */
623 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
624 "Software\\Wine\\Wine\\Config\\Network", 0, KEY_READ,
625 &hKey) == ERROR_SUCCESS) {
626 DWORD size = sizeof(primaryWINS.String);
629 RegQueryValueExA(hKey, "WinsServer", NULL, NULL,
630 primaryWINS.String, &size);
631 addr = inet_addr(primaryWINS.String);
632 if (addr != INADDR_NONE && addr != INADDR_ANY)
634 size = sizeof(secondaryWINS.String);
635 RegQueryValueExA(hKey, "BackupWinsServer", NULL, NULL,
636 secondaryWINS.String, &size);
637 addr = inet_addr(secondaryWINS.String);
638 if (addr != INADDR_NONE && addr != INADDR_ANY)
642 for (ndx = 0; ndx < table->numIndexes; ndx++) {
643 PIP_ADAPTER_INFO ptr = &pAdapterInfo[ndx];
644 DWORD addrLen = sizeof(ptr->Address), type;
646 /* on Win98 this is left empty, but whatever */
647 lstrcpynA(ptr->AdapterName,
648 getInterfaceNameByIndex(table->indexes[ndx]),
649 MAX_ADAPTER_NAME_LENGTH+1);
650 getInterfacePhysicalByIndex(table->indexes[ndx], &addrLen,
651 ptr->Address, &type);
652 /* MS defines address length and type as UINT in some places and
653 DWORD in others, **sigh**. Don't want to assume that PUINT and
654 PDWORD are equiv (64-bit?) */
655 ptr->AddressLength = addrLen;
657 ptr->Index = table->indexes[ndx];
658 toIPAddressString(getInterfaceIPAddrByIndex(table->indexes[ndx]),
659 ptr->IpAddressList.IpAddress.String);
660 toIPAddressString(getInterfaceMaskByIndex(table->indexes[ndx]),
661 ptr->IpAddressList.IpMask.String);
663 ptr->HaveWins = TRUE;
664 memcpy(ptr->PrimaryWinsServer.IpAddress.String,
665 primaryWINS.String, sizeof(primaryWINS.String));
666 memcpy(ptr->SecondaryWinsServer.IpAddress.String,
667 secondaryWINS.String, sizeof(secondaryWINS.String));
669 if (ndx < table->numIndexes - 1)
670 ptr->Next = &pAdapterInfo[ndx + 1];
676 HeapFree(GetProcessHeap(), 0, table);
679 ret = ERROR_OUTOFMEMORY;
685 TRACE("returning %ld\n", ret);
690 /******************************************************************
691 * GetBestInterface (IPHLPAPI.@)
696 * pdwBestIfIndex [In/Out]
703 DWORD WINAPI GetBestInterface(IPAddr dwDestAddr, PDWORD pdwBestIfIndex)
707 TRACE("dwDestAddr 0x%08lx, pdwBestIfIndex %p\n", dwDestAddr, pdwBestIfIndex);
709 ret = ERROR_INVALID_PARAMETER;
711 MIB_IPFORWARDROW ipRow;
713 ret = GetBestRoute(dwDestAddr, 0, &ipRow);
714 if (ret == ERROR_SUCCESS)
715 *pdwBestIfIndex = ipRow.dwForwardIfIndex;
717 TRACE("returning %ld\n", ret);
722 /******************************************************************
723 * GetBestRoute (IPHLPAPI.@)
736 DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDROW pBestRoute)
738 PMIB_IPFORWARDTABLE table;
741 TRACE("dwDestAddr 0x%08lx, dwSourceAddr 0x%08lx, pBestRoute %p\n", dwDestAddr,
742 dwSourceAddr, pBestRoute);
744 return ERROR_INVALID_PARAMETER;
746 AllocateAndGetIpForwardTableFromStack(&table, FALSE, GetProcessHeap(), 0);
748 DWORD ndx, matchedBits, matchedNdx = 0;
750 for (ndx = 0, matchedBits = 0; ndx < table->dwNumEntries; ndx++) {
751 if ((dwDestAddr & table->table[ndx].dwForwardMask) ==
752 (table->table[ndx].dwForwardDest & table->table[ndx].dwForwardMask)) {
753 DWORD numShifts, mask;
755 for (numShifts = 0, mask = table->table[ndx].dwForwardMask;
756 mask && !(mask & 1); mask >>= 1, numShifts++)
758 if (numShifts > matchedBits) {
759 matchedBits = numShifts;
764 memcpy(pBestRoute, &table->table[matchedNdx], sizeof(MIB_IPFORWARDROW));
765 HeapFree(GetProcessHeap(), 0, table);
769 ret = ERROR_OUTOFMEMORY;
770 TRACE("returning %ld\n", ret);
775 /******************************************************************
776 * GetFriendlyIfIndex (IPHLPAPI.@)
779 * Returns a "friendly" version if IfIndex, which is one that doesn't
780 * have the top byte set. Doesn't validate whether IfIndex is a valid
788 * A friendly version of IfIndex.
791 DWORD WINAPI GetFriendlyIfIndex(DWORD IfIndex)
793 /* windows doesn't validate these, either, just makes sure the top byte is
794 cleared. I assume my ifenum module never gives an index with the top
796 TRACE("returning %ld\n", IfIndex);
801 /******************************************************************
802 * GetIcmpStatistics (IPHLPAPI.@)
813 DWORD WINAPI GetIcmpStatistics(PMIB_ICMP pStats)
817 TRACE("pStats %p\n", pStats);
818 ret = getICMPStats(pStats);
819 TRACE("returning %ld\n", ret);
824 /******************************************************************
825 * GetIfEntry (IPHLPAPI.@)
836 DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
841 TRACE("pIfRow %p\n", pIfRow);
843 return ERROR_INVALID_PARAMETER;
845 name = getInterfaceNameByIndex(pIfRow->dwIndex);
847 ret = getInterfaceEntryByName(name, pIfRow);
849 ret = getInterfaceStatsByName(name, pIfRow);
852 ret = ERROR_INVALID_DATA;
853 TRACE("returning %ld\n", ret);
858 static int IfTableSorter(const void *a, const void *b)
863 ret = ((PMIB_IFROW)a)->dwIndex - ((PMIB_IFROW)b)->dwIndex;
870 /******************************************************************
871 * GetIfTable (IPHLPAPI.@)
874 * Returns a table of local interfaces, *pdwSize is the size in bytes of
875 * pIfTable. If this is less than required, the function will return
876 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
878 * If bOrder is true, the returned table will be sorted by interface index.
887 * NO_ERROR on success, something else on failure.
890 DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
894 TRACE("pIfTable %p, pdwSize %p, bOrder %ld\n", pdwSize, pdwSize,
897 ret = ERROR_INVALID_PARAMETER;
899 DWORD numInterfaces = getNumInterfaces();
900 ULONG size = sizeof(MIB_IFTABLE) + (numInterfaces - 1) * sizeof(MIB_IFROW);
902 if (!pIfTable || *pdwSize < size) {
904 ret = ERROR_INSUFFICIENT_BUFFER;
907 InterfaceIndexTable *table = getInterfaceIndexTable();
910 size = sizeof(MIB_IFTABLE) + (table->numIndexes - 1) *
912 if (*pdwSize < size) {
914 ret = ERROR_INSUFFICIENT_BUFFER;
919 pIfTable->dwNumEntries = 0;
920 for (ndx = 0; ndx < table->numIndexes; ndx++) {
921 pIfTable->table[ndx].dwIndex = table->indexes[ndx];
922 GetIfEntry(&pIfTable->table[ndx]);
923 pIfTable->dwNumEntries++;
926 qsort(pIfTable->table, pIfTable->dwNumEntries, sizeof(MIB_IFROW),
930 HeapFree(GetProcessHeap(), 0, table);
933 ret = ERROR_OUTOFMEMORY;
936 TRACE("returning %ld\n", ret);
941 /******************************************************************
942 * GetInterfaceInfo (IPHLPAPI.@)
947 * dwOutBufLen [In/Out]
954 DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
958 TRACE("pIfTable %p, dwOutBufLen %p\n", pIfTable, dwOutBufLen);
960 ret = ERROR_INVALID_PARAMETER;
962 DWORD numInterfaces = getNumInterfaces();
963 ULONG size = sizeof(IP_INTERFACE_INFO) + (numInterfaces - 1) *
964 sizeof(IP_ADAPTER_INDEX_MAP);
966 if (!pIfTable || *dwOutBufLen < size) {
968 ret = ERROR_INSUFFICIENT_BUFFER;
971 InterfaceIndexTable *table = getInterfaceIndexTable();
974 size = sizeof(IP_INTERFACE_INFO) + (table->numIndexes - 1) *
975 sizeof(IP_ADAPTER_INDEX_MAP);
976 if (*dwOutBufLen < size) {
978 ret = ERROR_INSUFFICIENT_BUFFER;
983 pIfTable->NumAdapters = 0;
984 for (ndx = 0; ndx < table->numIndexes; ndx++) {
985 const char *walker, *name;
988 pIfTable->Adapter[ndx].Index = table->indexes[ndx];
989 name = getInterfaceNameByIndex(table->indexes[ndx]);
990 for (walker = name, assigner = pIfTable->Adapter[ndx].Name;
992 assigner - pIfTable->Adapter[ndx].Name < MAX_ADAPTER_NAME - 1;
993 walker++, assigner++)
996 pIfTable->NumAdapters++;
1000 HeapFree(GetProcessHeap(), 0, table);
1003 ret = ERROR_OUTOFMEMORY;
1006 TRACE("returning %ld\n", ret);
1011 static int IpAddrTableSorter(const void *a, const void *b)
1016 ret = ((PMIB_IPADDRROW)a)->dwAddr - ((PMIB_IPADDRROW)b)->dwAddr;
1023 /******************************************************************
1024 * GetIpAddrTable (IPHLPAPI.@)
1027 * Returns the route table. On input, *pdwSize is the size in bytes of
1028 * pIpForwardTable. If this is less than required, the function will return
1029 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
1031 * If bOrder is true, the returned table will be sorted by the next hop and
1032 * an assortment of arbitrary parameters.
1036 * pIpAddrTable [In/Out]
1041 * NO_ERROR on success, something else on failure.
1044 DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)
1048 TRACE("pIpAddrTable %p, pdwSize %p, bOrder %ld\n", pIpAddrTable, pdwSize,
1051 ret = ERROR_INVALID_PARAMETER;
1053 DWORD numInterfaces = getNumInterfaces();
1054 ULONG size = sizeof(MIB_IPADDRTABLE) + (numInterfaces - 1) *
1055 sizeof(MIB_IPADDRROW);
1057 if (!pIpAddrTable || *pdwSize < size) {
1059 ret = ERROR_INSUFFICIENT_BUFFER;
1062 InterfaceIndexTable *table = getInterfaceIndexTable();
1065 size = sizeof(MIB_IPADDRTABLE) + (table->numIndexes - 1) *
1066 sizeof(MIB_IPADDRROW);
1067 if (*pdwSize < size) {
1069 ret = ERROR_INSUFFICIENT_BUFFER;
1074 pIpAddrTable->dwNumEntries = 0;
1075 for (ndx = 0; ndx < table->numIndexes; ndx++) {
1076 pIpAddrTable->table[ndx].dwIndex = table->indexes[ndx];
1077 pIpAddrTable->table[ndx].dwAddr =
1078 getInterfaceIPAddrByIndex(table->indexes[ndx]);
1079 pIpAddrTable->table[ndx].dwMask =
1080 getInterfaceMaskByIndex(table->indexes[ndx]);
1081 /* the dwBCastAddr member isn't the broadcast address, it indicates
1082 * whether the interface uses the 1's broadcast address (1) or the
1083 * 0's broadcast address (0).
1085 bcast = getInterfaceBCastAddrByIndex(table->indexes[ndx]);
1086 pIpAddrTable->table[ndx].dwBCastAddr =
1087 (bcast & pIpAddrTable->table[ndx].dwMask) ? 1 : 0;
1088 /* FIXME: hardcoded reasm size, not sure where to get it */
1089 pIpAddrTable->table[ndx].dwReasmSize = 65535;
1090 pIpAddrTable->table[ndx].unused1 = 0;
1091 pIpAddrTable->table[ndx].wType = 0; /* aka unused2 */
1092 pIpAddrTable->dwNumEntries++;
1095 qsort(pIpAddrTable->table, pIpAddrTable->dwNumEntries,
1096 sizeof(MIB_IPADDRROW), IpAddrTableSorter);
1099 HeapFree(GetProcessHeap(), 0, table);
1102 ret = ERROR_OUTOFMEMORY;
1105 TRACE("returning %ld\n", ret);
1110 static int IpForwardTableSorter(const void *a, const void *b)
1115 PMIB_IPFORWARDROW rowA = (PMIB_IPFORWARDROW)a, rowB = (PMIB_IPFORWARDROW)b;
1117 ret = rowA->dwForwardDest - rowB->dwForwardDest;
1119 ret = rowA->dwForwardProto - rowB->dwForwardProto;
1121 ret = rowA->dwForwardPolicy - rowB->dwForwardPolicy;
1123 ret = rowA->dwForwardNextHop - rowB->dwForwardNextHop;
1133 /******************************************************************
1134 * GetIpForwardTable (IPHLPAPI.@)
1137 * Returns the route table. On input, *pdwSize is the size in bytes of
1138 * pIpForwardTable. If this is less than required, the function will return
1139 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
1141 * If bOrder is true, the returned table will be sorted by the next hop and
1142 * an assortment of arbitrary parameters.
1146 * pIpForwardTable [In/Out]
1151 * NO_ERROR on success, something else on failure.
1154 DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSize, BOOL bOrder)
1158 TRACE("pIpForwardTable %p, pdwSize %p, bOrder %ld\n", pIpForwardTable,
1159 pdwSize, (DWORD)bOrder);
1161 ret = ERROR_INVALID_PARAMETER;
1163 DWORD numRoutes = getNumRoutes();
1164 ULONG sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (numRoutes - 1) *
1165 sizeof(MIB_IPFORWARDROW);
1167 if (!pIpForwardTable || *pdwSize < sizeNeeded) {
1168 *pdwSize = sizeNeeded;
1169 ret = ERROR_INSUFFICIENT_BUFFER;
1172 RouteTable *table = getRouteTable();
1174 sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (table->numRoutes - 1) *
1175 sizeof(MIB_IPFORWARDROW);
1176 if (*pdwSize < sizeNeeded) {
1177 *pdwSize = sizeNeeded;
1178 ret = ERROR_INSUFFICIENT_BUFFER;
1183 pIpForwardTable->dwNumEntries = table->numRoutes;
1184 for (ndx = 0; ndx < numRoutes; ndx++) {
1185 pIpForwardTable->table[ndx].dwForwardIfIndex =
1186 table->routes[ndx].ifIndex;
1187 pIpForwardTable->table[ndx].dwForwardDest =
1188 table->routes[ndx].dest;
1189 pIpForwardTable->table[ndx].dwForwardMask =
1190 table->routes[ndx].mask;
1191 pIpForwardTable->table[ndx].dwForwardPolicy = 0;
1192 pIpForwardTable->table[ndx].dwForwardNextHop =
1193 table->routes[ndx].gateway;
1194 /* FIXME: this type is appropriate for local interfaces; may not
1195 always be appropriate */
1196 pIpForwardTable->table[ndx].dwForwardType = MIB_IPROUTE_TYPE_DIRECT;
1197 /* FIXME: other protos might be appropriate, e.g. the default route
1198 is typically set with MIB_IPPROTO_NETMGMT instead */
1199 pIpForwardTable->table[ndx].dwForwardProto = MIB_IPPROTO_LOCAL;
1200 /* punt on age and AS */
1201 pIpForwardTable->table[ndx].dwForwardAge = 0;
1202 pIpForwardTable->table[ndx].dwForwardNextHopAS = 0;
1203 pIpForwardTable->table[ndx].dwForwardMetric1 =
1204 table->routes[ndx].metric;
1205 /* rest of the metrics are 0.. */
1206 pIpForwardTable->table[ndx].dwForwardMetric2 = 0;
1207 pIpForwardTable->table[ndx].dwForwardMetric3 = 0;
1208 pIpForwardTable->table[ndx].dwForwardMetric4 = 0;
1209 pIpForwardTable->table[ndx].dwForwardMetric5 = 0;
1212 qsort(pIpForwardTable->table, pIpForwardTable->dwNumEntries,
1213 sizeof(MIB_IPFORWARDROW), IpForwardTableSorter);
1216 HeapFree(GetProcessHeap(), 0, table);
1219 ret = ERROR_OUTOFMEMORY;
1222 TRACE("returning %ld\n", ret);
1227 static int IpNetTableSorter(const void *a, const void *b)
1232 ret = ((PMIB_IPNETROW)a)->dwAddr - ((PMIB_IPNETROW)b)->dwAddr;
1239 /******************************************************************
1240 * GetIpNetTable (IPHLPAPI.@)
1242 * Returns the ARP cache. On input, *pdwSize is the size in bytes of
1243 * pIpNetTable. If this is less than required, the function will return
1244 * ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
1246 * If bOrder is true, the returned table will be sorted by IP address.
1250 * pIpNetTable [In/Out]
1255 * NO_ERROR on success, something else on failure.
1258 DWORD WINAPI GetIpNetTable(PMIB_IPNETTABLE pIpNetTable, PULONG pdwSize, BOOL bOrder)
1262 TRACE("pIpNetTable %p, pdwSize %p, bOrder %ld\n", pIpNetTable, pdwSize,
1265 ret = ERROR_INVALID_PARAMETER;
1267 DWORD numEntries = getNumArpEntries();
1268 ULONG size = sizeof(MIB_IPNETTABLE) + (numEntries - 1) *
1269 sizeof(MIB_IPNETROW);
1271 if (!pIpNetTable || *pdwSize < size) {
1273 ret = ERROR_INSUFFICIENT_BUFFER;
1276 PMIB_IPNETTABLE table = getArpTable();
1279 size = sizeof(MIB_IPNETTABLE) + (table->dwNumEntries - 1) *
1280 sizeof(MIB_IPNETROW);
1281 if (*pdwSize < size) {
1283 ret = ERROR_INSUFFICIENT_BUFFER;
1286 memcpy(pIpNetTable, table, size);
1288 qsort(pIpNetTable->table, pIpNetTable->dwNumEntries,
1289 sizeof(MIB_IPNETROW), IpNetTableSorter);
1292 HeapFree(GetProcessHeap(), 0, table);
1295 ret = ERROR_OUTOFMEMORY;
1298 TRACE("returning %ld\n", ret);
1303 /******************************************************************
1304 * GetIpStatistics (IPHLPAPI.@)
1315 DWORD WINAPI GetIpStatistics(PMIB_IPSTATS pStats)
1319 TRACE("pStats %p\n", pStats);
1320 ret = getIPStats(pStats);
1321 TRACE("returning %ld\n", ret);
1326 /******************************************************************
1327 * GetNetworkParams (IPHLPAPI.@)
1331 * pFixedInfo [In/Out]
1332 * pOutBufLen [In/Out]
1339 DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
1345 TRACE("pFixedInfo %p, pOutBufLen %p\n", pFixedInfo, pOutBufLen);
1347 return ERROR_INVALID_PARAMETER;
1350 size = sizeof(FIXED_INFO) + (_res.nscount > 0 ? (_res.nscount - 1) *
1351 sizeof(IP_ADDR_STRING) : 0);
1352 if (!pFixedInfo || *pOutBufLen < size) {
1354 return ERROR_BUFFER_OVERFLOW;
1357 memset(pFixedInfo, 0, size);
1358 size = sizeof(pFixedInfo->HostName);
1359 GetComputerNameExA(ComputerNameDnsHostname, pFixedInfo->HostName, &size);
1360 size = sizeof(pFixedInfo->DomainName);
1361 GetComputerNameExA(ComputerNameDnsDomain, pFixedInfo->DomainName, &size);
1362 if (_res.nscount > 0) {
1363 PIP_ADDR_STRING ptr;
1366 for (i = 0, ptr = &pFixedInfo->DnsServerList; i < _res.nscount && ptr;
1367 i++, ptr = ptr->Next) {
1368 toIPAddressString(_res.nsaddr_list[i].sin_addr.s_addr,
1369 ptr->IpAddress.String);
1370 if (i == _res.nscount - 1)
1373 ptr->Next = (PIP_ADDR_STRING)((LPBYTE)pFixedInfo + sizeof(FIXED_INFO));
1375 ptr->Next = (PIP_ADDR_STRING)((PBYTE)ptr + sizeof(IP_ADDR_STRING));
1378 pFixedInfo->NodeType = HYBRID_NODETYPE;
1379 regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
1380 "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", 0, KEY_READ, &hKey);
1381 if (regReturn != ERROR_SUCCESS)
1382 regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
1383 "SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ,
1385 if (regReturn == ERROR_SUCCESS)
1387 DWORD size = sizeof(pFixedInfo->ScopeId);
1389 RegQueryValueExA(hKey, "ScopeID", NULL, NULL, pFixedInfo->ScopeId, &size);
1393 /* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
1394 I suppose could also check for a listener on port 53 to set EnableDns */
1396 TRACE("returning %ld\n", ret);
1401 /******************************************************************
1402 * GetNumberOfInterfaces (IPHLPAPI.@)
1405 * Returns the number of interfaces in *pdwNumIf.
1412 * NO_ERROR on success, ERROR_INVALID_PARAMETER if pdwNumIf is NULL.
1415 DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf)
1419 TRACE("pdwNumIf %p\n", pdwNumIf);
1421 ret = ERROR_INVALID_PARAMETER;
1423 *pdwNumIf = getNumInterfaces();
1426 TRACE("returning %ld\n", ret);
1431 /******************************************************************
1432 * GetPerAdapterInfo (IPHLPAPI.@)
1440 * pPerAdapterInfo [In/Out]
1441 * pOutBufLen [In/Out]
1444 * ERROR_NOT_SUPPORTED
1446 DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
1448 TRACE("(IfIndex %ld, pPerAdapterInfo %p, pOutBufLen %p)\n", IfIndex,
1449 pPerAdapterInfo, pOutBufLen);
1450 /* marking Win2K+ functions not supported */
1451 return ERROR_NOT_SUPPORTED;
1455 /******************************************************************
1456 * GetRTTAndHopCount (IPHLPAPI.@)
1463 * DestIpAddress [In]
1472 BOOL WINAPI GetRTTAndHopCount(IPAddr DestIpAddress, PULONG HopCount, ULONG MaxHops, PULONG RTT)
1474 FIXME("(DestIpAddress 0x%08lx, HopCount %p, MaxHops %ld, RTT %p): stub\n",
1475 DestIpAddress, HopCount, MaxHops, RTT);
1480 /******************************************************************
1481 * GetTcpStatistics (IPHLPAPI.@)
1492 DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS pStats)
1496 TRACE("pStats %p\n", pStats);
1497 ret = getTCPStats(pStats);
1498 TRACE("returning %ld\n", ret);
1503 static int TcpTableSorter(const void *a, const void *b)
1508 PMIB_TCPROW rowA = (PMIB_TCPROW)a, rowB = (PMIB_TCPROW)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 PMIB_UDPROW rowA = (PMIB_UDPROW)a, rowB = (PMIB_UDPROW)b;
1621 ret = rowA->dwLocalAddr - rowB->dwLocalAddr;
1623 ret = rowA->dwLocalPort - rowB->dwLocalPort;
1631 /******************************************************************
1632 * GetUdpTable (IPHLPAPI.@)
1634 * Returns a table of active UDP connections. On input, *pdwSize
1635 * is the size in bytes of pUdpTable. If this is less than required,
1636 * the function will return ERROR_INSUFFICIENT_BUFFER, and *pdwSize
1637 * will be set to the required byte size.
1638 * If bOrder is true, the returned table will be sorted, first by
1639 * local address, then by local port number.
1643 * pUdpTable [In/Out]
1648 * NO_ERROR on success, something else on failure.
1651 DWORD WINAPI GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
1655 TRACE("pUdpTable %p, pdwSize %p, bOrder %ld\n", pUdpTable, pdwSize,
1658 ret = ERROR_INVALID_PARAMETER;
1660 DWORD numEntries = getNumUdpEntries();
1661 ULONG size = sizeof(MIB_UDPTABLE) + (numEntries - 1) * sizeof(MIB_UDPROW);
1663 if (!pUdpTable || *pdwSize < size) {
1665 ret = ERROR_INSUFFICIENT_BUFFER;
1668 PMIB_UDPTABLE table = getUdpTable();
1671 size = sizeof(MIB_UDPTABLE) + (table->dwNumEntries - 1) *
1673 if (*pdwSize < size) {
1675 ret = ERROR_INSUFFICIENT_BUFFER;
1678 memcpy(pUdpTable, table, size);
1680 qsort(pUdpTable->table, pUdpTable->dwNumEntries,
1681 sizeof(MIB_UDPROW), UdpTableSorter);
1684 HeapFree(GetProcessHeap(), 0, table);
1687 ret = ERROR_OUTOFMEMORY;
1690 TRACE("returning %ld\n", ret);
1695 /******************************************************************
1696 * GetUniDirectionalAdapterInfo (IPHLPAPI.@)
1698 * This is a Win98-only function to get information on "unidirectional"
1699 * adapters. Since this is pretty nonsensical in other contexts, it
1700 * never returns anything.
1704 * pIPIfInfo [In/Out]
1705 * dwOutBufLen [In/Out]
1708 * ERROR_NOT_SUPPORTED
1711 DWORD WINAPI GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo, PULONG dwOutBufLen)
1713 TRACE("pIPIfInfo %p, dwOutBufLen %p\n", pIPIfInfo, dwOutBufLen);
1714 /* a unidirectional adapter?? not bloody likely! */
1715 return ERROR_NOT_SUPPORTED;
1719 /******************************************************************
1720 * IpReleaseAddress (IPHLPAPI.@)
1723 * Since GetAdaptersInfo never returns adapters that have DHCP enabled,
1724 * this function does nothing.
1728 * AdapterInfo [In/Out]
1731 * ERROR_NOT_SUPPORTED
1734 DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
1736 TRACE("AdapterInfo %p\n", AdapterInfo);
1737 /* not a stub, never going to support this (and I never mark an adapter as
1738 DHCP enabled, see GetAdaptersInfo, so this should never get called) */
1739 return ERROR_NOT_SUPPORTED;
1743 /******************************************************************
1744 * IpRenewAddress (IPHLPAPI.@)
1747 * Since GetAdaptersInfo never returns adapters that have DHCP enabled,
1748 * this function does nothing.
1752 * AdapterInfo [In/Out]
1755 * ERROR_NOT_SUPPORTED
1758 DWORD WINAPI IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
1760 TRACE("AdapterInfo %p\n", AdapterInfo);
1761 /* not a stub, never going to support this (and I never mark an adapter as
1762 DHCP enabled, see GetAdaptersInfo, so this should never get called) */
1763 return ERROR_NOT_SUPPORTED;
1767 /******************************************************************
1768 * NotifyAddrChange (IPHLPAPI.@)
1776 * overlapped [In/Out]
1779 * ERROR_NOT_SUPPORTED
1782 DWORD WINAPI NotifyAddrChange(PHANDLE Handle, LPOVERLAPPED overlapped)
1784 FIXME("(Handle %p, overlapped %p): stub\n", Handle, overlapped);
1785 /* marking Win2K+ functions not supported */
1786 return ERROR_NOT_SUPPORTED;
1790 /******************************************************************
1791 * NotifyRouteChange (IPHLPAPI.@)
1799 * overlapped [In/Out]
1802 * ERROR_NOT_SUPPORTED
1805 DWORD WINAPI NotifyRouteChange(PHANDLE Handle, LPOVERLAPPED overlapped)
1807 FIXME("(Handle %p, overlapped %p): stub\n", Handle, overlapped);
1808 /* marking Win2K+ functions not supported */
1809 return ERROR_NOT_SUPPORTED;
1813 /******************************************************************
1814 * SendARP (IPHLPAPI.@)
1824 * PhyAddrLen [In/Out]
1827 * ERROR_NOT_SUPPORTED
1830 DWORD WINAPI SendARP(IPAddr DestIP, IPAddr SrcIP, PULONG pMacAddr, PULONG PhyAddrLen)
1832 FIXME("(DestIP 0x%08lx, SrcIP 0x%08lx, pMacAddr %p, PhyAddrLen %p): stub\n",
1833 DestIP, SrcIP, pMacAddr, PhyAddrLen);
1834 /* marking Win2K+ functions not supported */
1835 return ERROR_NOT_SUPPORTED;
1839 /******************************************************************
1840 * SetIfEntry (IPHLPAPI.@)
1850 * ERROR_NOT_SUPPORTED
1853 DWORD WINAPI SetIfEntry(PMIB_IFROW pIfRow)
1855 FIXME("(pIfRow %p): stub\n", pIfRow);
1856 /* this is supposed to set an administratively interface up or down.
1857 Could do SIOCSIFFLAGS and set/clear IFF_UP, but, not sure I want to, and
1858 this sort of down is indistinguishable from other sorts of down (e.g. no
1860 return ERROR_NOT_SUPPORTED;
1864 /******************************************************************
1865 * SetIpForwardEntry (IPHLPAPI.@)
1878 DWORD WINAPI SetIpForwardEntry(PMIB_IPFORWARDROW pRoute)
1880 FIXME("(pRoute %p): stub\n", pRoute);
1881 /* this is to add a route entry, how's it distinguishable from
1882 CreateIpForwardEntry?
1883 could use SIOCADDRT, not sure I want to */
1888 /******************************************************************
1889 * SetIpNetEntry (IPHLPAPI.@)
1896 * pArpEntry [In/Out]
1902 DWORD WINAPI SetIpNetEntry(PMIB_IPNETROW pArpEntry)
1904 FIXME("(pArpEntry %p): stub\n", pArpEntry);
1905 /* same as CreateIpNetEntry here, could use SIOCSARP, not sure I want to */
1910 /******************************************************************
1911 * SetIpStatistics (IPHLPAPI.@)
1924 DWORD WINAPI SetIpStatistics(PMIB_IPSTATS pIpStats)
1926 FIXME("(pIpStats %p): stub\n", pIpStats);
1931 /******************************************************************
1932 * SetIpTTL (IPHLPAPI.@)
1945 DWORD WINAPI SetIpTTL(UINT nTTL)
1947 FIXME("(nTTL %d): stub\n", nTTL);
1948 /* could echo nTTL > /proc/net/sys/net/ipv4/ip_default_ttl, not sure I
1949 want to. Could map EACCESS to ERROR_ACCESS_DENIED, I suppose */
1954 /******************************************************************
1955 * SetTcpEntry (IPHLPAPI.@)
1968 DWORD WINAPI SetTcpEntry(PMIB_TCPROW pTcpRow)
1970 FIXME("(pTcpRow %p): stub\n", pTcpRow);
1975 /******************************************************************
1976 * UnenableRouter (IPHLPAPI.@)
1983 * pOverlapped [In/Out]
1984 * lpdwEnableCount [In/Out]
1987 * ERROR_NOT_SUPPORTED
1990 DWORD WINAPI UnenableRouter(OVERLAPPED * pOverlapped, LPDWORD lpdwEnableCount)
1992 FIXME("(pOverlapped %p, lpdwEnableCount %p): stub\n", pOverlapped,
1994 /* could echo "0" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
1995 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
1996 marking Win2K+ functions not supported */
1997 return ERROR_NOT_SUPPORTED;