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
22 #include "iphlpapi_private.h"
26 #include <sys/types.h>
27 #ifdef HAVE_NETINET_IN_H
28 # include <netinet/in.h>
30 #ifdef HAVE_ARPA_INET_H
31 # include <arpa/inet.h>
33 #ifdef HAVE_ARPA_NAMESER_H
34 # include <arpa/nameser.h>
50 #include "wine/debug.h"
52 WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi
);
54 BOOL WINAPI
DllMain (HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
57 case DLL_PROCESS_ATTACH
:
58 DisableThreadLibraryCalls( hinstDLL
);
62 case DLL_PROCESS_DETACH
:
69 /******************************************************************
70 * AddIPAddress (IPHLPAPI.@)
79 * NTEInstance [In/Out]
86 DWORD WINAPI
AddIPAddress(IPAddr Address
, IPMask Netmask
, DWORD IfIndex
, PULONG NteContext
, PULONG NteInstance
)
88 return RtlNtStatusToDosError(addIPAddress(Address
, Netmask
, IfIndex
, NteContext
, NteInstance
));
92 /******************************************************************
93 * AllocateAndGetIfTableFromStack (IPHLPAPI.@)
98 * ppIfTable [Out] -- pointer into which the MIB_IFTABLE is
99 * allocated and returned.
100 * bOrder [In] -- passed to GetIfTable to order the table
101 * heap [In] -- heap from which the table is allocated
102 * flags [In] -- flags to HeapAlloc
104 * RETURNS -- ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
105 * GetIfTable returns otherwise
108 DWORD WINAPI
AllocateAndGetIfTableFromStack(PMIB_IFTABLE
*ppIfTable
,
109 BOOL bOrder
, HANDLE heap
, DWORD flags
)
113 TRACE("ppIfTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n", ppIfTable
,
114 (DWORD
)bOrder
, (DWORD
)heap
, flags
);
116 ret
= ERROR_INVALID_PARAMETER
;
120 ret
= GetIfTable(*ppIfTable
, &dwSize
, bOrder
);
121 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
122 *ppIfTable
= (PMIB_IFTABLE
)HeapAlloc(heap
, flags
, dwSize
);
123 ret
= GetIfTable(*ppIfTable
, &dwSize
, bOrder
);
126 TRACE("returning %ld\n", ret
);
131 /******************************************************************
132 * AllocateAndGetIpAddrTableFromStack (IPHLPAPI.@)
137 * ppIpAddrTable [Out]
138 * bOrder [In] -- passed to GetIpAddrTable to order the table
139 * heap [In] -- heap from which the table is allocated
140 * flags [In] -- flags to HeapAlloc
147 DWORD WINAPI
AllocateAndGetIpAddrTableFromStack(PMIB_IPADDRTABLE
*ppIpAddrTable
,
148 BOOL bOrder
, HANDLE heap
, DWORD flags
)
152 TRACE("ppIpAddrTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
153 ppIpAddrTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
155 ret
= ERROR_INVALID_PARAMETER
;
159 ret
= GetIpAddrTable(*ppIpAddrTable
, &dwSize
, bOrder
);
160 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
161 *ppIpAddrTable
= (PMIB_IPADDRTABLE
)HeapAlloc(heap
, flags
, dwSize
);
162 ret
= GetIpAddrTable(*ppIpAddrTable
, &dwSize
, bOrder
);
165 TRACE("returning %ld\n", ret
);
170 /******************************************************************
171 * AllocateAndGetIpForwardTableFromStack (IPHLPAPI.@)
174 * ppIpForwardTable [Out] -- pointer into which the MIB_IPFORWARDTABLE is
175 * allocated and returned.
176 * bOrder [In] -- passed to GetIfTable to order the table
177 * heap [In] -- heap from which the table is allocated
178 * flags [In] -- flags to HeapAlloc
180 * RETURNS -- ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
181 * GetIpForwardTable returns otherwise
184 DWORD WINAPI
AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE
*
185 ppIpForwardTable
, BOOL bOrder
, HANDLE heap
, DWORD flags
)
189 TRACE("ppIpForwardTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
190 ppIpForwardTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
191 if (!ppIpForwardTable
)
192 ret
= ERROR_INVALID_PARAMETER
;
196 ret
= GetIpForwardTable(*ppIpForwardTable
, &dwSize
, bOrder
);
197 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
198 *ppIpForwardTable
= (PMIB_IPFORWARDTABLE
)HeapAlloc(heap
, flags
, dwSize
);
199 ret
= GetIpForwardTable(*ppIpForwardTable
, &dwSize
, bOrder
);
202 TRACE("returning %ld\n", ret
);
207 /******************************************************************
208 * AllocateAndGetIpNetTableFromStack (IPHLPAPI.@)
214 * bOrder [In] -- passed to GetIpNetTable to order the table
215 * heap [In] -- heap from which the table is allocated
216 * flags [In] -- flags to HeapAlloc
223 DWORD WINAPI
AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE
*ppIpNetTable
,
224 BOOL bOrder
, HANDLE heap
, DWORD flags
)
228 TRACE("ppIpNetTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
229 ppIpNetTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
231 ret
= ERROR_INVALID_PARAMETER
;
235 ret
= GetIpNetTable(*ppIpNetTable
, &dwSize
, bOrder
);
236 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
237 *ppIpNetTable
= (PMIB_IPNETTABLE
)HeapAlloc(heap
, flags
, dwSize
);
238 ret
= GetIpNetTable(*ppIpNetTable
, &dwSize
, bOrder
);
241 TRACE("returning %ld\n", ret
);
246 /******************************************************************
247 * AllocateAndGetTcpTableFromStack (IPHLPAPI.@)
253 * bOrder [In] -- passed to GetTcpTable to order the table
254 * heap [In] -- heap from which the table is allocated
255 * flags [In] -- flags to HeapAlloc
262 DWORD WINAPI
AllocateAndGetTcpTableFromStack(PMIB_TCPTABLE
*ppTcpTable
,
263 BOOL bOrder
, HANDLE heap
, DWORD flags
)
267 TRACE("ppTcpTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
268 ppTcpTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
270 ret
= ERROR_INVALID_PARAMETER
;
274 ret
= GetTcpTable(*ppTcpTable
, &dwSize
, bOrder
);
275 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
276 *ppTcpTable
= (PMIB_TCPTABLE
)HeapAlloc(heap
, flags
, dwSize
);
277 ret
= GetTcpTable(*ppTcpTable
, &dwSize
, bOrder
);
280 TRACE("returning %ld\n", ret
);
285 /******************************************************************
286 * AllocateAndGetUdpTableFromStack (IPHLPAPI.@)
292 * bOrder [In] -- passed to GetUdpTable to order the table
293 * heap [In] -- heap from which the table is allocated
294 * flags [In] -- flags to HeapAlloc
301 DWORD WINAPI
AllocateAndGetUdpTableFromStack(PMIB_UDPTABLE
*ppUdpTable
,
302 BOOL bOrder
, HANDLE heap
, DWORD flags
)
306 TRACE("ppUdpTable %p, bOrder %ld, heap 0x%08lx, flags 0x%08lx\n",
307 ppUdpTable
, (DWORD
)bOrder
, (DWORD
)heap
, flags
);
309 ret
= ERROR_INVALID_PARAMETER
;
313 ret
= GetUdpTable(*ppUdpTable
, &dwSize
, bOrder
);
314 if (ret
== ERROR_INSUFFICIENT_BUFFER
) {
315 *ppUdpTable
= (PMIB_UDPTABLE
)HeapAlloc(heap
, flags
, dwSize
);
316 ret
= GetUdpTable(*ppUdpTable
, &dwSize
, bOrder
);
319 TRACE("returning %ld\n", ret
);
324 /******************************************************************
325 * CreateIpForwardEntry (IPHLPAPI.@)
337 DWORD WINAPI
CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
339 return createIpForwardEntry( pRoute
);
343 /******************************************************************
344 * CreateIpNetEntry (IPHLPAPI.@)
356 DWORD WINAPI
CreateIpNetEntry(PMIB_IPNETROW pArpEntry
)
358 TRACE("pArpEntry %p\n", pArpEntry
);
359 /* could use SIOCSARP on systems that support it, not sure I want to */
365 /******************************************************************
366 * CreateProxyArpEntry (IPHLPAPI.@)
380 DWORD WINAPI
CreateProxyArpEntry(DWORD dwAddress
, DWORD dwMask
, DWORD dwIfIndex
)
382 TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress
,
385 /* marking Win2K+ functions not supported */
386 return ERROR_NOT_SUPPORTED
;
390 /******************************************************************
391 * DeleteIPAddress (IPHLPAPI.@)
403 DWORD WINAPI
DeleteIPAddress(ULONG NTEContext
)
405 TRACE("NTEContext %ld\n", NTEContext
);
406 return RtlNtStatusToDosError(deleteIpAddress(NTEContext
));
410 /******************************************************************
411 * DeleteIpForwardEntry (IPHLPAPI.@)
423 DWORD WINAPI
DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
425 return deleteIpForwardEntry( pRoute
);
429 /******************************************************************
430 * DeleteIpNetEntry (IPHLPAPI.@)
442 DWORD WINAPI
DeleteIpNetEntry(PMIB_IPNETROW pArpEntry
)
444 TRACE("pArpEntry %p\n", pArpEntry
);
445 /* could use SIOCDARP on systems that support it, not sure I want to */
451 /******************************************************************
452 * DeleteProxyArpEntry (IPHLPAPI.@)
466 DWORD WINAPI
DeleteProxyArpEntry(DWORD dwAddress
, DWORD dwMask
, DWORD dwIfIndex
)
468 TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress
,
471 /* marking Win2K+ functions not supported */
472 return ERROR_NOT_SUPPORTED
;
475 /******************************************************************
476 * EnableRouter (IPHLPAPI.@)
482 * pOverlapped [In/Out]
489 DWORD WINAPI
EnableRouter(HANDLE
* pHandle
, OVERLAPPED
* pOverlapped
)
491 TRACE("pHandle %p, pOverlapped %p\n", pHandle
, pOverlapped
);
493 /* could echo "1" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
494 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
495 marking Win2K+ functions not supported */
496 return ERROR_NOT_SUPPORTED
;
500 /******************************************************************
501 * FlushIpNetTable (IPHLPAPI.@)
513 DWORD WINAPI
FlushIpNetTable(DWORD dwIfIndex
)
515 TRACE("dwIfIndex 0x%08lx\n", dwIfIndex
);
517 /* this flushes the arp cache of the given index
518 marking Win2K+ functions not supported */
519 return ERROR_NOT_SUPPORTED
;
523 /******************************************************************
524 * GetAdapterIndex (IPHLPAPI.@)
529 * AdapterName [In/Out]
537 DWORD WINAPI
GetAdapterIndex(LPWSTR AdapterName
, PULONG IfIndex
)
539 TRACE("AdapterName %p, IfIndex %p\n", AdapterName
, IfIndex
);
541 /* marking Win2K+ functions not supported */
542 return ERROR_NOT_SUPPORTED
;
546 /******************************************************************
547 * GetAdaptersInfo (IPHLPAPI.@)
552 * pAdapterInfo [In/Out]
553 * pOutBufLen [In/Out]
560 DWORD WINAPI
GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo
, PULONG pOutBufLen
)
566 TRACE("pAdapterInfo %p, pOutBufLen %p\n", pAdapterInfo
, pOutBufLen
);
568 ret
= ERROR_INVALID_PARAMETER
;
570 DWORD numNonLoopbackInterfaces
= getNumNonLoopbackInterfaces();
572 if (numNonLoopbackInterfaces
> 0) {
573 /* this calculation assumes only one address in the IP_ADDR_STRING lists.
574 that's okay, because:
575 - we don't get multiple addresses per adapter anyway
576 - we don't know about per-adapter gateways
577 - DHCP and WINS servers can have max one entry per list */
578 ULONG size
= sizeof(IP_ADAPTER_INFO
) * numNonLoopbackInterfaces
;
580 if (!pAdapterInfo
|| *pOutBufLen
< size
) {
582 ret
= ERROR_BUFFER_OVERFLOW
;
585 InterfaceIndexTable
*table
= getNonLoopbackInterfaceIndexTable();
588 size
= sizeof(IP_ADAPTER_INFO
) * table
->numIndexes
;
589 if (*pOutBufLen
< size
) {
591 ret
= ERROR_INSUFFICIENT_BUFFER
;
596 BOOL winsEnabled
= FALSE
;
597 IP_ADDRESS_STRING primaryWINS
, secondaryWINS
;
599 memset(pAdapterInfo
, 0, size
);
600 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
601 "Software\\Wine\\Wine\\Config\\Network", 0, KEY_READ
,
602 &hKey
) == ERROR_SUCCESS
) {
603 DWORD size
= sizeof(primaryWINS
.String
);
606 RegQueryValueExA(hKey
, "WinsServer", NULL
, NULL
,
607 primaryWINS
.String
, &size
);
608 addr
= inet_addr(primaryWINS
.String
);
609 if (addr
!= INADDR_NONE
&& addr
!= INADDR_ANY
)
611 size
= sizeof(secondaryWINS
.String
);
612 RegQueryValueExA(hKey
, "BackupWinsServer", NULL
, NULL
,
613 secondaryWINS
.String
, &size
);
614 addr
= inet_addr(secondaryWINS
.String
);
615 if (addr
!= INADDR_NONE
&& addr
!= INADDR_ANY
)
619 TRACE("num of index is %lu\n", table
->numIndexes
);
620 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
621 PIP_ADAPTER_INFO ptr
= &pAdapterInfo
[ndx
];
622 DWORD addrLen
= sizeof(ptr
->Address
), type
;
624 getInterfaceNameByIndex(table
->indexes
[ndx
]);
626 /* on Win98 this is left empty, but whatever */
628 strncpy(ptr
->AdapterName
,ifname
,sizeof(ptr
->AdapterName
));
629 consumeInterfaceName(ifname
);
630 ptr
->AdapterName
[MAX_ADAPTER_NAME_LENGTH
] = '\0';
631 getInterfacePhysicalByIndex(table
->indexes
[ndx
], &addrLen
,
632 ptr
->Address
, &type
);
633 /* MS defines address length and type as UINT in some places and
634 DWORD in others, **sigh**. Don't want to assume that PUINT and
635 PDWORD are equiv (64-bit?) */
636 ptr
->AddressLength
= addrLen
;
638 ptr
->Index
= table
->indexes
[ndx
];
639 toIPAddressString(getInterfaceIPAddrByIndex(table
->indexes
[ndx
]),
640 ptr
->IpAddressList
.IpAddress
.String
);
641 toIPAddressString(getInterfaceMaskByIndex(table
->indexes
[ndx
]),
642 ptr
->IpAddressList
.IpMask
.String
);
643 getDhcpInfoForAdapter(table
->indexes
[ndx
], &dhcpEnabled
,
644 &dhcpServer
, &ptr
->LeaseObtained
,
646 ptr
->DhcpEnabled
= (DWORD
) dhcpEnabled
;
647 toIPAddressString(dhcpServer
,
648 ptr
->DhcpServer
.IpAddress
.String
);
650 ptr
->HaveWins
= TRUE
;
651 memcpy(ptr
->PrimaryWinsServer
.IpAddress
.String
,
652 primaryWINS
.String
, sizeof(primaryWINS
.String
));
653 memcpy(ptr
->SecondaryWinsServer
.IpAddress
.String
,
654 secondaryWINS
.String
, sizeof(secondaryWINS
.String
));
656 if (ndx
< table
->numIndexes
- 1)
657 ptr
->Next
= &pAdapterInfo
[ndx
+ 1];
666 ret
= ERROR_OUTOFMEMORY
;
672 TRACE("returning %ld\n", ret
);
677 /******************************************************************
678 * GetBestInterface (IPHLPAPI.@)
684 * pdwBestIfIndex [In/Out]
691 DWORD WINAPI
GetBestInterface(IPAddr dwDestAddr
, PDWORD pdwBestIfIndex
)
695 TRACE("dwDestAddr 0x%08lx, pdwBestIfIndex %p\n", dwDestAddr
, pdwBestIfIndex
);
697 ret
= ERROR_INVALID_PARAMETER
;
699 MIB_IPFORWARDROW ipRow
;
701 ret
= GetBestRoute(dwDestAddr
, 0, &ipRow
);
702 if (ret
== ERROR_SUCCESS
)
703 *pdwBestIfIndex
= ipRow
.dwForwardIfIndex
;
705 TRACE("returning %ld\n", ret
);
710 /******************************************************************
711 * GetBestRoute (IPHLPAPI.@)
725 DWORD WINAPI
GetBestRoute(DWORD dwDestAddr
, DWORD dwSourceAddr
, PMIB_IPFORWARDROW pBestRoute
)
727 PMIB_IPFORWARDTABLE table
;
730 TRACE("dwDestAddr 0x%08lx, dwSourceAddr 0x%08lx, pBestRoute %p\n", dwDestAddr
,
731 dwSourceAddr
, pBestRoute
);
733 return ERROR_INVALID_PARAMETER
;
735 AllocateAndGetIpForwardTableFromStack(&table
, FALSE
, GetProcessHeap(), 0);
737 DWORD ndx
, matchedBits
, matchedNdx
= 0;
739 for (ndx
= 0, matchedBits
= 0; ndx
< table
->dwNumEntries
; ndx
++) {
740 if ((dwDestAddr
& table
->table
[ndx
].dwForwardMask
) ==
741 (table
->table
[ndx
].dwForwardDest
& table
->table
[ndx
].dwForwardMask
)) {
742 DWORD numShifts
, mask
;
744 for (numShifts
= 0, mask
= table
->table
[ndx
].dwForwardMask
;
745 mask
&& !(mask
& 1); mask
>>= 1, numShifts
++)
747 if (numShifts
> matchedBits
) {
748 matchedBits
= numShifts
;
753 memcpy(pBestRoute
, &table
->table
[matchedNdx
], sizeof(MIB_IPFORWARDROW
));
754 HeapFree(GetProcessHeap(), 0, table
);
758 ret
= ERROR_OUTOFMEMORY
;
759 TRACE("returning %ld\n", ret
);
764 /******************************************************************
765 * GetFriendlyIfIndex (IPHLPAPI.@)
777 DWORD WINAPI
GetFriendlyIfIndex(DWORD IfIndex
)
779 /* windows doesn't validate these, either, just makes sure the top byte is
780 cleared. I assume my ifenum module never gives an index with the top
782 TRACE("returning %ld\n", IfIndex
);
787 /******************************************************************
788 * GetIcmpStatistics (IPHLPAPI.@)
800 DWORD WINAPI
GetIcmpStatistics(PMIB_ICMP pStats
)
804 TRACE("pStats %p\n", pStats
);
805 ret
= getICMPStats(pStats
);
806 TRACE("returning %ld\n", ret
);
811 /******************************************************************
812 * GetIfEntry (IPHLPAPI.@)
824 DWORD WINAPI
GetIfEntry(PMIB_IFROW pIfRow
)
829 TRACE("pIfRow %p\n", pIfRow
);
831 return ERROR_INVALID_PARAMETER
;
833 name
= getInterfaceNameByIndex(pIfRow
->dwIndex
);
835 ret
= getInterfaceEntryByIndex(pIfRow
->dwIndex
, pIfRow
);
837 ret
= getInterfaceStatsByName(name
, pIfRow
);
838 consumeInterfaceName(name
);
841 ret
= ERROR_INVALID_DATA
;
842 TRACE("returning %ld\n", ret
);
847 static int IfTableSorter(const void *a
, const void *b
)
852 ret
= ((PMIB_IFROW
)a
)->dwIndex
- ((PMIB_IFROW
)b
)->dwIndex
;
859 /******************************************************************
860 * GetIfTable (IPHLPAPI.@)
874 DWORD WINAPI
GetIfTable(PMIB_IFTABLE pIfTable
, PULONG pdwSize
, BOOL bOrder
)
878 TRACE("pIfTable %p, pdwSize %p, bOrder %ld\n", pdwSize
, pdwSize
,
881 ret
= ERROR_INVALID_PARAMETER
;
883 DWORD numInterfaces
= getNumInterfaces();
884 TRACE("GetIfTable: numInterfaces = %d\n", (int)numInterfaces
);
885 ULONG size
= sizeof(MIB_IFTABLE
) + (numInterfaces
- 1) * sizeof(MIB_IFROW
);
887 if (!pIfTable
|| *pdwSize
< size
) {
889 ret
= ERROR_INSUFFICIENT_BUFFER
;
892 InterfaceIndexTable
*table
= getInterfaceIndexTable();
895 size
= sizeof(MIB_IFTABLE
) + (table
->numIndexes
- 1) *
897 if (*pdwSize
< size
) {
899 ret
= ERROR_INSUFFICIENT_BUFFER
;
904 pIfTable
->dwNumEntries
= 0;
905 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
906 pIfTable
->table
[ndx
].dwIndex
= table
->indexes
[ndx
];
907 GetIfEntry(&pIfTable
->table
[ndx
]);
908 pIfTable
->dwNumEntries
++;
911 qsort(pIfTable
->table
, pIfTable
->dwNumEntries
, sizeof(MIB_IFROW
),
918 ret
= ERROR_OUTOFMEMORY
;
921 TRACE("returning %ld\n", ret
);
926 /******************************************************************
927 * GetInterfaceInfo (IPHLPAPI.@)
933 * dwOutBufLen [In/Out]
940 DWORD WINAPI
GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable
, PULONG dwOutBufLen
)
944 TRACE("pIfTable %p, dwOutBufLen %p\n", pIfTable
, dwOutBufLen
);
946 ret
= ERROR_INVALID_PARAMETER
;
948 DWORD numNonLoopbackInterfaces
= getNumNonLoopbackInterfaces();
949 DPRINT("numNonLoopbackInterfaces == 0x%x\n", numNonLoopbackInterfaces
);
950 ULONG size
= sizeof(IP_INTERFACE_INFO
) + (numNonLoopbackInterfaces
) *
951 sizeof(IP_ADAPTER_INDEX_MAP
);
953 if (!pIfTable
|| *dwOutBufLen
< size
) {
955 ret
= ERROR_INSUFFICIENT_BUFFER
;
958 InterfaceIndexTable
*table
= getNonLoopbackInterfaceIndexTable();
959 DPRINT("table->numIndexes == 0x%x\n", table
->numIndexes
);
962 size
= sizeof(IP_INTERFACE_INFO
) + (table
->numIndexes
) *
963 sizeof(IP_ADAPTER_INDEX_MAP
);
964 if (*dwOutBufLen
< size
) {
966 ret
= ERROR_INSUFFICIENT_BUFFER
;
971 pIfTable
->NumAdapters
= 0;
972 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
973 const char *walker
, *name
;
976 pIfTable
->Adapter
[ndx
].Index
= table
->indexes
[ndx
];
977 name
= getInterfaceNameByIndex(table
->indexes
[ndx
]);
978 for (walker
= name
, assigner
= pIfTable
->Adapter
[ndx
].Name
;
980 assigner
- pIfTable
->Adapter
[ndx
].Name
< MAX_ADAPTER_NAME
- 1;
981 walker
++, assigner
++)
984 consumeInterfaceName(name
);
985 pIfTable
->NumAdapters
++;
992 ret
= ERROR_OUTOFMEMORY
;
995 TRACE("returning %ld\n", ret
);
1000 static int IpAddrTableSorter(const void *a
, const void *b
)
1005 ret
= ((PMIB_IPADDRROW
)a
)->dwAddr
- ((PMIB_IPADDRROW
)b
)->dwAddr
;
1012 /******************************************************************
1013 * GetIpAddrTable (IPHLPAPI.@)
1018 * pIpAddrTable [In/Out]
1027 DWORD WINAPI
GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable
, PULONG pdwSize
, BOOL bOrder
)
1031 TRACE("pIpAddrTable %p, pdwSize %p, bOrder %ld\n", pIpAddrTable
, pdwSize
,
1034 ret
= ERROR_INVALID_PARAMETER
;
1036 DWORD numInterfaces
= getNumInterfaces();
1037 ULONG size
= sizeof(MIB_IPADDRTABLE
) + (numInterfaces
- 1) *
1038 sizeof(MIB_IPADDRROW
);
1040 if (!pIpAddrTable
|| *pdwSize
< size
) {
1042 ret
= ERROR_INSUFFICIENT_BUFFER
;
1045 InterfaceIndexTable
*table
= getInterfaceIndexTable();
1048 size
= sizeof(MIB_IPADDRTABLE
) + (table
->numIndexes
- 1) *
1049 sizeof(MIB_IPADDRROW
);
1050 if (*pdwSize
< size
) {
1052 ret
= ERROR_INSUFFICIENT_BUFFER
;
1057 pIpAddrTable
->dwNumEntries
= 0;
1058 for (ndx
= 0; ndx
< table
->numIndexes
; ndx
++) {
1059 pIpAddrTable
->table
[ndx
].dwIndex
= table
->indexes
[ndx
];
1060 pIpAddrTable
->table
[ndx
].dwAddr
=
1061 getInterfaceIPAddrByIndex(table
->indexes
[ndx
]);
1062 pIpAddrTable
->table
[ndx
].dwMask
=
1063 getInterfaceMaskByIndex(table
->indexes
[ndx
]);
1064 /* the dwBCastAddr member isn't the broadcast address, it indicates
1065 * whether the interface uses the 1's broadcast address (1) or the
1066 * 0's broadcast address (0).
1068 bcast
= getInterfaceBCastAddrByIndex(table
->indexes
[ndx
]);
1069 pIpAddrTable
->table
[ndx
].dwBCastAddr
=
1070 (bcast
& pIpAddrTable
->table
[ndx
].dwMask
) ? 1 : 0;
1071 /* FIXME: hardcoded reasm size, not sure where to get it */
1072 pIpAddrTable
->table
[ndx
].dwReasmSize
= 65535;
1073 pIpAddrTable
->table
[ndx
].unused1
= 0;
1074 pIpAddrTable
->table
[ndx
].wType
= 0; /* aka unused2 */
1075 pIpAddrTable
->dwNumEntries
++;
1078 qsort(pIpAddrTable
->table
, pIpAddrTable
->dwNumEntries
,
1079 sizeof(MIB_IPADDRROW
), IpAddrTableSorter
);
1085 ret
= ERROR_OUTOFMEMORY
;
1088 TRACE("returning %ld\n", ret
);
1093 static int IpForwardTableSorter(const void *a
, const void *b
)
1098 PMIB_IPFORWARDROW rowA
= (PMIB_IPFORWARDROW
)a
, rowB
= (PMIB_IPFORWARDROW
)b
;
1100 ret
= rowA
->dwForwardDest
- rowB
->dwForwardDest
;
1102 ret
= rowA
->dwForwardProto
- rowB
->dwForwardProto
;
1104 ret
= rowA
->dwForwardPolicy
- rowB
->dwForwardPolicy
;
1106 ret
= rowA
->dwForwardNextHop
- rowB
->dwForwardNextHop
;
1116 /******************************************************************
1117 * GetIpForwardTable (IPHLPAPI.@)
1122 * pIpForwardTable [In/Out]
1131 DWORD WINAPI
GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable
, PULONG pdwSize
, BOOL bOrder
)
1135 TRACE("pIpForwardTable %p, pdwSize %p, bOrder %ld\n", pIpForwardTable
,
1136 pdwSize
, (DWORD
)bOrder
);
1138 ret
= ERROR_INVALID_PARAMETER
;
1140 DWORD numRoutes
= getNumRoutes();
1141 ULONG sizeNeeded
= sizeof(MIB_IPFORWARDTABLE
) + (numRoutes
- 1) *
1142 sizeof(MIB_IPFORWARDROW
);
1144 if (!pIpForwardTable
|| *pdwSize
< sizeNeeded
) {
1145 *pdwSize
= sizeNeeded
;
1146 ret
= ERROR_INSUFFICIENT_BUFFER
;
1149 RouteTable
*table
= getRouteTable();
1151 sizeNeeded
= sizeof(MIB_IPFORWARDTABLE
) + (table
->numRoutes
- 1) *
1152 sizeof(MIB_IPFORWARDROW
);
1153 if (*pdwSize
< sizeNeeded
) {
1154 *pdwSize
= sizeNeeded
;
1155 ret
= ERROR_INSUFFICIENT_BUFFER
;
1160 pIpForwardTable
->dwNumEntries
= table
->numRoutes
;
1161 for (ndx
= 0; ndx
< numRoutes
; ndx
++) {
1162 pIpForwardTable
->table
[ndx
].dwForwardIfIndex
=
1163 table
->routes
[ndx
].ifIndex
;
1164 pIpForwardTable
->table
[ndx
].dwForwardDest
=
1165 table
->routes
[ndx
].dest
;
1166 pIpForwardTable
->table
[ndx
].dwForwardMask
=
1167 table
->routes
[ndx
].mask
;
1168 pIpForwardTable
->table
[ndx
].dwForwardPolicy
= 0;
1169 pIpForwardTable
->table
[ndx
].dwForwardNextHop
=
1170 table
->routes
[ndx
].gateway
;
1171 /* FIXME: this type is appropriate for local interfaces; may not
1172 always be appropriate */
1173 pIpForwardTable
->table
[ndx
].dwForwardType
= MIB_IPROUTE_TYPE_DIRECT
;
1174 /* FIXME: other protos might be appropriate, e.g. the default route
1175 is typically set with MIB_IPPROTO_NETMGMT instead */
1176 pIpForwardTable
->table
[ndx
].dwForwardProto
= MIB_IPPROTO_LOCAL
;
1177 /* punt on age and AS */
1178 pIpForwardTable
->table
[ndx
].dwForwardAge
= 0;
1179 pIpForwardTable
->table
[ndx
].dwForwardNextHopAS
= 0;
1180 pIpForwardTable
->table
[ndx
].dwForwardMetric1
=
1181 table
->routes
[ndx
].metric
;
1182 /* rest of the metrics are 0.. */
1183 pIpForwardTable
->table
[ndx
].dwForwardMetric2
= 0;
1184 pIpForwardTable
->table
[ndx
].dwForwardMetric3
= 0;
1185 pIpForwardTable
->table
[ndx
].dwForwardMetric4
= 0;
1186 pIpForwardTable
->table
[ndx
].dwForwardMetric5
= 0;
1189 qsort(pIpForwardTable
->table
, pIpForwardTable
->dwNumEntries
,
1190 sizeof(MIB_IPFORWARDROW
), IpForwardTableSorter
);
1196 ret
= ERROR_OUTOFMEMORY
;
1199 TRACE("returning %ld\n", ret
);
1204 static int IpNetTableSorter(const void *a
, const void *b
)
1209 ret
= ((PMIB_IPNETROW
)a
)->dwAddr
- ((PMIB_IPNETROW
)b
)->dwAddr
;
1216 /******************************************************************
1217 * GetIpNetTable (IPHLPAPI.@)
1222 * pIpNetTable [In/Out]
1231 DWORD WINAPI
GetIpNetTable(PMIB_IPNETTABLE pIpNetTable
, PULONG pdwSize
, BOOL bOrder
)
1235 TRACE("pIpNetTable %p, pdwSize %p, bOrder %ld\n", pIpNetTable
, pdwSize
,
1238 ret
= ERROR_INVALID_PARAMETER
;
1240 DWORD numEntries
= getNumArpEntries();
1241 ULONG size
= sizeof(MIB_IPNETTABLE
) + (numEntries
- 1) *
1242 sizeof(MIB_IPNETROW
);
1244 if (!pIpNetTable
|| *pdwSize
< size
) {
1246 ret
= ERROR_INSUFFICIENT_BUFFER
;
1249 PMIB_IPNETTABLE table
= getArpTable();
1252 size
= sizeof(MIB_IPNETTABLE
) + (table
->dwNumEntries
- 1) *
1253 sizeof(MIB_IPNETROW
);
1254 if (*pdwSize
< size
) {
1256 ret
= ERROR_INSUFFICIENT_BUFFER
;
1259 memcpy(pIpNetTable
, table
, size
);
1261 qsort(pIpNetTable
->table
, pIpNetTable
->dwNumEntries
,
1262 sizeof(MIB_IPNETROW
), IpNetTableSorter
);
1268 ret
= ERROR_OUTOFMEMORY
;
1271 TRACE("returning %ld\n", ret
);
1276 /******************************************************************
1277 * GetIpStatistics (IPHLPAPI.@)
1289 DWORD WINAPI
GetIpStatistics(PMIB_IPSTATS pStats
)
1291 return GetIpStatisticsEx(pStats
, PF_INET
);
1294 /******************************************************************
1295 * GetIpStatisticsEx (IPHLPAPI.@)
1308 DWORD WINAPI
GetIpStatisticsEx(PMIB_IPSTATS pStats
, DWORD dwFamily
)
1312 TRACE("pStats %p\n", pStats
);
1313 ret
= getIPStats(pStats
, dwFamily
);
1314 TRACE("returning %ld\n", ret
);
1318 /******************************************************************
1319 * GetNetworkParams (IPHLPAPI.@)
1324 * pFixedInfo [In/Out]
1325 * pOutBufLen [In/Out]
1332 DWORD WINAPI
GetNetworkParams(PFIXED_INFO pFixedInfo
, PULONG pOutBufLen
)
1337 PIPHLP_RES_INFO resInfo
;
1339 TRACE("pFixedInfo %p, pOutBufLen %p\n", pFixedInfo
, pOutBufLen
);
1341 return ERROR_INVALID_PARAMETER
;
1343 resInfo
= getResInfo();
1345 return ERROR_OUTOFMEMORY
;
1347 size
= sizeof(FIXED_INFO
) + (resInfo
->riCount
> 0 ? (resInfo
->riCount
- 1) *
1348 sizeof(IP_ADDR_STRING
) : 0);
1349 if (!pFixedInfo
|| *pOutBufLen
< size
) {
1351 disposeResInfo( resInfo
);
1352 return ERROR_BUFFER_OVERFLOW
;
1355 memset(pFixedInfo
, 0, size
);
1356 size
= sizeof(pFixedInfo
->HostName
);
1357 GetComputerNameExA(ComputerNameDnsHostname
, pFixedInfo
->HostName
, &size
);
1358 size
= sizeof(pFixedInfo
->DomainName
);
1359 GetComputerNameExA(ComputerNameDnsDomain
, pFixedInfo
->DomainName
, &size
);
1361 TRACE("GetComputerNameExA: %s\n", pFixedInfo
->DomainName
);
1363 if (resInfo
->riCount
> 0) {
1364 PIP_ADDR_STRING ptr
;
1367 for (i
= 0, ptr
= &pFixedInfo
->DnsServerList
; i
< resInfo
->riCount
&& ptr
;
1368 i
++, ptr
= ptr
->Next
) {
1369 struct sockaddr_in
*addr_v4
=
1370 (struct sockaddr_in
*)&resInfo
->riAddressList
[i
];
1372 (addr_v4
->sin_addr
.s_addr
,
1373 ptr
->IpAddress
.String
);
1374 if (i
== resInfo
->riCount
- 1)
1377 ptr
->Next
= (PIP_ADDR_STRING
)((LPBYTE
)pFixedInfo
+ sizeof(FIXED_INFO
));
1379 ptr
->Next
= (PIP_ADDR_STRING
)((PBYTE
)ptr
+ sizeof(IP_ADDR_STRING
));
1382 pFixedInfo
->NodeType
= HYBRID_NODETYPE
;
1383 regReturn
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
1384 "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", 0, KEY_READ
, &hKey
);
1385 if (regReturn
!= ERROR_SUCCESS
)
1386 regReturn
= RegOpenKeyExA(HKEY_LOCAL_MACHINE
,
1387 "SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ
,
1389 if (regReturn
== ERROR_SUCCESS
)
1391 DWORD size
= sizeof(pFixedInfo
->ScopeId
);
1393 RegQueryValueExA(hKey
, "ScopeID", NULL
, NULL
, pFixedInfo
->ScopeId
, &size
);
1397 disposeResInfo( resInfo
);
1398 /* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
1399 I suppose could also check for a listener on port 53 to set EnableDns */
1401 TRACE("returning %ld\n", ret
);
1407 /******************************************************************
1408 * GetNumberOfInterfaces (IPHLPAPI.@)
1420 DWORD WINAPI
GetNumberOfInterfaces(PDWORD pdwNumIf
)
1424 TRACE("pdwNumIf %p\n", pdwNumIf
);
1426 ret
= ERROR_INVALID_PARAMETER
;
1428 *pdwNumIf
= getNumInterfaces();
1431 TRACE("returning %ld\n", ret
);
1436 /******************************************************************
1437 * GetPerAdapterInfo (IPHLPAPI.@)
1443 * pPerAdapterInfo [In/Out]
1444 * pOutBufLen [In/Out]
1451 DWORD WINAPI
GetPerAdapterInfo(ULONG IfIndex
, PIP_PER_ADAPTER_INFO pPerAdapterInfo
, PULONG pOutBufLen
)
1453 TRACE("IfIndex %ld, pPerAdapterInfo %p, pOutBufLen %p\n", IfIndex
,
1454 pPerAdapterInfo
, pOutBufLen
);
1456 /* marking Win2K+ functions not supported */
1457 return ERROR_NOT_SUPPORTED
;
1461 /******************************************************************
1462 * GetRTTAndHopCount (IPHLPAPI.@)
1467 * DestIpAddress [In]
1477 BOOL WINAPI
GetRTTAndHopCount(IPAddr DestIpAddress
, PULONG HopCount
, ULONG MaxHops
, PULONG RTT
)
1479 TRACE("DestIpAddress 0x%08lx, HopCount %p, MaxHops %ld, RTT %p\n",
1480 DestIpAddress
, HopCount
, MaxHops
, RTT
);
1486 /******************************************************************
1487 * GetTcpStatisticsEx (IPHLPAPI.@)
1500 DWORD WINAPI
GetTcpStatisticsEx(PMIB_TCPSTATS pStats
, DWORD dwFamily
)
1504 TRACE("pStats %p\n", pStats
);
1505 ret
= getTCPStats(pStats
, dwFamily
);
1506 TRACE("returning %ld\n", ret
);
1510 /******************************************************************
1511 * GetTcpStatistics (IPHLPAPI.@)
1523 DWORD WINAPI
GetTcpStatistics(PMIB_TCPSTATS pStats
)
1525 return GetTcpStatisticsEx(pStats
, PF_INET
);
1529 static int TcpTableSorter(const void *a
, const void *b
)
1534 PMIB_TCPROW rowA
= (PMIB_TCPROW
)a
, rowB
= (PMIB_TCPROW
)b
;
1536 ret
= rowA
->dwLocalAddr
- rowB
->dwLocalAddr
;
1538 ret
= rowA
->dwLocalPort
- rowB
->dwLocalPort
;
1540 ret
= rowA
->dwRemoteAddr
- rowB
->dwRemoteAddr
;
1542 ret
= rowA
->dwRemotePort
- rowB
->dwRemotePort
;
1552 /******************************************************************
1553 * GetTcpTable (IPHLPAPI.@)
1558 * pTcpTable [In/Out]
1567 DWORD WINAPI
GetTcpTable(PMIB_TCPTABLE pTcpTable
, PDWORD pdwSize
, BOOL bOrder
)
1571 TRACE("pTcpTable %p, pdwSize %p, bOrder %ld\n", pTcpTable
, pdwSize
,
1574 ret
= ERROR_INVALID_PARAMETER
;
1576 DWORD numEntries
= getNumTcpEntries();
1577 ULONG size
= sizeof(MIB_TCPTABLE
) + (numEntries
- 1) * sizeof(MIB_TCPROW
);
1579 if (!pTcpTable
|| *pdwSize
< size
) {
1581 ret
= ERROR_INSUFFICIENT_BUFFER
;
1584 PMIB_TCPTABLE table
= getTcpTable();
1587 size
= sizeof(MIB_TCPTABLE
) + (table
->dwNumEntries
- 1) *
1589 if (*pdwSize
< size
) {
1591 ret
= ERROR_INSUFFICIENT_BUFFER
;
1594 memcpy(pTcpTable
, table
, size
);
1596 qsort(pTcpTable
->table
, pTcpTable
->dwNumEntries
,
1597 sizeof(MIB_TCPROW
), TcpTableSorter
);
1603 ret
= ERROR_OUTOFMEMORY
;
1606 TRACE("returning %ld\n", ret
);
1611 /******************************************************************
1612 * GetUdpStatisticsEx (IPHLPAPI.@)
1625 DWORD WINAPI
GetUdpStatisticsEx(PMIB_UDPSTATS pStats
, DWORD dwFamily
)
1629 TRACE("pStats %p\n", pStats
);
1630 ret
= getUDPStats(pStats
, dwFamily
);
1631 TRACE("returning %ld\n", ret
);
1635 /******************************************************************
1636 * GetUdpStatistics (IPHLPAPI.@)
1648 DWORD WINAPI
GetUdpStatistics(PMIB_UDPSTATS pStats
)
1650 return GetUdpStatisticsEx(pStats
, PF_INET
);
1654 static int UdpTableSorter(const void *a
, const void *b
)
1659 PMIB_UDPROW rowA
= (PMIB_UDPROW
)a
, rowB
= (PMIB_UDPROW
)b
;
1661 ret
= rowA
->dwLocalAddr
- rowB
->dwLocalAddr
;
1663 ret
= rowA
->dwLocalPort
- rowB
->dwLocalPort
;
1671 /******************************************************************
1672 * GetUdpTable (IPHLPAPI.@)
1677 * pUdpTable [In/Out]
1686 DWORD WINAPI
GetUdpTable(PMIB_UDPTABLE pUdpTable
, PDWORD pdwSize
, BOOL bOrder
)
1690 TRACE("pUdpTable %p, pdwSize %p, bOrder %ld\n", pUdpTable
, pdwSize
,
1693 ret
= ERROR_INVALID_PARAMETER
;
1695 DWORD numEntries
= getNumUdpEntries();
1696 ULONG size
= sizeof(MIB_UDPTABLE
) + (numEntries
- 1) * sizeof(MIB_UDPROW
);
1698 if (!pUdpTable
|| *pdwSize
< size
) {
1700 ret
= ERROR_INSUFFICIENT_BUFFER
;
1703 PMIB_UDPTABLE table
= getUdpTable();
1706 size
= sizeof(MIB_UDPTABLE
) + (table
->dwNumEntries
- 1) *
1708 if (*pdwSize
< size
) {
1710 ret
= ERROR_INSUFFICIENT_BUFFER
;
1713 memcpy(pUdpTable
, table
, size
);
1715 qsort(pUdpTable
->table
, pUdpTable
->dwNumEntries
,
1716 sizeof(MIB_UDPROW
), UdpTableSorter
);
1722 ret
= ERROR_OUTOFMEMORY
;
1725 TRACE("returning %ld\n", ret
);
1730 /******************************************************************
1731 * GetUniDirectionalAdapterInfo (IPHLPAPI.@)
1736 * pIPIfInfo [In/Out]
1737 * dwOutBufLen [In/Out]
1744 DWORD WINAPI
GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo
, PULONG dwOutBufLen
)
1746 TRACE("pIPIfInfo %p, dwOutBufLen %p\n", pIPIfInfo
, dwOutBufLen
);
1747 /* a unidirectional adapter?? not bloody likely! */
1748 return ERROR_NOT_SUPPORTED
;
1752 /******************************************************************
1753 * IpReleaseAddress (IPHLPAPI.@)
1758 * AdapterInfo [In/Out]
1765 DWORD WINAPI
IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo
)
1767 TRACE("AdapterInfo %p\n", AdapterInfo
);
1768 /* not a stub, never going to support this (and I never mark an adapter as
1769 DHCP enabled, see GetAdaptersInfo, so this should never get called) */
1770 return ERROR_NOT_SUPPORTED
;
1774 /******************************************************************
1775 * IpRenewAddress (IPHLPAPI.@)
1780 * AdapterInfo [In/Out]
1787 DWORD WINAPI
IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo
)
1789 TRACE("AdapterInfo %p\n", AdapterInfo
);
1790 /* not a stub, never going to support this (and I never mark an adapter as
1791 DHCP enabled, see GetAdaptersInfo, so this should never get called) */
1792 return ERROR_NOT_SUPPORTED
;
1796 /******************************************************************
1797 * NotifyAddrChange (IPHLPAPI.@)
1803 * overlapped [In/Out]
1810 DWORD WINAPI
NotifyAddrChange(PHANDLE Handle
, LPOVERLAPPED overlapped
)
1812 TRACE("Handle %p, overlapped %p\n", Handle
, overlapped
);
1814 /* marking Win2K+ functions not supported */
1815 return ERROR_NOT_SUPPORTED
;
1819 /******************************************************************
1820 * NotifyRouteChange (IPHLPAPI.@)
1826 * overlapped [In/Out]
1833 DWORD WINAPI
NotifyRouteChange(PHANDLE Handle
, LPOVERLAPPED overlapped
)
1835 TRACE("Handle %p, overlapped %p\n", Handle
, overlapped
);
1837 /* marking Win2K+ functions not supported */
1838 return ERROR_NOT_SUPPORTED
;
1842 /******************************************************************
1843 * SendARP (IPHLPAPI.@)
1851 * PhyAddrLen [In/Out]
1858 DWORD WINAPI
SendARP(IPAddr DestIP
, IPAddr SrcIP
, PULONG pMacAddr
, PULONG PhyAddrLen
)
1860 TRACE("DestIP 0x%08lx, SrcIP 0x%08lx, pMacAddr %p, PhyAddrLen %p\n", DestIP
,
1861 SrcIP
, pMacAddr
, PhyAddrLen
);
1863 /* marking Win2K+ functions not supported */
1864 return ERROR_NOT_SUPPORTED
;
1868 /******************************************************************
1869 * SetIfEntry (IPHLPAPI.@)
1881 DWORD WINAPI
SetIfEntry(PMIB_IFROW pIfRow
)
1883 TRACE("pIfRow %p\n", pIfRow
);
1884 /* this is supposed to set an administratively interface up or down.
1885 Could do SIOCSIFFLAGS and set/clear IFF_UP, but, not sure I want to, and
1886 this sort of down is indistinguishable from other sorts of down (e.g. no
1889 return ERROR_NOT_SUPPORTED
;
1893 /******************************************************************
1894 * SetIpForwardEntry (IPHLPAPI.@)
1906 DWORD WINAPI
SetIpForwardEntry(PMIB_IPFORWARDROW pRoute
)
1908 return setIpForwardEntry( pRoute
);
1912 /******************************************************************
1913 * SetIpNetEntry (IPHLPAPI.@)
1918 * pArpEntry [In/Out]
1925 DWORD WINAPI
SetIpNetEntry(PMIB_IPNETROW pArpEntry
)
1927 TRACE("pArpEntry %p\n", pArpEntry
);
1928 /* same as CreateIpNetEntry here, could use SIOCSARP, not sure I want to */
1934 /******************************************************************
1935 * SetIpStatistics (IPHLPAPI.@)
1947 DWORD WINAPI
SetIpStatistics(PMIB_IPSTATS pIpStats
)
1949 TRACE("pIpStats %p\n", pIpStats
);
1955 /******************************************************************
1956 * SetIpTTL (IPHLPAPI.@)
1968 DWORD WINAPI
SetIpTTL(UINT nTTL
)
1970 TRACE("nTTL %d\n", nTTL
);
1971 /* could echo nTTL > /proc/net/sys/net/ipv4/ip_default_ttl, not sure I
1972 want to. Could map EACCESS to ERROR_ACCESS_DENIED, I suppose */
1978 /******************************************************************
1979 * SetTcpEntry (IPHLPAPI.@)
1991 DWORD WINAPI
SetTcpEntry(PMIB_TCPROW pTcpRow
)
1993 TRACE("pTcpRow %p\n", pTcpRow
);
1999 /******************************************************************
2000 * UnenableRouter (IPHLPAPI.@)
2005 * pOverlapped [In/Out]
2006 * lpdwEnableCount [In/Out]
2013 DWORD WINAPI
UnenableRouter(OVERLAPPED
* pOverlapped
, LPDWORD lpdwEnableCount
)
2015 TRACE("pOverlapped %p, lpdwEnableCount %p\n", pOverlapped
, lpdwEnableCount
);
2017 /* could echo "0" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
2018 could map EACCESS to ERROR_ACCESS_DENIED, I suppose
2019 marking Win2K+ functions not supported */
2020 return ERROR_NOT_SUPPORTED
;
2026 DWORD WINAPI
GetIpErrorString(IP_STATUS ErrorCode
,PWCHAR Buffer
,PDWORD Size
)
2036 PIP_ADAPTER_ORDER_MAP WINAPI
GetAdapterOrderMap(VOID
)
2045 DWORD WINAPI
GetAdaptersAddresses(ULONG Family
,DWORD Flags
,PVOID Reserved
,PIP_ADAPTER_ADDRESSES pAdapterAddresses
,PULONG pOutBufLen
)
2054 BOOL WINAPI
CancelIPChangeNotify(LPOVERLAPPED notifyOverlapped
)
2063 DWORD WINAPI
GetBestInterfaceEx(struct sockaddr
*pDestAddr
,PDWORD pdwBestIfIndex
)
2072 DWORD WINAPI
NhpAllocateAndGetInterfaceInfoFromStack(IP_INTERFACE_NAME_INFO
**ppTable
,PDWORD pdwCount
,BOOL bOrder
,HANDLE hHeap
,DWORD dwFlags
)
2081 DWORD WINAPI
GetIcmpStatisticsEx(PMIB_ICMP_EX pStats
,DWORD dwFamily
)