2003-05-13 05:32:20 +02:00
|
|
|
/*
|
|
|
|
* iphlpapi dll implementation
|
|
|
|
*
|
2006-01-25 13:14:12 +01:00
|
|
|
* Copyright (C) 2003,2006 Juan Lang
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2003-05-13 05:32:20 +02:00
|
|
|
#include <stdlib.h>
|
2003-05-14 01:37:29 +02:00
|
|
|
#include <sys/types.h>
|
2003-05-19 23:41:00 +02:00
|
|
|
#ifdef HAVE_NETINET_IN_H
|
2003-08-08 23:07:23 +02:00
|
|
|
# include <netinet/in.h>
|
2003-05-19 23:41:00 +02:00
|
|
|
#endif
|
2004-01-02 04:55:05 +01:00
|
|
|
#ifdef HAVE_ARPA_INET_H
|
|
|
|
# include <arpa/inet.h>
|
|
|
|
#endif
|
2003-05-19 23:41:00 +02:00
|
|
|
#ifdef HAVE_ARPA_NAMESER_H
|
2003-08-08 23:07:23 +02:00
|
|
|
# include <arpa/nameser.h>
|
2003-05-19 23:41:00 +02:00
|
|
|
#endif
|
2003-08-08 23:07:23 +02:00
|
|
|
#ifdef HAVE_RESOLV_H
|
|
|
|
# include <resolv.h>
|
|
|
|
#endif
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2003-05-13 05:32:20 +02:00
|
|
|
#include "winbase.h"
|
2003-09-08 21:00:25 +02:00
|
|
|
#include "winreg.h"
|
2003-05-13 05:32:20 +02:00
|
|
|
#include "iphlpapi.h"
|
|
|
|
#include "ifenum.h"
|
|
|
|
#include "ipstats.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
|
|
|
|
|
2004-01-15 01:25:41 +01:00
|
|
|
#ifndef INADDR_NONE
|
|
|
|
#define INADDR_NONE ~0UL
|
|
|
|
#endif
|
|
|
|
|
2007-04-18 20:39:33 +02:00
|
|
|
static int resolver_initialised;
|
|
|
|
|
2007-04-30 02:06:11 +02:00
|
|
|
/* call res_init() just once because of a bug in Mac OS X 10.4 */
|
2007-04-18 20:39:33 +02:00
|
|
|
static void initialise_resolver(void)
|
|
|
|
{
|
|
|
|
if (!resolver_initialised)
|
|
|
|
{
|
|
|
|
res_init();
|
|
|
|
resolver_initialised = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-30 07:03:21 +01:00
|
|
|
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
|
|
|
switch (fdwReason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls( hinstDLL );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-05-13 05:32:20 +02:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* AddIPAddress (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Add an IP address to an adapter.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Address [In] IP address to add to the adapter
|
|
|
|
* IpMask [In] subnet mask for the IP address
|
|
|
|
* IfIndex [In] adapter index to add the address
|
|
|
|
* NTEContext [Out] Net Table Entry (NTE) context for the IP address
|
|
|
|
* NTEInstance [Out] NTE instance for the IP address
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub. Currently returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI AddIPAddress(IPAddr Address, IPMask IpMask, DWORD IfIndex, PULONG NTEContext, PULONG NTEInstance)
|
|
|
|
{
|
|
|
|
FIXME(":stub\n");
|
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-08 21:00:25 +02:00
|
|
|
/******************************************************************
|
|
|
|
* AllocateAndGetIfTableFromStack (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get table of local interfaces.
|
|
|
|
* Like GetIfTable(), but allocate the returned table from heap.
|
2003-09-08 21:00:25 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* ppIfTable [Out] pointer into which the MIB_IFTABLE is
|
|
|
|
* allocated and returned.
|
2006-01-24 12:18:50 +01:00
|
|
|
* bOrder [In] whether to sort the table
|
2005-11-14 12:24:37 +01:00
|
|
|
* heap [In] heap from which the table is allocated
|
|
|
|
* flags [In] flags to HeapAlloc
|
2003-09-08 21:00:25 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* RETURNS
|
|
|
|
* ERROR_INVALID_PARAMETER if ppIfTable is NULL, whatever
|
|
|
|
* GetIfTable() returns otherwise.
|
2003-09-08 21:00:25 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI AllocateAndGetIfTableFromStack(PMIB_IFTABLE *ppIfTable,
|
|
|
|
BOOL bOrder, HANDLE heap, DWORD flags)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("ppIfTable %p, bOrder %d, heap %p, flags 0x%08x\n", ppIfTable,
|
2005-09-12 12:30:05 +02:00
|
|
|
bOrder, heap, flags);
|
2003-09-08 21:00:25 +02:00
|
|
|
if (!ppIfTable)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else {
|
|
|
|
DWORD dwSize = 0;
|
|
|
|
|
|
|
|
ret = GetIfTable(*ppIfTable, &dwSize, bOrder);
|
|
|
|
if (ret == ERROR_INSUFFICIENT_BUFFER) {
|
2005-03-24 22:01:35 +01:00
|
|
|
*ppIfTable = HeapAlloc(heap, flags, dwSize);
|
2003-09-08 21:00:25 +02:00
|
|
|
ret = GetIfTable(*ppIfTable, &dwSize, bOrder);
|
|
|
|
}
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-09-08 21:00:25 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-24 12:18:50 +01:00
|
|
|
static int IpAddrTableSorter(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (a && b)
|
|
|
|
ret = ((const MIB_IPADDRROW*)a)->dwAddr - ((const MIB_IPADDRROW*)b)->dwAddr;
|
|
|
|
else
|
|
|
|
ret = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-08 21:00:25 +02:00
|
|
|
/******************************************************************
|
|
|
|
* AllocateAndGetIpAddrTableFromStack (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get interface-to-IP address mapping table.
|
|
|
|
* Like GetIpAddrTable(), but allocate the returned table from heap.
|
2003-09-08 21:00:25 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* ppIpAddrTable [Out] pointer into which the MIB_IPADDRTABLE is
|
|
|
|
* allocated and returned.
|
2006-01-24 12:18:50 +01:00
|
|
|
* bOrder [In] whether to sort the table
|
2005-11-14 12:24:37 +01:00
|
|
|
* heap [In] heap from which the table is allocated
|
|
|
|
* flags [In] flags to HeapAlloc
|
2003-09-08 21:00:25 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2006-01-24 12:18:50 +01:00
|
|
|
* ERROR_INVALID_PARAMETER if ppIpAddrTable is NULL, other error codes on
|
|
|
|
* failure, NO_ERROR on success.
|
2003-09-08 21:00:25 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI AllocateAndGetIpAddrTableFromStack(PMIB_IPADDRTABLE *ppIpAddrTable,
|
|
|
|
BOOL bOrder, HANDLE heap, DWORD flags)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("ppIpAddrTable %p, bOrder %d, heap %p, flags 0x%08x\n",
|
2005-09-12 12:30:05 +02:00
|
|
|
ppIpAddrTable, bOrder, heap, flags);
|
2006-01-24 12:18:50 +01:00
|
|
|
ret = getIPAddrTable(ppIpAddrTable, heap, flags);
|
|
|
|
if (!ret && bOrder)
|
|
|
|
qsort((*ppIpAddrTable)->table, (*ppIpAddrTable)->dwNumEntries,
|
|
|
|
sizeof(MIB_IPADDRROW), IpAddrTableSorter);
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2006-01-24 12:18:50 +01:00
|
|
|
return ret;
|
|
|
|
}
|
2003-09-08 21:00:25 +02:00
|
|
|
|
2006-01-24 12:18:50 +01:00
|
|
|
|
|
|
|
static int IpForwardTableSorter(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (a && b) {
|
|
|
|
const MIB_IPFORWARDROW* rowA = (const MIB_IPFORWARDROW*)a;
|
|
|
|
const MIB_IPFORWARDROW* rowB = (const MIB_IPFORWARDROW*)b;
|
|
|
|
|
|
|
|
ret = rowA->dwForwardDest - rowB->dwForwardDest;
|
|
|
|
if (ret == 0) {
|
|
|
|
ret = rowA->dwForwardProto - rowB->dwForwardProto;
|
|
|
|
if (ret == 0) {
|
|
|
|
ret = rowA->dwForwardPolicy - rowB->dwForwardPolicy;
|
|
|
|
if (ret == 0)
|
|
|
|
ret = rowA->dwForwardNextHop - rowB->dwForwardNextHop;
|
|
|
|
}
|
2003-09-08 21:00:25 +02:00
|
|
|
}
|
|
|
|
}
|
2006-01-24 12:18:50 +01:00
|
|
|
else
|
|
|
|
ret = 0;
|
2003-09-08 21:00:25 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* AllocateAndGetIpForwardTableFromStack (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the route table.
|
|
|
|
* Like GetIpForwardTable(), but allocate the returned table from heap.
|
2004-12-13 14:21:39 +01:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* ppIpForwardTable [Out] pointer into which the MIB_IPFORWARDTABLE is
|
|
|
|
* allocated and returned.
|
2006-01-24 12:18:50 +01:00
|
|
|
* bOrder [In] whether to sort the table
|
2005-11-14 12:24:37 +01:00
|
|
|
* heap [In] heap from which the table is allocated
|
|
|
|
* flags [In] flags to HeapAlloc
|
2003-09-08 21:00:25 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* RETURNS
|
2006-01-24 12:18:50 +01:00
|
|
|
* ERROR_INVALID_PARAMETER if ppIfTable is NULL, other error codes
|
|
|
|
* on failure, NO_ERROR on success.
|
2003-09-08 21:00:25 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *
|
|
|
|
ppIpForwardTable, BOOL bOrder, HANDLE heap, DWORD flags)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("ppIpForwardTable %p, bOrder %d, heap %p, flags 0x%08x\n",
|
2005-09-12 12:30:05 +02:00
|
|
|
ppIpForwardTable, bOrder, heap, flags);
|
2006-01-24 12:18:50 +01:00
|
|
|
ret = getRouteTable(ppIpForwardTable, heap, flags);
|
|
|
|
if (!ret && bOrder)
|
|
|
|
qsort((*ppIpForwardTable)->table, (*ppIpForwardTable)->dwNumEntries,
|
|
|
|
sizeof(MIB_IPFORWARDROW), IpForwardTableSorter);
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-09-08 21:00:25 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-01-24 12:18:50 +01:00
|
|
|
static int IpNetTableSorter(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (a && b)
|
|
|
|
ret = ((const MIB_IPNETROW*)a)->dwAddr - ((const MIB_IPNETROW*)b)->dwAddr;
|
|
|
|
else
|
|
|
|
ret = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-08 21:00:25 +02:00
|
|
|
/******************************************************************
|
|
|
|
* AllocateAndGetIpNetTableFromStack (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the IP-to-physical address mapping table.
|
|
|
|
* Like GetIpNetTable(), but allocate the returned table from heap.
|
2003-09-08 21:00:25 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* ppIpNetTable [Out] pointer into which the MIB_IPNETTABLE is
|
|
|
|
* allocated and returned.
|
2006-01-24 12:18:50 +01:00
|
|
|
* bOrder [In] whether to sort the table
|
2005-11-14 12:24:37 +01:00
|
|
|
* heap [In] heap from which the table is allocated
|
|
|
|
* flags [In] flags to HeapAlloc
|
2003-09-08 21:00:25 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2006-01-24 12:18:50 +01:00
|
|
|
* ERROR_INVALID_PARAMETER if ppIpNetTable is NULL, other error codes
|
|
|
|
* on failure, NO_ERROR on success.
|
2003-09-08 21:00:25 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable,
|
|
|
|
BOOL bOrder, HANDLE heap, DWORD flags)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("ppIpNetTable %p, bOrder %d, heap %p, flags 0x%08x\n",
|
2005-09-12 12:30:05 +02:00
|
|
|
ppIpNetTable, bOrder, heap, flags);
|
2006-01-24 12:18:50 +01:00
|
|
|
ret = getArpTable(ppIpNetTable, heap, flags);
|
|
|
|
if (!ret && bOrder)
|
|
|
|
qsort((*ppIpNetTable)->table, (*ppIpNetTable)->dwNumEntries,
|
|
|
|
sizeof(MIB_IPADDRROW), IpNetTableSorter);
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2006-01-24 12:18:50 +01:00
|
|
|
return ret;
|
|
|
|
}
|
2003-09-08 21:00:25 +02:00
|
|
|
|
2006-01-24 12:18:50 +01:00
|
|
|
|
|
|
|
static int TcpTableSorter(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (a && b) {
|
|
|
|
const MIB_TCPROW* rowA = a;
|
|
|
|
const MIB_TCPROW* rowB = b;
|
|
|
|
|
2007-07-11 06:16:37 +02:00
|
|
|
ret = ntohl (rowA->dwLocalAddr) - ntohl (rowB->dwLocalAddr);
|
2006-01-24 12:18:50 +01:00
|
|
|
if (ret == 0) {
|
2007-07-11 06:16:37 +02:00
|
|
|
ret = ntohs ((unsigned short)rowA->dwLocalPort) -
|
|
|
|
ntohs ((unsigned short)rowB->dwLocalPort);
|
2006-01-24 12:18:50 +01:00
|
|
|
if (ret == 0) {
|
2007-07-11 06:16:37 +02:00
|
|
|
ret = ntohl (rowA->dwRemoteAddr) - ntohl (rowB->dwRemoteAddr);
|
2006-01-24 12:18:50 +01:00
|
|
|
if (ret == 0)
|
2007-07-11 06:16:37 +02:00
|
|
|
ret = ntohs ((unsigned short)rowA->dwRemotePort) -
|
|
|
|
ntohs ((unsigned short)rowB->dwRemotePort);
|
2006-01-24 12:18:50 +01:00
|
|
|
}
|
2003-09-08 21:00:25 +02:00
|
|
|
}
|
|
|
|
}
|
2006-01-24 12:18:50 +01:00
|
|
|
else
|
|
|
|
ret = 0;
|
2003-09-08 21:00:25 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* AllocateAndGetTcpTableFromStack (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the TCP connection table.
|
|
|
|
* Like GetTcpTable(), but allocate the returned table from heap.
|
2003-09-08 21:00:25 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* ppTcpTable [Out] pointer into which the MIB_TCPTABLE is
|
|
|
|
* allocated and returned.
|
2006-01-24 12:18:50 +01:00
|
|
|
* bOrder [In] whether to sort the table
|
2005-11-14 12:24:37 +01:00
|
|
|
* heap [In] heap from which the table is allocated
|
|
|
|
* flags [In] flags to HeapAlloc
|
2003-09-08 21:00:25 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* ERROR_INVALID_PARAMETER if ppTcpTable is NULL, whatever GetTcpTable()
|
|
|
|
* returns otherwise.
|
2003-09-08 21:00:25 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI AllocateAndGetTcpTableFromStack(PMIB_TCPTABLE *ppTcpTable,
|
|
|
|
BOOL bOrder, HANDLE heap, DWORD flags)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("ppTcpTable %p, bOrder %d, heap %p, flags 0x%08x\n",
|
2005-09-12 12:30:05 +02:00
|
|
|
ppTcpTable, bOrder, heap, flags);
|
2007-07-11 05:39:21 +02:00
|
|
|
|
|
|
|
*ppTcpTable = NULL;
|
|
|
|
ret = getTcpTable(ppTcpTable, 0, heap, flags);
|
2006-01-24 12:18:50 +01:00
|
|
|
if (!ret && bOrder)
|
|
|
|
qsort((*ppTcpTable)->table, (*ppTcpTable)->dwNumEntries,
|
|
|
|
sizeof(MIB_TCPROW), TcpTableSorter);
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2006-01-24 12:18:50 +01:00
|
|
|
return ret;
|
|
|
|
}
|
2003-09-08 21:00:25 +02:00
|
|
|
|
2006-01-24 12:18:50 +01:00
|
|
|
|
|
|
|
static int UdpTableSorter(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (a && b) {
|
|
|
|
const MIB_UDPROW* rowA = (const MIB_UDPROW*)a;
|
|
|
|
const MIB_UDPROW* rowB = (const MIB_UDPROW*)b;
|
|
|
|
|
|
|
|
ret = rowA->dwLocalAddr - rowB->dwLocalAddr;
|
|
|
|
if (ret == 0)
|
|
|
|
ret = rowA->dwLocalPort - rowB->dwLocalPort;
|
2003-09-08 21:00:25 +02:00
|
|
|
}
|
2006-01-24 12:18:50 +01:00
|
|
|
else
|
|
|
|
ret = 0;
|
2003-09-08 21:00:25 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* AllocateAndGetUdpTableFromStack (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the UDP listener table.
|
|
|
|
* Like GetUdpTable(), but allocate the returned table from heap.
|
2003-09-08 21:00:25 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* ppUdpTable [Out] pointer into which the MIB_UDPTABLE is
|
|
|
|
* allocated and returned.
|
2006-01-24 12:18:50 +01:00
|
|
|
* bOrder [In] whether to sort the table
|
2005-11-14 12:24:37 +01:00
|
|
|
* heap [In] heap from which the table is allocated
|
|
|
|
* flags [In] flags to HeapAlloc
|
2003-09-08 21:00:25 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* ERROR_INVALID_PARAMETER if ppUdpTable is NULL, whatever GetUdpTable()
|
|
|
|
* returns otherwise.
|
2003-09-08 21:00:25 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI AllocateAndGetUdpTableFromStack(PMIB_UDPTABLE *ppUdpTable,
|
|
|
|
BOOL bOrder, HANDLE heap, DWORD flags)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("ppUdpTable %p, bOrder %d, heap %p, flags 0x%08x\n",
|
2005-09-12 12:30:05 +02:00
|
|
|
ppUdpTable, bOrder, heap, flags);
|
2006-01-24 12:18:50 +01:00
|
|
|
ret = getUdpTable(ppUdpTable, heap, flags);
|
|
|
|
if (!ret && bOrder)
|
|
|
|
qsort((*ppUdpTable)->table, (*ppUdpTable)->dwNumEntries,
|
|
|
|
sizeof(MIB_UDPROW), UdpTableSorter);
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-09-08 21:00:25 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-13 05:32:20 +02:00
|
|
|
/******************************************************************
|
|
|
|
* CreateIpForwardEntry (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Create a route in the local computer's IP table.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pRoute [In] new route information
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
2005-11-23 20:14:43 +01:00
|
|
|
* Stub, always returns NO_ERROR.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI CreateIpForwardEntry(PMIB_IPFORWARDROW pRoute)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(pRoute %p): stub\n", pRoute);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* could use SIOCADDRT, not sure I want to */
|
|
|
|
return (DWORD) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* CreateIpNetEntry (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Create entry in the ARP table.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pArpEntry [In] new ARP entry
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
2005-11-23 20:14:43 +01:00
|
|
|
* Stub, always returns NO_ERROR.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI CreateIpNetEntry(PMIB_IPNETROW pArpEntry)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(pArpEntry %p)\n", pArpEntry);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* could use SIOCSARP on systems that support it, not sure I want to */
|
|
|
|
return (DWORD) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* CreateProxyArpEntry (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Create a Proxy ARP (PARP) entry for an IP address.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* dwAddress [In] IP address for which this computer acts as a proxy.
|
|
|
|
* dwMask [In] subnet mask for dwAddress
|
|
|
|
* dwIfIndex [In] interface index
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI CreateProxyArpEntry(DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
|
|
|
|
{
|
2006-10-07 20:18:10 +02:00
|
|
|
FIXME("(dwAddress 0x%08x, dwMask 0x%08x, dwIfIndex 0x%08x): stub\n",
|
2004-12-13 14:21:39 +01:00
|
|
|
dwAddress, dwMask, dwIfIndex);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* DeleteIPAddress (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Delete an IP address added with AddIPAddress().
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* NTEContext [In] NTE context from AddIPAddress();
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI DeleteIPAddress(ULONG NTEContext)
|
|
|
|
{
|
2006-10-07 20:18:10 +02:00
|
|
|
FIXME("(NTEContext %d): stub\n", NTEContext);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* DeleteIpForwardEntry (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Delete a route.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pRoute [In] route to delete
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns NO_ERROR.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI DeleteIpForwardEntry(PMIB_IPFORWARDROW pRoute)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(pRoute %p): stub\n", pRoute);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* could use SIOCDELRT, not sure I want to */
|
|
|
|
return (DWORD) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* DeleteIpNetEntry (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Delete an ARP entry.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pArpEntry [In] ARP entry to delete
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns NO_ERROR.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI DeleteIpNetEntry(PMIB_IPNETROW pArpEntry)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(pArpEntry %p): stub\n", pArpEntry);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* could use SIOCDARP on systems that support it, not sure I want to */
|
|
|
|
return (DWORD) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* DeleteProxyArpEntry (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Delete a Proxy ARP entry.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* dwAddress [In] IP address for which this computer acts as a proxy.
|
|
|
|
* dwMask [In] subnet mask for dwAddress
|
|
|
|
* dwIfIndex [In] interface index
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI DeleteProxyArpEntry(DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
|
|
|
|
{
|
2006-10-07 20:18:10 +02:00
|
|
|
FIXME("(dwAddress 0x%08x, dwMask 0x%08x, dwIfIndex 0x%08x): stub\n",
|
2004-12-13 14:21:39 +01:00
|
|
|
dwAddress, dwMask, dwIfIndex);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* EnableRouter (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Turn on ip forwarding.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pHandle [In/Out]
|
|
|
|
* pOverlapped [In/Out] hEvent member should contain a valid handle.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: ERROR_IO_PENDING
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI EnableRouter(HANDLE * pHandle, OVERLAPPED * pOverlapped)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(pHandle %p, pOverlapped %p): stub\n", pHandle, pOverlapped);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* could echo "1" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
|
|
|
|
could map EACCESS to ERROR_ACCESS_DENIED, I suppose
|
2006-01-20 16:16:56 +01:00
|
|
|
*/
|
2003-05-13 05:32:20 +02:00
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* FlushIpNetTable (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Delete all ARP entries of an interface
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* dwIfIndex [In] interface index
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI FlushIpNetTable(DWORD dwIfIndex)
|
|
|
|
{
|
2006-10-07 20:18:10 +02:00
|
|
|
FIXME("(dwIfIndex 0x%08x): stub\n", dwIfIndex);
|
2006-01-20 16:16:56 +01:00
|
|
|
/* this flushes the arp cache of the given index */
|
2003-05-13 05:32:20 +02:00
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetAdapterIndex (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get interface index from its name.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* AdapterName [In] unicode string with the adapter name
|
|
|
|
* IfIndex [Out] returns found interface index
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetAdapterIndex(LPWSTR AdapterName, PULONG IfIndex)
|
|
|
|
{
|
2007-10-14 01:39:10 +02:00
|
|
|
char adapterName[MAX_ADAPTER_NAME];
|
|
|
|
int i;
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
TRACE("(AdapterName %p, IfIndex %p)\n", AdapterName, IfIndex);
|
|
|
|
/* The adapter name is guaranteed not to have any unicode characters, so
|
|
|
|
* this translation is never lossy */
|
|
|
|
for (i = 0; i < sizeof(adapterName) - 1 && AdapterName[i]; i++)
|
|
|
|
adapterName[i] = (char)AdapterName[i];
|
|
|
|
adapterName[i] = '\0';
|
|
|
|
ret = getInterfaceIndexByName(adapterName, IfIndex);
|
|
|
|
TRACE("returning %d\n", ret);
|
|
|
|
return ret;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetAdaptersInfo (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get information about adapters.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* PARAMS
|
|
|
|
* pAdapterInfo [Out] buffer for adapter infos
|
|
|
|
* pOutBufLen [In] length of output buffer
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2004-01-02 04:55:05 +01:00
|
|
|
TRACE("pAdapterInfo %p, pOutBufLen %p\n", pAdapterInfo, pOutBufLen);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pOutBufLen)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else {
|
|
|
|
DWORD numNonLoopbackInterfaces = getNumNonLoopbackInterfaces();
|
|
|
|
|
|
|
|
if (numNonLoopbackInterfaces > 0) {
|
2006-01-25 13:14:12 +01:00
|
|
|
DWORD numIPAddresses = getNumIPAddresses();
|
|
|
|
ULONG size;
|
|
|
|
|
|
|
|
/* This may slightly overestimate the amount of space needed, because
|
|
|
|
* the IP addresses include the loopback address, but it's easier
|
|
|
|
* to make sure there's more than enough space than to make sure there's
|
|
|
|
* precisely enough space.
|
|
|
|
*/
|
|
|
|
size = sizeof(IP_ADAPTER_INFO) * numNonLoopbackInterfaces;
|
2006-01-30 18:16:22 +01:00
|
|
|
size += numIPAddresses * sizeof(IP_ADDR_STRING);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pAdapterInfo || *pOutBufLen < size) {
|
|
|
|
*pOutBufLen = size;
|
|
|
|
ret = ERROR_BUFFER_OVERFLOW;
|
|
|
|
}
|
|
|
|
else {
|
2006-01-25 13:14:12 +01:00
|
|
|
InterfaceIndexTable *table = NULL;
|
|
|
|
PMIB_IPADDRTABLE ipAddrTable = NULL;
|
2007-10-14 01:21:20 +02:00
|
|
|
PMIB_IPFORWARDTABLE routeTable = NULL;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2006-01-25 13:14:12 +01:00
|
|
|
ret = getIPAddrTable(&ipAddrTable, GetProcessHeap(), 0);
|
2007-10-14 01:21:20 +02:00
|
|
|
if (!ret)
|
|
|
|
ret = getRouteTable(&routeTable, GetProcessHeap(), 0);
|
2006-01-25 13:14:12 +01:00
|
|
|
if (!ret)
|
|
|
|
table = getNonLoopbackInterfaceIndexTable();
|
2003-05-13 05:32:20 +02:00
|
|
|
if (table) {
|
|
|
|
size = sizeof(IP_ADAPTER_INFO) * table->numIndexes;
|
2006-01-30 18:16:22 +01:00
|
|
|
size += ipAddrTable->dwNumEntries * sizeof(IP_ADDR_STRING);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (*pOutBufLen < size) {
|
|
|
|
*pOutBufLen = size;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
DWORD ndx;
|
2004-01-02 04:55:05 +01:00
|
|
|
HKEY hKey;
|
|
|
|
BOOL winsEnabled = FALSE;
|
|
|
|
IP_ADDRESS_STRING primaryWINS, secondaryWINS;
|
2006-01-25 13:14:12 +01:00
|
|
|
PIP_ADDR_STRING nextIPAddr = (PIP_ADDR_STRING)((LPBYTE)pAdapterInfo
|
|
|
|
+ numNonLoopbackInterfaces * sizeof(IP_ADAPTER_INFO));
|
2003-05-13 05:32:20 +02:00
|
|
|
|
|
|
|
memset(pAdapterInfo, 0, size);
|
2005-06-14 19:22:41 +02:00
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\Network */
|
2006-01-25 13:14:12 +01:00
|
|
|
if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Network",
|
|
|
|
&hKey) == ERROR_SUCCESS) {
|
2004-01-02 04:55:05 +01:00
|
|
|
DWORD size = sizeof(primaryWINS.String);
|
|
|
|
unsigned long addr;
|
|
|
|
|
|
|
|
RegQueryValueExA(hKey, "WinsServer", NULL, NULL,
|
2005-07-07 14:08:42 +02:00
|
|
|
(LPBYTE)primaryWINS.String, &size);
|
2004-01-02 04:55:05 +01:00
|
|
|
addr = inet_addr(primaryWINS.String);
|
|
|
|
if (addr != INADDR_NONE && addr != INADDR_ANY)
|
|
|
|
winsEnabled = TRUE;
|
|
|
|
size = sizeof(secondaryWINS.String);
|
|
|
|
RegQueryValueExA(hKey, "BackupWinsServer", NULL, NULL,
|
2005-07-07 14:08:42 +02:00
|
|
|
(LPBYTE)secondaryWINS.String, &size);
|
2004-01-02 04:55:05 +01:00
|
|
|
addr = inet_addr(secondaryWINS.String);
|
|
|
|
if (addr != INADDR_NONE && addr != INADDR_ANY)
|
|
|
|
winsEnabled = TRUE;
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
2003-05-13 05:32:20 +02:00
|
|
|
for (ndx = 0; ndx < table->numIndexes; ndx++) {
|
|
|
|
PIP_ADAPTER_INFO ptr = &pAdapterInfo[ndx];
|
2007-10-14 01:25:36 +02:00
|
|
|
DWORD i;
|
2006-01-25 13:14:12 +01:00
|
|
|
PIP_ADDR_STRING currentIPAddr = &ptr->IpAddressList;
|
|
|
|
BOOL firstIPAddr = TRUE;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
|
|
|
/* on Win98 this is left empty, but whatever */
|
2006-01-27 19:19:32 +01:00
|
|
|
getInterfaceNameByIndex(table->indexes[ndx], ptr->AdapterName);
|
2007-10-14 01:25:36 +02:00
|
|
|
getInterfacePhysicalByIndex(table->indexes[ndx],
|
|
|
|
&ptr->AddressLength, ptr->Address, &ptr->Type);
|
2003-05-13 05:32:20 +02:00
|
|
|
ptr->Index = table->indexes[ndx];
|
2006-01-25 13:14:12 +01:00
|
|
|
for (i = 0; i < ipAddrTable->dwNumEntries; i++) {
|
|
|
|
if (ipAddrTable->table[i].dwIndex == ptr->Index) {
|
|
|
|
if (firstIPAddr) {
|
|
|
|
toIPAddressString(ipAddrTable->table[i].dwAddr,
|
|
|
|
ptr->IpAddressList.IpAddress.String);
|
2006-10-27 16:03:06 +02:00
|
|
|
toIPAddressString(ipAddrTable->table[i].dwMask,
|
2006-01-25 13:14:12 +01:00
|
|
|
ptr->IpAddressList.IpMask.String);
|
|
|
|
firstIPAddr = FALSE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
currentIPAddr->Next = nextIPAddr;
|
|
|
|
currentIPAddr = nextIPAddr;
|
|
|
|
toIPAddressString(ipAddrTable->table[i].dwAddr,
|
|
|
|
currentIPAddr->IpAddress.String);
|
2006-10-27 16:03:06 +02:00
|
|
|
toIPAddressString(ipAddrTable->table[i].dwMask,
|
2006-01-25 13:14:12 +01:00
|
|
|
currentIPAddr->IpMask.String);
|
|
|
|
nextIPAddr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-14 01:21:20 +02:00
|
|
|
/* Find first router through this interface, which we'll assume
|
|
|
|
* is the default gateway for this adapter */
|
|
|
|
for (i = 0; i < routeTable->dwNumEntries; i++)
|
|
|
|
if (routeTable->table[i].dwForwardIfIndex == ptr->Index
|
|
|
|
&& routeTable->table[i].dwForwardType ==
|
|
|
|
MIB_IPROUTE_TYPE_INDIRECT)
|
|
|
|
toIPAddressString(routeTable->table[i].dwForwardNextHop,
|
|
|
|
ptr->GatewayList.IpAddress.String);
|
2004-01-02 04:55:05 +01:00
|
|
|
if (winsEnabled) {
|
|
|
|
ptr->HaveWins = TRUE;
|
|
|
|
memcpy(ptr->PrimaryWinsServer.IpAddress.String,
|
|
|
|
primaryWINS.String, sizeof(primaryWINS.String));
|
|
|
|
memcpy(ptr->SecondaryWinsServer.IpAddress.String,
|
|
|
|
secondaryWINS.String, sizeof(secondaryWINS.String));
|
|
|
|
}
|
2003-10-31 05:16:54 +01:00
|
|
|
if (ndx < table->numIndexes - 1)
|
|
|
|
ptr->Next = &pAdapterInfo[ndx + 1];
|
|
|
|
else
|
|
|
|
ptr->Next = NULL;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
ret = NO_ERROR;
|
|
|
|
}
|
2004-12-13 14:21:39 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, table);
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = ERROR_OUTOFMEMORY;
|
2007-10-14 01:21:20 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, routeTable);
|
2006-05-10 00:33:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, ipAddrTable);
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = ERROR_NO_DATA;
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetBestInterface (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the interface, with the best route for the given IP address.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* PARAMS
|
|
|
|
* dwDestAddr [In] IP address to search the interface for
|
|
|
|
* pdwBestIfIndex [Out] found best interface
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetBestInterface(IPAddr dwDestAddr, PDWORD pdwBestIfIndex)
|
|
|
|
{
|
2003-09-08 21:00:25 +02:00
|
|
|
DWORD ret;
|
|
|
|
|
2004-01-02 04:55:05 +01:00
|
|
|
TRACE("dwDestAddr 0x%08lx, pdwBestIfIndex %p\n", dwDestAddr, pdwBestIfIndex);
|
2003-09-08 21:00:25 +02:00
|
|
|
if (!pdwBestIfIndex)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else {
|
|
|
|
MIB_IPFORWARDROW ipRow;
|
|
|
|
|
|
|
|
ret = GetBestRoute(dwDestAddr, 0, &ipRow);
|
|
|
|
if (ret == ERROR_SUCCESS)
|
|
|
|
*pdwBestIfIndex = ipRow.dwForwardIfIndex;
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-09-08 21:00:25 +02:00
|
|
|
return ret;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetBestRoute (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the best route for the given IP address.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* PARAMS
|
|
|
|
* dwDestAddr [In] IP address to search the best route for
|
|
|
|
* dwSourceAddr [In] optional source IP address
|
|
|
|
* pBestRoute [Out] found best route
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDROW pBestRoute)
|
|
|
|
{
|
2003-09-08 21:00:25 +02:00
|
|
|
PMIB_IPFORWARDTABLE table;
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("dwDestAddr 0x%08x, dwSourceAddr 0x%08x, pBestRoute %p\n", dwDestAddr,
|
2004-01-02 04:55:05 +01:00
|
|
|
dwSourceAddr, pBestRoute);
|
2003-09-08 21:00:25 +02:00
|
|
|
if (!pBestRoute)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2007-10-24 18:15:39 +02:00
|
|
|
ret = AllocateAndGetIpForwardTableFromStack(&table, FALSE, GetProcessHeap(), 0);
|
2007-11-15 18:38:12 +01:00
|
|
|
if (!ret) {
|
2007-10-24 21:47:42 +02:00
|
|
|
DWORD ndx, matchedBits, matchedNdx = table->dwNumEntries;
|
2003-09-08 21:00:25 +02:00
|
|
|
|
|
|
|
for (ndx = 0, matchedBits = 0; ndx < table->dwNumEntries; ndx++) {
|
2006-01-24 12:18:50 +01:00
|
|
|
if (table->table[ndx].dwForwardType != MIB_IPROUTE_TYPE_INVALID &&
|
|
|
|
(dwDestAddr & table->table[ndx].dwForwardMask) ==
|
2003-09-08 21:00:25 +02:00
|
|
|
(table->table[ndx].dwForwardDest & table->table[ndx].dwForwardMask)) {
|
|
|
|
DWORD numShifts, mask;
|
|
|
|
|
|
|
|
for (numShifts = 0, mask = table->table[ndx].dwForwardMask;
|
|
|
|
mask && !(mask & 1); mask >>= 1, numShifts++)
|
|
|
|
;
|
|
|
|
if (numShifts > matchedBits) {
|
|
|
|
matchedBits = numShifts;
|
|
|
|
matchedNdx = ndx;
|
|
|
|
}
|
2007-11-15 18:38:12 +01:00
|
|
|
else if (!matchedBits && table->table[ndx].dwForwardType ==
|
|
|
|
MIB_IPROUTE_TYPE_INDIRECT) {
|
|
|
|
/* default to a default gateway */
|
|
|
|
matchedNdx = ndx;
|
|
|
|
}
|
2003-09-08 21:00:25 +02:00
|
|
|
}
|
|
|
|
}
|
2006-01-24 12:18:50 +01:00
|
|
|
if (matchedNdx < table->dwNumEntries) {
|
|
|
|
memcpy(pBestRoute, &table->table[matchedNdx], sizeof(MIB_IPFORWARDROW));
|
|
|
|
ret = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* No route matches, which can happen if there's no default route. */
|
|
|
|
ret = ERROR_HOST_UNREACHABLE;
|
|
|
|
}
|
2003-09-08 21:00:25 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, table);
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-09-08 21:00:25 +02:00
|
|
|
return ret;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetFriendlyIfIndex (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get a "friendly" version of IfIndex, which is one that doesn't
|
2004-12-13 14:21:39 +01:00
|
|
|
* have the top byte set. Doesn't validate whether IfIndex is a valid
|
|
|
|
* adapter index.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* IfIndex [In] interface index to get the friendly one for
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* A friendly version of IfIndex.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetFriendlyIfIndex(DWORD IfIndex)
|
|
|
|
{
|
|
|
|
/* windows doesn't validate these, either, just makes sure the top byte is
|
2003-09-08 21:00:25 +02:00
|
|
|
cleared. I assume my ifenum module never gives an index with the top
|
2003-05-13 05:32:20 +02:00
|
|
|
byte set. */
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", IfIndex);
|
2003-05-13 05:32:20 +02:00
|
|
|
return IfIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetIcmpStatistics (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the ICMP statistics for the local computer.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* PARAMS
|
|
|
|
* pStats [Out] buffer for ICMP statistics
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetIcmpStatistics(PMIB_ICMP pStats)
|
|
|
|
{
|
2004-01-02 04:55:05 +01:00
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
TRACE("pStats %p\n", pStats);
|
|
|
|
ret = getICMPStats(pStats);
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2004-01-02 04:55:05 +01:00
|
|
|
return ret;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetIfEntry (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get information about an interface.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* PARAMS
|
|
|
|
* pIfRow [In/Out] In: dwIndex of MIB_IFROW selects the interface.
|
|
|
|
* Out: interface information
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
2006-01-27 19:19:32 +01:00
|
|
|
char nameBuf[MAX_ADAPTER_NAME];
|
|
|
|
char *name;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2004-01-02 04:55:05 +01:00
|
|
|
TRACE("pIfRow %p\n", pIfRow);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pIfRow)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2006-01-27 19:19:32 +01:00
|
|
|
name = getInterfaceNameByIndex(pIfRow->dwIndex, nameBuf);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (name) {
|
|
|
|
ret = getInterfaceEntryByName(name, pIfRow);
|
|
|
|
if (ret == NO_ERROR)
|
|
|
|
ret = getInterfaceStatsByName(name, pIfRow);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = ERROR_INVALID_DATA;
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-08 21:00:25 +02:00
|
|
|
static int IfTableSorter(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (a && b)
|
2005-06-27 11:53:46 +02:00
|
|
|
ret = ((const MIB_IFROW*)a)->dwIndex - ((const MIB_IFROW*)b)->dwIndex;
|
2003-09-08 21:00:25 +02:00
|
|
|
else
|
|
|
|
ret = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-13 05:32:20 +02:00
|
|
|
/******************************************************************
|
|
|
|
* GetIfTable (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get a table of local interfaces.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pIfTable [Out] buffer for local interfaces table
|
|
|
|
* pdwSize [In/Out] length of output buffer
|
|
|
|
* bOrder [In] whether to sort the table
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* NOTES
|
|
|
|
* If pdwSize is less than required, the function will return
|
|
|
|
* ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
|
|
|
|
* size.
|
|
|
|
* If bOrder is true, the returned table will be sorted by interface index.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("pIfTable %p, pdwSize %p, bOrder %d\n", pdwSize, pdwSize,
|
2004-01-02 04:55:05 +01:00
|
|
|
(DWORD)bOrder);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pdwSize)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else {
|
|
|
|
DWORD numInterfaces = getNumInterfaces();
|
2007-11-15 20:05:10 +01:00
|
|
|
ULONG size = sizeof(MIB_IFTABLE);
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2007-11-15 20:05:10 +01:00
|
|
|
if (numInterfaces > 1)
|
|
|
|
size += (numInterfaces - 1) * sizeof(MIB_IFROW);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pIfTable || *pdwSize < size) {
|
|
|
|
*pdwSize = size;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
InterfaceIndexTable *table = getInterfaceIndexTable();
|
|
|
|
|
|
|
|
if (table) {
|
2007-11-15 20:05:10 +01:00
|
|
|
size = sizeof(MIB_IFTABLE);
|
|
|
|
if (table->numIndexes > 1)
|
|
|
|
size += (table->numIndexes - 1) * sizeof(MIB_IFROW);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (*pdwSize < size) {
|
|
|
|
*pdwSize = size;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
DWORD ndx;
|
|
|
|
|
2006-01-24 12:18:50 +01:00
|
|
|
*pdwSize = size;
|
2003-05-13 05:32:20 +02:00
|
|
|
pIfTable->dwNumEntries = 0;
|
|
|
|
for (ndx = 0; ndx < table->numIndexes; ndx++) {
|
|
|
|
pIfTable->table[ndx].dwIndex = table->indexes[ndx];
|
|
|
|
GetIfEntry(&pIfTable->table[ndx]);
|
|
|
|
pIfTable->dwNumEntries++;
|
|
|
|
}
|
2003-09-08 21:00:25 +02:00
|
|
|
if (bOrder)
|
|
|
|
qsort(pIfTable->table, pIfTable->dwNumEntries, sizeof(MIB_IFROW),
|
|
|
|
IfTableSorter);
|
2003-05-13 05:32:20 +02:00
|
|
|
ret = NO_ERROR;
|
|
|
|
}
|
2004-12-13 14:21:39 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, table);
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetInterfaceInfo (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get a list of network interface adapters.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* PARAMS
|
2006-01-20 16:16:56 +01:00
|
|
|
* pIfTable [Out] buffer for interface adapters
|
2005-11-14 12:24:37 +01:00
|
|
|
* dwOutBufLen [Out] if buffer is too small, returns required size
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2006-01-27 19:19:32 +01:00
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* MSDN states this should return non-loopback interfaces only.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetInterfaceInfo(PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2004-01-02 04:55:05 +01:00
|
|
|
TRACE("pIfTable %p, dwOutBufLen %p\n", pIfTable, dwOutBufLen);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!dwOutBufLen)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else {
|
|
|
|
DWORD numInterfaces = getNumInterfaces();
|
2007-11-15 20:05:10 +01:00
|
|
|
ULONG size = sizeof(IP_INTERFACE_INFO);
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2007-11-15 20:05:10 +01:00
|
|
|
if (numInterfaces > 1)
|
|
|
|
size += (numInterfaces - 1) * sizeof(IP_ADAPTER_INDEX_MAP);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pIfTable || *dwOutBufLen < size) {
|
|
|
|
*dwOutBufLen = size;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
InterfaceIndexTable *table = getInterfaceIndexTable();
|
|
|
|
|
|
|
|
if (table) {
|
2007-11-15 20:05:10 +01:00
|
|
|
size = sizeof(IP_INTERFACE_INFO);
|
|
|
|
if (table->numIndexes > 1)
|
|
|
|
size += (table->numIndexes - 1) * sizeof(IP_ADAPTER_INDEX_MAP);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (*dwOutBufLen < size) {
|
|
|
|
*dwOutBufLen = size;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
DWORD ndx;
|
2006-01-27 19:19:32 +01:00
|
|
|
char nameBuf[MAX_ADAPTER_NAME];
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2006-01-25 13:14:12 +01:00
|
|
|
*dwOutBufLen = size;
|
2003-05-13 05:32:20 +02:00
|
|
|
pIfTable->NumAdapters = 0;
|
|
|
|
for (ndx = 0; ndx < table->numIndexes; ndx++) {
|
|
|
|
const char *walker, *name;
|
|
|
|
WCHAR *assigner;
|
|
|
|
|
|
|
|
pIfTable->Adapter[ndx].Index = table->indexes[ndx];
|
2006-01-27 19:19:32 +01:00
|
|
|
name = getInterfaceNameByIndex(table->indexes[ndx], nameBuf);
|
2003-05-13 05:32:20 +02:00
|
|
|
for (walker = name, assigner = pIfTable->Adapter[ndx].Name;
|
|
|
|
walker && *walker &&
|
|
|
|
assigner - pIfTable->Adapter[ndx].Name < MAX_ADAPTER_NAME - 1;
|
|
|
|
walker++, assigner++)
|
|
|
|
*assigner = *walker;
|
|
|
|
*assigner = 0;
|
|
|
|
pIfTable->NumAdapters++;
|
|
|
|
}
|
|
|
|
ret = NO_ERROR;
|
|
|
|
}
|
2004-12-13 14:21:39 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, table);
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetIpAddrTable (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get interface-to-IP address mapping table.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pIpAddrTable [Out] buffer for mapping table
|
|
|
|
* pdwSize [In/Out] length of output buffer
|
|
|
|
* bOrder [In] whether to sort the table
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* NOTES
|
|
|
|
* If pdwSize is less than required, the function will return
|
|
|
|
* ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
|
|
|
|
* size.
|
|
|
|
* If bOrder is true, the returned table will be sorted by the next hop and
|
|
|
|
* an assortment of arbitrary parameters.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("pIpAddrTable %p, pdwSize %p, bOrder %d\n", pIpAddrTable, pdwSize,
|
2004-01-02 04:55:05 +01:00
|
|
|
(DWORD)bOrder);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pdwSize)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else {
|
2006-01-24 12:18:50 +01:00
|
|
|
PMIB_IPADDRTABLE table;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2006-01-24 12:18:50 +01:00
|
|
|
ret = getIPAddrTable(&table, GetProcessHeap(), 0);
|
|
|
|
if (ret == NO_ERROR)
|
|
|
|
{
|
2007-11-15 20:06:07 +01:00
|
|
|
ULONG size = sizeof(MIB_IPADDRTABLE);
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2007-11-15 20:06:07 +01:00
|
|
|
if (table->dwNumEntries > 1)
|
|
|
|
size += (table->dwNumEntries - 1) * sizeof(MIB_IPADDRROW);
|
2006-01-24 12:18:50 +01:00
|
|
|
if (!pIpAddrTable || *pdwSize < size) {
|
|
|
|
*pdwSize = size;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
2006-01-24 12:18:50 +01:00
|
|
|
else {
|
|
|
|
*pdwSize = size;
|
2007-11-15 20:06:07 +01:00
|
|
|
memcpy(pIpAddrTable, table, size);
|
2006-01-24 12:18:50 +01:00
|
|
|
if (bOrder)
|
|
|
|
qsort(pIpAddrTable->table, pIpAddrTable->dwNumEntries,
|
|
|
|
sizeof(MIB_IPADDRROW), IpAddrTableSorter);
|
|
|
|
ret = NO_ERROR;
|
2003-09-08 21:00:25 +02:00
|
|
|
}
|
2006-01-24 12:18:50 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, table);
|
2003-09-08 21:00:25 +02:00
|
|
|
}
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-09-08 21:00:25 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-13 05:32:20 +02:00
|
|
|
/******************************************************************
|
|
|
|
* GetIpForwardTable (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the route table.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pIpForwardTable [Out] buffer for route table
|
|
|
|
* pdwSize [In/Out] length of output buffer
|
|
|
|
* bOrder [In] whether to sort the table
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* NOTES
|
|
|
|
* If pdwSize is less than required, the function will return
|
|
|
|
* ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
|
|
|
|
* size.
|
|
|
|
* If bOrder is true, the returned table will be sorted by the next hop and
|
|
|
|
* an assortment of arbitrary parameters.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSize, BOOL bOrder)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("pIpForwardTable %p, pdwSize %p, bOrder %d\n", pIpForwardTable,
|
2004-01-02 04:55:05 +01:00
|
|
|
pdwSize, (DWORD)bOrder);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pdwSize)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else {
|
|
|
|
DWORD numRoutes = getNumRoutes();
|
2007-11-15 20:02:22 +01:00
|
|
|
ULONG sizeNeeded = sizeof(MIB_IPFORWARDTABLE);
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2007-11-15 20:02:22 +01:00
|
|
|
if (numRoutes > 1)
|
|
|
|
sizeNeeded += (numRoutes - 1) * sizeof(MIB_IPFORWARDROW);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pIpForwardTable || *pdwSize < sizeNeeded) {
|
|
|
|
*pdwSize = sizeNeeded;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
2006-01-24 12:18:50 +01:00
|
|
|
PMIB_IPFORWARDTABLE table;
|
|
|
|
|
|
|
|
ret = getRouteTable(&table, GetProcessHeap(), 0);
|
|
|
|
if (!ret) {
|
2007-11-15 20:02:22 +01:00
|
|
|
sizeNeeded = sizeof(MIB_IPFORWARDTABLE);
|
|
|
|
if (table->dwNumEntries > 1)
|
|
|
|
sizeNeeded += (table->dwNumEntries - 1) * sizeof(MIB_IPFORWARDROW);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (*pdwSize < sizeNeeded) {
|
|
|
|
*pdwSize = sizeNeeded;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
2006-01-24 12:18:50 +01:00
|
|
|
*pdwSize = sizeNeeded;
|
|
|
|
memcpy(pIpForwardTable, table, sizeNeeded);
|
2003-09-08 21:00:25 +02:00
|
|
|
if (bOrder)
|
|
|
|
qsort(pIpForwardTable->table, pIpForwardTable->dwNumEntries,
|
|
|
|
sizeof(MIB_IPFORWARDROW), IpForwardTableSorter);
|
2003-05-13 05:32:20 +02:00
|
|
|
ret = NO_ERROR;
|
|
|
|
}
|
2004-12-13 14:21:39 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, table);
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetIpNetTable (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the IP-to-physical address mapping table.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pIpNetTable [Out] buffer for mapping table
|
|
|
|
* pdwSize [In/Out] length of output buffer
|
|
|
|
* bOrder [In] whether to sort the table
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* NOTES
|
|
|
|
* If pdwSize is less than required, the function will return
|
|
|
|
* ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the required byte
|
|
|
|
* size.
|
|
|
|
* If bOrder is true, the returned table will be sorted by IP address.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetIpNetTable(PMIB_IPNETTABLE pIpNetTable, PULONG pdwSize, BOOL bOrder)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("pIpNetTable %p, pdwSize %p, bOrder %d\n", pIpNetTable, pdwSize,
|
2004-01-02 04:55:05 +01:00
|
|
|
(DWORD)bOrder);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pdwSize)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else {
|
|
|
|
DWORD numEntries = getNumArpEntries();
|
2007-11-15 20:03:25 +01:00
|
|
|
ULONG size = sizeof(MIB_IPNETTABLE);
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2007-11-15 20:03:25 +01:00
|
|
|
if (numEntries > 1)
|
|
|
|
size += (numEntries - 1) * sizeof(MIB_IPNETROW);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pIpNetTable || *pdwSize < size) {
|
|
|
|
*pdwSize = size;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
2006-01-24 12:18:50 +01:00
|
|
|
PMIB_IPNETTABLE table;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2006-01-24 12:18:50 +01:00
|
|
|
ret = getArpTable(&table, GetProcessHeap(), 0);
|
|
|
|
if (!ret) {
|
2007-11-15 20:03:25 +01:00
|
|
|
size = sizeof(MIB_IPNETTABLE);
|
|
|
|
if (table->dwNumEntries > 1)
|
|
|
|
size += (table->dwNumEntries - 1) * sizeof(MIB_IPNETROW);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (*pdwSize < size) {
|
|
|
|
*pdwSize = size;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
2006-01-24 12:18:50 +01:00
|
|
|
*pdwSize = size;
|
2003-05-13 05:32:20 +02:00
|
|
|
memcpy(pIpNetTable, table, size);
|
2003-09-08 21:00:25 +02:00
|
|
|
if (bOrder)
|
|
|
|
qsort(pIpNetTable->table, pIpNetTable->dwNumEntries,
|
|
|
|
sizeof(MIB_IPNETROW), IpNetTableSorter);
|
2003-05-13 05:32:20 +02:00
|
|
|
ret = NO_ERROR;
|
|
|
|
}
|
2004-12-13 14:21:39 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, table);
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetIpStatistics (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the IP statistics for the local computer.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* PARAMS
|
|
|
|
* pStats [Out] buffer for IP statistics
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetIpStatistics(PMIB_IPSTATS pStats)
|
|
|
|
{
|
2004-01-02 04:55:05 +01:00
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
TRACE("pStats %p\n", pStats);
|
|
|
|
ret = getIPStats(pStats);
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2004-01-02 04:55:05 +01:00
|
|
|
return ret;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetNetworkParams (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the network parameters for the local computer.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* PARAMS
|
|
|
|
* pFixedInfo [Out] buffer for network parameters
|
2005-11-23 20:14:43 +01:00
|
|
|
* pOutBufLen [In/Out] length of output buffer
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* NOTES
|
|
|
|
* If pOutBufLen is less than required, the function will return
|
|
|
|
* ERROR_INSUFFICIENT_BUFFER, and pOutBufLen will be set to the required byte
|
|
|
|
* size.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
|
|
|
|
{
|
2004-01-02 04:55:05 +01:00
|
|
|
DWORD ret, size;
|
|
|
|
LONG regReturn;
|
2003-09-08 21:00:25 +02:00
|
|
|
HKEY hKey;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2004-01-02 04:55:05 +01:00
|
|
|
TRACE("pFixedInfo %p, pOutBufLen %p\n", pFixedInfo, pOutBufLen);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pOutBufLen)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2007-04-18 20:39:33 +02:00
|
|
|
initialise_resolver();
|
2003-09-08 21:00:25 +02:00
|
|
|
size = sizeof(FIXED_INFO) + (_res.nscount > 0 ? (_res.nscount - 1) *
|
|
|
|
sizeof(IP_ADDR_STRING) : 0);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pFixedInfo || *pOutBufLen < size) {
|
|
|
|
*pOutBufLen = size;
|
|
|
|
return ERROR_BUFFER_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(pFixedInfo, 0, size);
|
|
|
|
size = sizeof(pFixedInfo->HostName);
|
|
|
|
GetComputerNameExA(ComputerNameDnsHostname, pFixedInfo->HostName, &size);
|
|
|
|
size = sizeof(pFixedInfo->DomainName);
|
|
|
|
GetComputerNameExA(ComputerNameDnsDomain, pFixedInfo->DomainName, &size);
|
|
|
|
if (_res.nscount > 0) {
|
|
|
|
PIP_ADDR_STRING ptr;
|
|
|
|
int i;
|
|
|
|
|
2003-09-08 21:00:25 +02:00
|
|
|
for (i = 0, ptr = &pFixedInfo->DnsServerList; i < _res.nscount && ptr;
|
2003-05-13 05:32:20 +02:00
|
|
|
i++, ptr = ptr->Next) {
|
|
|
|
toIPAddressString(_res.nsaddr_list[i].sin_addr.s_addr,
|
|
|
|
ptr->IpAddress.String);
|
2003-09-08 21:00:25 +02:00
|
|
|
if (i == _res.nscount - 1)
|
|
|
|
ptr->Next = NULL;
|
|
|
|
else if (i == 0)
|
|
|
|
ptr->Next = (PIP_ADDR_STRING)((LPBYTE)pFixedInfo + sizeof(FIXED_INFO));
|
|
|
|
else
|
|
|
|
ptr->Next = (PIP_ADDR_STRING)((PBYTE)ptr + sizeof(IP_ADDR_STRING));
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
}
|
2003-09-08 21:00:25 +02:00
|
|
|
pFixedInfo->NodeType = HYBRID_NODETYPE;
|
2004-01-02 04:55:05 +01:00
|
|
|
regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
|
|
|
|
"SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", 0, KEY_READ, &hKey);
|
|
|
|
if (regReturn != ERROR_SUCCESS)
|
|
|
|
regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
|
|
|
|
"SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ,
|
|
|
|
&hKey);
|
|
|
|
if (regReturn == ERROR_SUCCESS)
|
2003-09-08 21:00:25 +02:00
|
|
|
{
|
|
|
|
DWORD size = sizeof(pFixedInfo->ScopeId);
|
|
|
|
|
2005-07-07 14:08:42 +02:00
|
|
|
RegQueryValueExA(hKey, "ScopeID", NULL, NULL, (LPBYTE)pFixedInfo->ScopeId, &size);
|
2003-09-08 21:00:25 +02:00
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
|
2003-05-13 05:32:20 +02:00
|
|
|
/* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
|
|
|
|
I suppose could also check for a listener on port 53 to set EnableDns */
|
2004-01-02 04:55:05 +01:00
|
|
|
ret = NO_ERROR;
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2004-01-02 04:55:05 +01:00
|
|
|
return ret;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetNumberOfInterfaces (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the number of interfaces.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pdwNumIf [Out] number of interfaces
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* NO_ERROR on success, ERROR_INVALID_PARAMETER if pdwNumIf is NULL.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2004-01-02 04:55:05 +01:00
|
|
|
TRACE("pdwNumIf %p\n", pdwNumIf);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pdwNumIf)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else {
|
|
|
|
*pdwNumIf = getNumInterfaces();
|
|
|
|
ret = NO_ERROR;
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetPerAdapterInfo (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get information about an adapter corresponding to an interface.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* IfIndex [In] interface info
|
|
|
|
* pPerAdapterInfo [Out] buffer for per adapter info
|
|
|
|
* pOutBufLen [In/Out] length of output buffer
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
|
|
|
*
|
|
|
|
* FIXME
|
2007-10-13 01:16:35 +02:00
|
|
|
* Stub, returns empty IP_PER_ADAPTER_INFO in every case.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetPerAdapterInfo(ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
|
|
|
|
{
|
2007-10-13 01:16:35 +02:00
|
|
|
ULONG bytesNeeded = sizeof(IP_PER_ADAPTER_INFO);
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("(IfIndex %d, pPerAdapterInfo %p, pOutBufLen %p)\n", IfIndex,
|
2004-01-02 04:55:05 +01:00
|
|
|
pPerAdapterInfo, pOutBufLen);
|
2007-10-13 01:16:35 +02:00
|
|
|
if (!pOutBufLen)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else if (!pPerAdapterInfo)
|
|
|
|
{
|
|
|
|
*pOutBufLen = bytesNeeded;
|
|
|
|
ret = NO_ERROR;
|
|
|
|
}
|
|
|
|
else if (*pOutBufLen < bytesNeeded)
|
|
|
|
{
|
|
|
|
*pOutBufLen = bytesNeeded;
|
|
|
|
ret = ERROR_BUFFER_OVERFLOW;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memset(pPerAdapterInfo, 0, bytesNeeded);
|
|
|
|
ret = NO_ERROR;
|
|
|
|
}
|
|
|
|
return ret;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetRTTAndHopCount (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get round-trip time (RTT) and hop count.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* DestIpAddress [In] destination address to get the info for
|
|
|
|
* HopCount [Out] retrieved hop count
|
|
|
|
* MaxHops [In] maximum hops to search for the destination
|
|
|
|
* RTT [Out] RTT in milliseconds
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns FALSE.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI GetRTTAndHopCount(IPAddr DestIpAddress, PULONG HopCount, ULONG MaxHops, PULONG RTT)
|
|
|
|
{
|
2006-10-07 20:18:10 +02:00
|
|
|
FIXME("(DestIpAddress 0x%08lx, HopCount %p, MaxHops %d, RTT %p): stub\n",
|
2004-01-02 04:55:05 +01:00
|
|
|
DestIpAddress, HopCount, MaxHops, RTT);
|
2004-12-13 14:21:39 +01:00
|
|
|
return FALSE;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetTcpStatistics (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the TCP statistics for the local computer.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* PARAMS
|
|
|
|
* pStats [Out] buffer for TCP statistics
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetTcpStatistics(PMIB_TCPSTATS pStats)
|
|
|
|
{
|
2004-01-02 04:55:05 +01:00
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
TRACE("pStats %p\n", pStats);
|
|
|
|
ret = getTCPStats(pStats);
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2004-01-02 04:55:05 +01:00
|
|
|
return ret;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetTcpTable (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the table of active TCP connections.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pTcpTable [Out] buffer for TCP connections table
|
|
|
|
* pdwSize [In/Out] length of output buffer
|
|
|
|
* bOrder [In] whether to order the table
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* NOTES
|
|
|
|
* If pdwSize is less than required, the function will return
|
|
|
|
* ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to
|
|
|
|
* the required byte size.
|
|
|
|
* If bOrder is true, the returned table will be sorted, first by
|
|
|
|
* local address and port number, then by remote address and port
|
|
|
|
* number.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("pTcpTable %p, pdwSize %p, bOrder %d\n", pTcpTable, pdwSize,
|
2004-01-02 04:55:05 +01:00
|
|
|
(DWORD)bOrder);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pdwSize)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else {
|
|
|
|
DWORD numEntries = getNumTcpEntries();
|
2007-11-15 20:01:13 +01:00
|
|
|
DWORD size = sizeof(MIB_TCPTABLE);
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2007-11-15 20:01:13 +01:00
|
|
|
if (numEntries > 1)
|
|
|
|
size += (numEntries - 1) * sizeof(MIB_TCPROW);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pTcpTable || *pdwSize < size) {
|
|
|
|
*pdwSize = size;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
2007-07-11 05:39:21 +02:00
|
|
|
ret = getTcpTable(&pTcpTable, numEntries, 0, 0);
|
2006-01-24 12:18:50 +01:00
|
|
|
if (!ret) {
|
2007-11-15 20:01:13 +01:00
|
|
|
size = sizeof(MIB_TCPTABLE);
|
2007-11-16 19:25:11 +01:00
|
|
|
if (pTcpTable->dwNumEntries > 1)
|
|
|
|
size += (pTcpTable->dwNumEntries - 1) * sizeof(MIB_TCPROW);
|
2007-07-11 05:39:21 +02:00
|
|
|
*pdwSize = size;
|
|
|
|
|
2007-11-16 19:25:40 +01:00
|
|
|
if (bOrder)
|
|
|
|
qsort(pTcpTable->table, pTcpTable->dwNumEntries,
|
|
|
|
sizeof(MIB_TCPROW), TcpTableSorter);
|
|
|
|
ret = NO_ERROR;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetUdpStatistics (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get the UDP statistics for the local computer.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* PARAMS
|
|
|
|
* pStats [Out] buffer for UDP statistics
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetUdpStatistics(PMIB_UDPSTATS pStats)
|
|
|
|
{
|
2004-01-02 04:55:05 +01:00
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
TRACE("pStats %p\n", pStats);
|
|
|
|
ret = getUDPStats(pStats);
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2004-01-02 04:55:05 +01:00
|
|
|
return ret;
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetUdpTable (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Get a table of active UDP connections.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pUdpTable [Out] buffer for UDP connections table
|
|
|
|
* pdwSize [In/Out] length of output buffer
|
|
|
|
* bOrder [In] whether to order the table
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* NOTES
|
|
|
|
* If pdwSize is less than required, the function will return
|
|
|
|
* ERROR_INSUFFICIENT_BUFFER, and *pdwSize will be set to the
|
|
|
|
* required byte size.
|
|
|
|
* If bOrder is true, the returned table will be sorted, first by
|
|
|
|
* local address, then by local port number.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("pUdpTable %p, pdwSize %p, bOrder %d\n", pUdpTable, pdwSize,
|
2004-01-02 04:55:05 +01:00
|
|
|
(DWORD)bOrder);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pdwSize)
|
|
|
|
ret = ERROR_INVALID_PARAMETER;
|
|
|
|
else {
|
|
|
|
DWORD numEntries = getNumUdpEntries();
|
2007-11-15 20:04:12 +01:00
|
|
|
DWORD size = sizeof(MIB_UDPTABLE);
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2007-11-15 20:04:12 +01:00
|
|
|
if (numEntries > 1)
|
|
|
|
size += (numEntries - 1) * sizeof(MIB_UDPROW);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (!pUdpTable || *pdwSize < size) {
|
|
|
|
*pdwSize = size;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
2006-01-24 12:18:50 +01:00
|
|
|
PMIB_UDPTABLE table;
|
2003-05-13 05:32:20 +02:00
|
|
|
|
2006-01-24 12:18:50 +01:00
|
|
|
ret = getUdpTable(&table, GetProcessHeap(), 0);
|
|
|
|
if (!ret) {
|
2007-11-15 20:04:12 +01:00
|
|
|
size = sizeof(MIB_UDPTABLE);
|
|
|
|
if (table->dwNumEntries > 1)
|
|
|
|
size += (table->dwNumEntries - 1) * sizeof(MIB_UDPROW);
|
2003-05-13 05:32:20 +02:00
|
|
|
if (*pdwSize < size) {
|
|
|
|
*pdwSize = size;
|
|
|
|
ret = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
else {
|
2006-01-24 12:18:50 +01:00
|
|
|
*pdwSize = size;
|
2003-05-13 05:32:20 +02:00
|
|
|
memcpy(pUdpTable, table, size);
|
2003-09-08 21:00:25 +02:00
|
|
|
if (bOrder)
|
|
|
|
qsort(pUdpTable->table, pUdpTable->dwNumEntries,
|
|
|
|
sizeof(MIB_UDPROW), UdpTableSorter);
|
2003-05-13 05:32:20 +02:00
|
|
|
ret = NO_ERROR;
|
|
|
|
}
|
2004-12-13 14:21:39 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, table);
|
2003-05-13 05:32:20 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
2006-10-07 20:18:10 +02:00
|
|
|
TRACE("returning %d\n", ret);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* GetUniDirectionalAdapterInfo (IPHLPAPI.@)
|
|
|
|
*
|
2004-12-13 14:21:39 +01:00
|
|
|
* This is a Win98-only function to get information on "unidirectional"
|
|
|
|
* adapters. Since this is pretty nonsensical in other contexts, it
|
|
|
|
* never returns anything.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pIPIfInfo [Out] buffer for adapter infos
|
|
|
|
* dwOutBufLen [Out] length of the output buffer
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI GetUniDirectionalAdapterInfo(PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo, PULONG dwOutBufLen)
|
|
|
|
{
|
2004-01-02 04:55:05 +01:00
|
|
|
TRACE("pIPIfInfo %p, dwOutBufLen %p\n", pIPIfInfo, dwOutBufLen);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* a unidirectional adapter?? not bloody likely! */
|
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* IpReleaseAddress (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Release an IP optained through DHCP,
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* AdapterInfo [In] adapter to release IP address
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* NOTES
|
|
|
|
* Since GetAdaptersInfo never returns adapters that have DHCP enabled,
|
|
|
|
* this function does nothing.
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI IpReleaseAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
|
|
|
|
{
|
2004-01-02 04:55:05 +01:00
|
|
|
TRACE("AdapterInfo %p\n", AdapterInfo);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* not a stub, never going to support this (and I never mark an adapter as
|
|
|
|
DHCP enabled, see GetAdaptersInfo, so this should never get called) */
|
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* IpRenewAddress (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Renew an IP optained through DHCP.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* AdapterInfo [In] adapter to renew IP address
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Since GetAdaptersInfo never returns adapters that have DHCP enabled,
|
|
|
|
* this function does nothing.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI IpRenewAddress(PIP_ADAPTER_INDEX_MAP AdapterInfo)
|
|
|
|
{
|
2004-01-02 04:55:05 +01:00
|
|
|
TRACE("AdapterInfo %p\n", AdapterInfo);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* not a stub, never going to support this (and I never mark an adapter as
|
|
|
|
DHCP enabled, see GetAdaptersInfo, so this should never get called) */
|
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NotifyAddrChange (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Notify caller whenever the ip-interface map is changed.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Handle [Out] handle useable in asynchronus notification
|
|
|
|
* overlapped [In] overlapped structure that notifies the caller
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI NotifyAddrChange(PHANDLE Handle, LPOVERLAPPED overlapped)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(Handle %p, overlapped %p): stub\n", Handle, overlapped);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* NotifyRouteChange (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Notify caller whenever the ip routing table is changed.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Handle [Out] handle useable in asynchronus notification
|
|
|
|
* overlapped [In] overlapped structure that notifies the caller
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI NotifyRouteChange(PHANDLE Handle, LPOVERLAPPED overlapped)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(Handle %p, overlapped %p): stub\n", Handle, overlapped);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SendARP (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Send an ARP request.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2006-01-24 12:18:50 +01:00
|
|
|
* DestIP [In] attempt to obtain this IP
|
2005-11-14 12:24:37 +01:00
|
|
|
* SrcIP [In] optional sender IP address
|
|
|
|
* pMacAddr [Out] buffer for the mac address
|
|
|
|
* PhyAddrLen [In/Out] length of the output buffer
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI SendARP(IPAddr DestIP, IPAddr SrcIP, PULONG pMacAddr, PULONG PhyAddrLen)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(DestIP 0x%08lx, SrcIP 0x%08lx, pMacAddr %p, PhyAddrLen %p): stub\n",
|
|
|
|
DestIP, SrcIP, pMacAddr, PhyAddrLen);
|
2003-05-13 05:32:20 +02:00
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SetIfEntry (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Set the administrative status of an interface.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pIfRow [In] dwAdminStatus member specifies the new status.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI SetIfEntry(PMIB_IFROW pIfRow)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(pIfRow %p): stub\n", pIfRow);
|
2006-01-25 13:14:12 +01:00
|
|
|
/* this is supposed to set an interface administratively up or down.
|
2003-05-13 05:32:20 +02:00
|
|
|
Could do SIOCSIFFLAGS and set/clear IFF_UP, but, not sure I want to, and
|
|
|
|
this sort of down is indistinguishable from other sorts of down (e.g. no
|
|
|
|
link). */
|
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SetIpForwardEntry (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Modify an existing route.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pRoute [In] route with the new information
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns NO_ERROR.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI SetIpForwardEntry(PMIB_IPFORWARDROW pRoute)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(pRoute %p): stub\n", pRoute);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* this is to add a route entry, how's it distinguishable from
|
|
|
|
CreateIpForwardEntry?
|
|
|
|
could use SIOCADDRT, not sure I want to */
|
|
|
|
return (DWORD) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SetIpNetEntry (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Modify an existing ARP entry.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pArpEntry [In] ARP entry with the new information
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns NO_ERROR.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI SetIpNetEntry(PMIB_IPNETROW pArpEntry)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(pArpEntry %p): stub\n", pArpEntry);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* same as CreateIpNetEntry here, could use SIOCSARP, not sure I want to */
|
|
|
|
return (DWORD) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SetIpStatistics (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Toggle IP forwarding and det the default TTL value.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pIpStats [In] IP statistics with the new information
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns NO_ERROR.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI SetIpStatistics(PMIB_IPSTATS pIpStats)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(pIpStats %p): stub\n", pIpStats);
|
2003-05-13 05:32:20 +02:00
|
|
|
return (DWORD) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SetIpTTL (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Set the default TTL value.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* nTTL [In] new TTL value
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns NO_ERROR.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI SetIpTTL(UINT nTTL)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(nTTL %d): stub\n", nTTL);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* could echo nTTL > /proc/net/sys/net/ipv4/ip_default_ttl, not sure I
|
|
|
|
want to. Could map EACCESS to ERROR_ACCESS_DENIED, I suppose */
|
|
|
|
return (DWORD) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SetTcpEntry (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Set the state of a TCP connection.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pTcpRow [In] specifies connection with new state
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns NO_ERROR.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI SetTcpEntry(PMIB_TCPROW pTcpRow)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(pTcpRow %p): stub\n", pTcpRow);
|
2003-05-13 05:32:20 +02:00
|
|
|
return (DWORD) 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* UnenableRouter (IPHLPAPI.@)
|
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* Decrement the IP-forwarding reference count. Turn off IP-forwarding
|
|
|
|
* if it reaches zero.
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2005-11-14 12:24:37 +01:00
|
|
|
* pOverlapped [In/Out] should be the same as in EnableRouter()
|
|
|
|
* lpdwEnableCount [Out] optional, receives reference count
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
2005-11-14 12:24:37 +01:00
|
|
|
* Success: NO_ERROR
|
|
|
|
* Failure: error code from winerror.h
|
2003-05-13 05:32:20 +02:00
|
|
|
*
|
2005-11-14 12:24:37 +01:00
|
|
|
* FIXME
|
|
|
|
* Stub, returns ERROR_NOT_SUPPORTED.
|
2003-05-13 05:32:20 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI UnenableRouter(OVERLAPPED * pOverlapped, LPDWORD lpdwEnableCount)
|
|
|
|
{
|
2004-12-13 14:21:39 +01:00
|
|
|
FIXME("(pOverlapped %p, lpdwEnableCount %p): stub\n", pOverlapped,
|
|
|
|
lpdwEnableCount);
|
2003-05-13 05:32:20 +02:00
|
|
|
/* could echo "0" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
|
|
|
|
could map EACCESS to ERROR_ACCESS_DENIED, I suppose
|
2006-01-20 16:16:56 +01:00
|
|
|
*/
|
2003-05-13 05:32:20 +02:00
|
|
|
return ERROR_NOT_SUPPORTED;
|
|
|
|
}
|