2004-01-07 02:08:55 +01:00
|
|
|
/*
|
|
|
|
* iphlpapi dll test
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Juan Lang
|
|
|
|
*
|
|
|
|
* 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
|
2004-01-07 02:08:55 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some observations that an automated test can't produce:
|
|
|
|
* An adapter index is a key for an adapter. That is, if an index is returned
|
|
|
|
* from one API, that same index may be used successfully in another API, as
|
|
|
|
* long as the adapter remains present.
|
|
|
|
* If the adapter is removed and reinserted, however, the index may change (and
|
|
|
|
* indeed it does change on Win2K).
|
|
|
|
*
|
|
|
|
* The Name field of the IP_ADAPTER_INDEX_MAP entries returned by
|
|
|
|
* GetInterfaceInfo is declared as a wide string, but the bytes are actually
|
|
|
|
* an ASCII string on some versions of the IP helper API under Win9x. This was
|
|
|
|
* apparently an MS bug, it's corrected in later versions.
|
|
|
|
*
|
|
|
|
* The DomainName field of FIXED_INFO isn't NULL-terminated on Win98.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2009-03-10 17:50:50 +01:00
|
|
|
#include "winsock2.h"
|
2004-01-07 02:08:55 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "iphlpapi.h"
|
|
|
|
#include "iprtrmib.h"
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
static HMODULE hLibrary = NULL;
|
|
|
|
|
|
|
|
typedef DWORD (WINAPI *GetNumberOfInterfacesFunc)(PDWORD);
|
|
|
|
typedef DWORD (WINAPI *GetIpAddrTableFunc)(PMIB_IPADDRTABLE,PULONG,BOOL);
|
|
|
|
typedef DWORD (WINAPI *GetIfEntryFunc)(PMIB_IFROW);
|
|
|
|
typedef DWORD (WINAPI *GetFriendlyIfIndexFunc)(DWORD);
|
|
|
|
typedef DWORD (WINAPI *GetIfTableFunc)(PMIB_IFTABLE,PULONG,BOOL);
|
|
|
|
typedef DWORD (WINAPI *GetIpForwardTableFunc)(PMIB_IPFORWARDTABLE,PULONG,BOOL);
|
|
|
|
typedef DWORD (WINAPI *GetIpNetTableFunc)(PMIB_IPNETTABLE,PULONG,BOOL);
|
|
|
|
typedef DWORD (WINAPI *GetInterfaceInfoFunc)(PIP_INTERFACE_INFO,PULONG);
|
|
|
|
typedef DWORD (WINAPI *GetAdaptersInfoFunc)(PIP_ADAPTER_INFO,PULONG);
|
|
|
|
typedef DWORD (WINAPI *GetNetworkParamsFunc)(PFIXED_INFO,PULONG);
|
|
|
|
typedef DWORD (WINAPI *GetIcmpStatisticsFunc)(PMIB_ICMP);
|
|
|
|
typedef DWORD (WINAPI *GetIpStatisticsFunc)(PMIB_IPSTATS);
|
|
|
|
typedef DWORD (WINAPI *GetTcpStatisticsFunc)(PMIB_TCPSTATS);
|
|
|
|
typedef DWORD (WINAPI *GetUdpStatisticsFunc)(PMIB_UDPSTATS);
|
|
|
|
typedef DWORD (WINAPI *GetTcpTableFunc)(PMIB_TCPTABLE,PDWORD,BOOL);
|
|
|
|
typedef DWORD (WINAPI *GetUdpTableFunc)(PMIB_UDPTABLE,PDWORD,BOOL);
|
2008-07-02 17:27:37 +02:00
|
|
|
typedef DWORD (WINAPI *GetPerAdapterInfoFunc)(ULONG,PIP_PER_ADAPTER_INFO,PULONG);
|
2009-04-29 11:57:48 +02:00
|
|
|
typedef DWORD (WINAPI *GetAdaptersAddressesFunc)(ULONG,ULONG,PVOID,PIP_ADAPTER_ADDRESSES,PULONG);
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
static GetNumberOfInterfacesFunc gGetNumberOfInterfaces = NULL;
|
|
|
|
static GetIpAddrTableFunc gGetIpAddrTable = NULL;
|
|
|
|
static GetIfEntryFunc gGetIfEntry = NULL;
|
|
|
|
static GetFriendlyIfIndexFunc gGetFriendlyIfIndex = NULL;
|
|
|
|
static GetIfTableFunc gGetIfTable = NULL;
|
|
|
|
static GetIpForwardTableFunc gGetIpForwardTable = NULL;
|
|
|
|
static GetIpNetTableFunc gGetIpNetTable = NULL;
|
|
|
|
static GetInterfaceInfoFunc gGetInterfaceInfo = NULL;
|
|
|
|
static GetAdaptersInfoFunc gGetAdaptersInfo = NULL;
|
|
|
|
static GetNetworkParamsFunc gGetNetworkParams = NULL;
|
|
|
|
static GetIcmpStatisticsFunc gGetIcmpStatistics = NULL;
|
|
|
|
static GetIpStatisticsFunc gGetIpStatistics = NULL;
|
|
|
|
static GetTcpStatisticsFunc gGetTcpStatistics = NULL;
|
|
|
|
static GetUdpStatisticsFunc gGetUdpStatistics = NULL;
|
|
|
|
static GetTcpTableFunc gGetTcpTable = NULL;
|
|
|
|
static GetUdpTableFunc gGetUdpTable = NULL;
|
2008-07-02 17:27:37 +02:00
|
|
|
static GetPerAdapterInfoFunc gGetPerAdapterInfo = NULL;
|
2009-04-29 11:57:48 +02:00
|
|
|
static GetAdaptersAddressesFunc gGetAdaptersAddresses = NULL;
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
static void loadIPHlpApi(void)
|
|
|
|
{
|
|
|
|
hLibrary = LoadLibraryA("iphlpapi.dll");
|
|
|
|
if (hLibrary) {
|
|
|
|
gGetNumberOfInterfaces = (GetNumberOfInterfacesFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetNumberOfInterfaces");
|
|
|
|
gGetIpAddrTable = (GetIpAddrTableFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetIpAddrTable");
|
|
|
|
gGetIfEntry = (GetIfEntryFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetIfEntry");
|
|
|
|
gGetFriendlyIfIndex = (GetFriendlyIfIndexFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetFriendlyIfIndex");
|
|
|
|
gGetIfTable = (GetIfTableFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetIfTable");
|
|
|
|
gGetIpForwardTable = (GetIpForwardTableFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetIpForwardTable");
|
|
|
|
gGetIpNetTable = (GetIpNetTableFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetIpNetTable");
|
|
|
|
gGetInterfaceInfo = (GetInterfaceInfoFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetInterfaceInfo");
|
|
|
|
gGetAdaptersInfo = (GetAdaptersInfoFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetAdaptersInfo");
|
|
|
|
gGetNetworkParams = (GetNetworkParamsFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetNetworkParams");
|
|
|
|
gGetIcmpStatistics = (GetIcmpStatisticsFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetIcmpStatistics");
|
|
|
|
gGetIpStatistics = (GetIpStatisticsFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetIpStatistics");
|
|
|
|
gGetTcpStatistics = (GetTcpStatisticsFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetTcpStatistics");
|
|
|
|
gGetUdpStatistics = (GetUdpStatisticsFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetUdpStatistics");
|
|
|
|
gGetTcpTable = (GetTcpTableFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetTcpTable");
|
|
|
|
gGetUdpTable = (GetUdpTableFunc)GetProcAddress(
|
|
|
|
hLibrary, "GetUdpTable");
|
2008-07-02 17:27:37 +02:00
|
|
|
gGetPerAdapterInfo = (GetPerAdapterInfoFunc)GetProcAddress(hLibrary, "GetPerAdapterInfo");
|
2009-04-29 11:57:48 +02:00
|
|
|
gGetAdaptersAddresses = (GetAdaptersAddressesFunc)GetProcAddress(hLibrary, "GetAdaptersAddresses");
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void freeIPHlpApi(void)
|
|
|
|
{
|
|
|
|
if (hLibrary) {
|
|
|
|
gGetNumberOfInterfaces = NULL;
|
|
|
|
gGetIpAddrTable = NULL;
|
|
|
|
gGetIfEntry = NULL;
|
|
|
|
gGetFriendlyIfIndex = NULL;
|
|
|
|
gGetIfTable = NULL;
|
|
|
|
gGetIpForwardTable = NULL;
|
|
|
|
gGetIpNetTable = NULL;
|
|
|
|
gGetInterfaceInfo = NULL;
|
|
|
|
gGetAdaptersInfo = NULL;
|
|
|
|
gGetNetworkParams = NULL;
|
|
|
|
gGetIcmpStatistics = NULL;
|
|
|
|
gGetIpStatistics = NULL;
|
|
|
|
gGetTcpStatistics = NULL;
|
|
|
|
gGetUdpStatistics = NULL;
|
|
|
|
gGetTcpTable = NULL;
|
|
|
|
gGetUdpTable = NULL;
|
|
|
|
FreeLibrary(hLibrary);
|
|
|
|
hLibrary = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-10 17:50:50 +01:00
|
|
|
/* replacement for inet_ntoa */
|
|
|
|
static const char *ntoa( DWORD ip )
|
|
|
|
{
|
|
|
|
static char buffer[40];
|
|
|
|
|
|
|
|
ip = htonl(ip);
|
|
|
|
sprintf( buffer, "%u.%u.%u.%u", (ip >> 24) & 0xff, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff );
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2004-01-07 02:08:55 +01:00
|
|
|
/*
|
|
|
|
still-to-be-tested 98-only functions:
|
|
|
|
GetUniDirectionalAdapterInfo
|
|
|
|
*/
|
2005-07-05 13:05:50 +02:00
|
|
|
static void testWin98OnlyFunctions(void)
|
2004-01-07 02:08:55 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testGetNumberOfInterfaces(void)
|
|
|
|
{
|
|
|
|
if (gGetNumberOfInterfaces) {
|
2008-06-06 21:34:32 +02:00
|
|
|
DWORD apiReturn, numInterfaces;
|
|
|
|
|
|
|
|
/* Crashes on Vista */
|
|
|
|
if (0) {
|
|
|
|
apiReturn = gGetNumberOfInterfaces(NULL), numInterfaces;
|
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED)
|
|
|
|
return;
|
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
|
|
|
"GetNumberOfInterfaces(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
|
|
|
|
apiReturn);
|
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
apiReturn = gGetNumberOfInterfaces(&numInterfaces);
|
2008-06-06 21:34:32 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetNumberOfInterfaces is not supported\n");
|
|
|
|
return;
|
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetNumberOfInterfaces returned %d, expected 0\n", apiReturn);
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testGetIfEntry(DWORD index)
|
|
|
|
{
|
|
|
|
if (gGetIfEntry) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
MIB_IFROW row;
|
|
|
|
|
|
|
|
memset(&row, 0, sizeof(row));
|
|
|
|
apiReturn = gGetIfEntry(NULL);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetIfEntry is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIfEntry(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
row.dwIndex = -1; /* hope that's always bogus! */
|
|
|
|
apiReturn = gGetIfEntry(&row);
|
2008-06-06 21:37:51 +02:00
|
|
|
ok(apiReturn == ERROR_INVALID_DATA ||
|
|
|
|
apiReturn == ERROR_FILE_NOT_FOUND /* Vista */,
|
|
|
|
"GetIfEntry(bogus row) returned %d, expected ERROR_INVALID_DATA or ERROR_FILE_NOT_FOUND\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
row.dwIndex = index;
|
|
|
|
apiReturn = gGetIfEntry(&row);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIfEntry returned %d, expected NO_ERROR\n", apiReturn);
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testGetIpAddrTable(void)
|
|
|
|
{
|
|
|
|
if (gGetIpAddrTable) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
ULONG dwSize = 0;
|
|
|
|
|
|
|
|
apiReturn = gGetIpAddrTable(NULL, NULL, FALSE);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetIpAddrTable is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIpAddrTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
apiReturn = gGetIpAddrTable(NULL, &dwSize, FALSE);
|
|
|
|
ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIpAddrTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
|
2008-12-01 02:09:11 +01:00
|
|
|
PMIB_IPADDRTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
apiReturn = gGetIpAddrTable(buf, &dwSize, FALSE);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIpAddrTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
2004-05-07 01:39:59 +02:00
|
|
|
if (apiReturn == NO_ERROR && buf->dwNumEntries)
|
2004-01-07 02:08:55 +01:00
|
|
|
testGetIfEntry(buf->table[0].dwIndex);
|
2008-12-01 02:09:11 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testGetIfTable(void)
|
|
|
|
{
|
|
|
|
if (gGetIfTable) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
ULONG dwSize = 0;
|
|
|
|
|
|
|
|
apiReturn = gGetIfTable(NULL, NULL, FALSE);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetIfTable is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIfTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
apiReturn = gGetIfTable(NULL, &dwSize, FALSE);
|
|
|
|
ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIfTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
|
2008-12-01 02:09:11 +01:00
|
|
|
PMIB_IFTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
apiReturn = gGetIfTable(buf, &dwSize, FALSE);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIfTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
2009-03-10 17:50:50 +01:00
|
|
|
|
|
|
|
if (apiReturn == NO_ERROR && winetest_debug > 1)
|
|
|
|
{
|
|
|
|
DWORD i, j;
|
|
|
|
char name[MAX_INTERFACE_NAME_LEN];
|
|
|
|
|
|
|
|
trace( "interface table: %u entries\n", buf->dwNumEntries );
|
|
|
|
for (i = 0; i < buf->dwNumEntries; i++)
|
|
|
|
{
|
|
|
|
MIB_IFROW *row = &buf->table[i];
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, row->wszName, -1, name, MAX_INTERFACE_NAME_LEN, NULL, NULL );
|
|
|
|
trace( "%u: '%s' type %u mtu %u speed %u phys",
|
|
|
|
row->dwIndex, name, row->dwType, row->dwMtu, row->dwSpeed );
|
|
|
|
for (j = 0; j < row->dwPhysAddrLen; j++)
|
|
|
|
printf( " %02x", row->bPhysAddr[j] );
|
|
|
|
printf( "\n" );
|
|
|
|
trace( " in: bytes %u upkts %u nupkts %u disc %u err %u unk %u\n",
|
|
|
|
row->dwInOctets, row->dwInUcastPkts, row->dwInNUcastPkts,
|
|
|
|
row->dwInDiscards, row->dwInErrors, row->dwInUnknownProtos );
|
|
|
|
trace( " out: bytes %u upkts %u nupkts %u disc %u err %u\n",
|
|
|
|
row->dwOutOctets, row->dwOutUcastPkts, row->dwOutNUcastPkts,
|
|
|
|
row->dwOutDiscards, row->dwOutErrors );
|
|
|
|
}
|
|
|
|
}
|
2008-12-01 02:09:11 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testGetIpForwardTable(void)
|
|
|
|
{
|
|
|
|
if (gGetIpForwardTable) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
ULONG dwSize = 0;
|
|
|
|
|
|
|
|
apiReturn = gGetIpForwardTable(NULL, NULL, FALSE);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetIpForwardTable is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIpForwardTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
apiReturn = gGetIpForwardTable(NULL, &dwSize, FALSE);
|
|
|
|
ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIpForwardTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
|
2008-12-01 02:09:11 +01:00
|
|
|
PMIB_IPFORWARDTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
apiReturn = gGetIpForwardTable(buf, &dwSize, FALSE);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIpForwardTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
2009-03-10 17:50:50 +01:00
|
|
|
|
|
|
|
if (apiReturn == NO_ERROR && winetest_debug > 1)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
trace( "IP forward table: %u entries\n", buf->dwNumEntries );
|
|
|
|
for (i = 0; i < buf->dwNumEntries; i++)
|
|
|
|
{
|
|
|
|
char buffer[40];
|
|
|
|
sprintf( buffer, "dest %s", ntoa( buf->table[i].dwForwardDest ));
|
|
|
|
sprintf( buffer + strlen(buffer), " mask %s", ntoa( buf->table[i].dwForwardMask ));
|
|
|
|
trace( "%u: %s gw %s if %u type %u\n", i, buffer,
|
|
|
|
ntoa( buf->table[i].dwForwardNextHop ),
|
|
|
|
buf->table[i].dwForwardIfIndex, buf->table[i].dwForwardType );
|
|
|
|
}
|
|
|
|
}
|
2008-12-01 02:09:11 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-20 17:35:54 +02:00
|
|
|
static void testGetIpNetTable(void)
|
2004-01-07 02:08:55 +01:00
|
|
|
{
|
|
|
|
if (gGetIpNetTable) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
ULONG dwSize = 0;
|
|
|
|
|
|
|
|
apiReturn = gGetIpNetTable(NULL, NULL, FALSE);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetIpNetTable is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIpNetTable(NULL, NULL, FALSE) returned %d, expected ERROR_INVALID_PARAMETER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
apiReturn = gGetIpNetTable(NULL, &dwSize, FALSE);
|
|
|
|
ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_INSUFFICIENT_BUFFER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIpNetTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_NO_DATA or ERROR_INSUFFICIENT_BUFFER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
if (apiReturn == ERROR_NO_DATA)
|
|
|
|
; /* empty ARP table's okay */
|
|
|
|
else if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
|
2008-12-01 02:09:11 +01:00
|
|
|
PMIB_IPNETTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
apiReturn = gGetIpNetTable(buf, &dwSize, FALSE);
|
2008-12-30 14:09:03 +01:00
|
|
|
ok(apiReturn == NO_ERROR ||
|
|
|
|
apiReturn == ERROR_NO_DATA, /* empty ARP table's okay */
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIpNetTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
2009-03-10 17:50:50 +01:00
|
|
|
|
|
|
|
if (apiReturn == NO_ERROR && winetest_debug > 1)
|
|
|
|
{
|
|
|
|
DWORD i, j;
|
|
|
|
|
|
|
|
trace( "IP net table: %u entries\n", buf->dwNumEntries );
|
|
|
|
for (i = 0; i < buf->dwNumEntries; i++)
|
|
|
|
{
|
|
|
|
trace( "%u: idx %u type %u addr %s phys",
|
|
|
|
i, buf->table[i].dwIndex, buf->table[i].dwType, ntoa( buf->table[i].dwAddr ));
|
|
|
|
for (j = 0; j < buf->table[i].dwPhysAddrLen; j++)
|
|
|
|
printf( " %02x", buf->table[i].bPhysAddr[j] );
|
|
|
|
printf( "\n" );
|
|
|
|
}
|
|
|
|
}
|
2008-12-01 02:09:11 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-20 17:35:54 +02:00
|
|
|
static void testGetIcmpStatistics(void)
|
2004-01-07 02:08:55 +01:00
|
|
|
{
|
|
|
|
if (gGetIcmpStatistics) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
MIB_ICMP stats;
|
|
|
|
|
2008-06-06 21:34:32 +02:00
|
|
|
/* Crashes on Vista */
|
|
|
|
if (0) {
|
|
|
|
apiReturn = gGetIcmpStatistics(NULL);
|
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED)
|
|
|
|
return;
|
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
|
|
|
"GetIcmpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
|
|
|
|
apiReturn);
|
|
|
|
}
|
|
|
|
|
|
|
|
apiReturn = gGetIcmpStatistics(&stats);
|
2004-01-07 02:08:55 +01:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED)
|
2008-06-06 21:34:32 +02:00
|
|
|
{
|
|
|
|
skip("GetIcmpStatistics is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-06-06 21:34:32 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIcmpStatistics returned %d, expected NO_ERROR\n", apiReturn);
|
2009-03-10 17:50:50 +01:00
|
|
|
if (apiReturn == NO_ERROR && winetest_debug > 1)
|
|
|
|
{
|
|
|
|
trace( "ICMP stats: %8s %8s\n", "in", "out" );
|
|
|
|
trace( " dwMsgs: %8u %8u\n", stats.stats.icmpInStats.dwMsgs, stats.stats.icmpOutStats.dwMsgs );
|
|
|
|
trace( " dwErrors: %8u %8u\n", stats.stats.icmpInStats.dwErrors, stats.stats.icmpOutStats.dwErrors );
|
|
|
|
trace( " dwDestUnreachs: %8u %8u\n", stats.stats.icmpInStats.dwDestUnreachs, stats.stats.icmpOutStats.dwDestUnreachs );
|
|
|
|
trace( " dwTimeExcds: %8u %8u\n", stats.stats.icmpInStats.dwTimeExcds, stats.stats.icmpOutStats.dwTimeExcds );
|
|
|
|
trace( " dwParmProbs: %8u %8u\n", stats.stats.icmpInStats.dwParmProbs, stats.stats.icmpOutStats.dwParmProbs );
|
|
|
|
trace( " dwSrcQuenchs: %8u %8u\n", stats.stats.icmpInStats.dwSrcQuenchs, stats.stats.icmpOutStats.dwSrcQuenchs );
|
|
|
|
trace( " dwRedirects: %8u %8u\n", stats.stats.icmpInStats.dwRedirects, stats.stats.icmpOutStats.dwRedirects );
|
|
|
|
trace( " dwEchos: %8u %8u\n", stats.stats.icmpInStats.dwEchos, stats.stats.icmpOutStats.dwEchos );
|
|
|
|
trace( " dwEchoReps: %8u %8u\n", stats.stats.icmpInStats.dwEchoReps, stats.stats.icmpOutStats.dwEchoReps );
|
|
|
|
trace( " dwTimestamps: %8u %8u\n", stats.stats.icmpInStats.dwTimestamps, stats.stats.icmpOutStats.dwTimestamps );
|
|
|
|
trace( " dwTimestampReps: %8u %8u\n", stats.stats.icmpInStats.dwTimestampReps, stats.stats.icmpOutStats.dwTimestampReps );
|
|
|
|
trace( " dwAddrMasks: %8u %8u\n", stats.stats.icmpInStats.dwAddrMasks, stats.stats.icmpOutStats.dwAddrMasks );
|
|
|
|
trace( " dwAddrMaskReps: %8u %8u\n", stats.stats.icmpInStats.dwAddrMaskReps, stats.stats.icmpOutStats.dwAddrMaskReps );
|
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-20 17:35:54 +02:00
|
|
|
static void testGetIpStatistics(void)
|
2004-01-07 02:08:55 +01:00
|
|
|
{
|
|
|
|
if (gGetIpStatistics) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
MIB_IPSTATS stats;
|
|
|
|
|
|
|
|
apiReturn = gGetIpStatistics(NULL);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetIpStatistics is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
apiReturn = gGetIpStatistics(&stats);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetIpStatistics returned %d, expected NO_ERROR\n", apiReturn);
|
2009-03-10 17:50:50 +01:00
|
|
|
if (apiReturn == NO_ERROR && winetest_debug > 1)
|
|
|
|
{
|
|
|
|
trace( "IP stats:\n" );
|
|
|
|
trace( " dwForwarding: %u\n", stats.dwForwarding );
|
|
|
|
trace( " dwDefaultTTL: %u\n", stats.dwDefaultTTL );
|
|
|
|
trace( " dwInReceives: %u\n", stats.dwInReceives );
|
|
|
|
trace( " dwInHdrErrors: %u\n", stats.dwInHdrErrors );
|
|
|
|
trace( " dwInAddrErrors: %u\n", stats.dwInAddrErrors );
|
|
|
|
trace( " dwForwDatagrams: %u\n", stats.dwForwDatagrams );
|
|
|
|
trace( " dwInUnknownProtos: %u\n", stats.dwInUnknownProtos );
|
|
|
|
trace( " dwInDiscards: %u\n", stats.dwInDiscards );
|
|
|
|
trace( " dwInDelivers: %u\n", stats.dwInDelivers );
|
|
|
|
trace( " dwOutRequests: %u\n", stats.dwOutRequests );
|
|
|
|
trace( " dwRoutingDiscards: %u\n", stats.dwRoutingDiscards );
|
|
|
|
trace( " dwOutDiscards: %u\n", stats.dwOutDiscards );
|
|
|
|
trace( " dwOutNoRoutes: %u\n", stats.dwOutNoRoutes );
|
|
|
|
trace( " dwReasmTimeout: %u\n", stats.dwReasmTimeout );
|
|
|
|
trace( " dwReasmReqds: %u\n", stats.dwReasmReqds );
|
|
|
|
trace( " dwReasmOks: %u\n", stats.dwReasmOks );
|
|
|
|
trace( " dwReasmFails: %u\n", stats.dwReasmFails );
|
|
|
|
trace( " dwFragOks: %u\n", stats.dwFragOks );
|
|
|
|
trace( " dwFragFails: %u\n", stats.dwFragFails );
|
|
|
|
trace( " dwFragCreates: %u\n", stats.dwFragCreates );
|
|
|
|
trace( " dwNumIf: %u\n", stats.dwNumIf );
|
|
|
|
trace( " dwNumAddr: %u\n", stats.dwNumAddr );
|
|
|
|
trace( " dwNumRoutes: %u\n", stats.dwNumRoutes );
|
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-20 17:35:54 +02:00
|
|
|
static void testGetTcpStatistics(void)
|
2004-01-07 02:08:55 +01:00
|
|
|
{
|
|
|
|
if (gGetTcpStatistics) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
MIB_TCPSTATS stats;
|
|
|
|
|
|
|
|
apiReturn = gGetTcpStatistics(NULL);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetTcpStatistics is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetTcpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
apiReturn = gGetTcpStatistics(&stats);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetTcpStatistics returned %d, expected NO_ERROR\n", apiReturn);
|
2009-03-10 17:50:50 +01:00
|
|
|
if (apiReturn == NO_ERROR && winetest_debug > 1)
|
|
|
|
{
|
|
|
|
trace( "TCP stats:\n" );
|
|
|
|
trace( " dwRtoAlgorithm: %u\n", stats.dwRtoAlgorithm );
|
|
|
|
trace( " dwRtoMin: %u\n", stats.dwRtoMin );
|
|
|
|
trace( " dwRtoMax: %u\n", stats.dwRtoMax );
|
|
|
|
trace( " dwMaxConn: %u\n", stats.dwMaxConn );
|
|
|
|
trace( " dwActiveOpens: %u\n", stats.dwActiveOpens );
|
|
|
|
trace( " dwPassiveOpens: %u\n", stats.dwPassiveOpens );
|
|
|
|
trace( " dwAttemptFails: %u\n", stats.dwAttemptFails );
|
|
|
|
trace( " dwEstabResets: %u\n", stats.dwEstabResets );
|
|
|
|
trace( " dwCurrEstab: %u\n", stats.dwCurrEstab );
|
|
|
|
trace( " dwInSegs: %u\n", stats.dwInSegs );
|
|
|
|
trace( " dwOutSegs: %u\n", stats.dwOutSegs );
|
|
|
|
trace( " dwRetransSegs: %u\n", stats.dwRetransSegs );
|
|
|
|
trace( " dwInErrs: %u\n", stats.dwInErrs );
|
|
|
|
trace( " dwOutRsts: %u\n", stats.dwOutRsts );
|
|
|
|
trace( " dwNumConns: %u\n", stats.dwNumConns );
|
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-20 17:35:54 +02:00
|
|
|
static void testGetUdpStatistics(void)
|
2004-01-07 02:08:55 +01:00
|
|
|
{
|
|
|
|
if (gGetUdpStatistics) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
MIB_UDPSTATS stats;
|
|
|
|
|
|
|
|
apiReturn = gGetUdpStatistics(NULL);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetUdpStatistics is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetUdpStatistics(NULL) returned %d, expected ERROR_INVALID_PARAMETER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
apiReturn = gGetUdpStatistics(&stats);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetUdpStatistics returned %d, expected NO_ERROR\n", apiReturn);
|
2009-03-10 17:50:50 +01:00
|
|
|
if (apiReturn == NO_ERROR && winetest_debug > 1)
|
|
|
|
{
|
|
|
|
trace( "UDP stats:\n" );
|
|
|
|
trace( " dwInDatagrams: %u\n", stats.dwInDatagrams );
|
|
|
|
trace( " dwNoPorts: %u\n", stats.dwNoPorts );
|
|
|
|
trace( " dwInErrors: %u\n", stats.dwInErrors );
|
|
|
|
trace( " dwOutDatagrams: %u\n", stats.dwOutDatagrams );
|
|
|
|
trace( " dwNumAddrs: %u\n", stats.dwNumAddrs );
|
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-20 17:35:54 +02:00
|
|
|
static void testGetTcpTable(void)
|
2004-01-07 02:08:55 +01:00
|
|
|
{
|
|
|
|
if (gGetTcpTable) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
ULONG dwSize = 0;
|
|
|
|
|
2009-03-05 23:17:35 +01:00
|
|
|
apiReturn = gGetTcpTable(NULL, &dwSize, FALSE);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetTcpTable is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2008-09-03 05:51:37 +02:00
|
|
|
ok(apiReturn == ERROR_INSUFFICIENT_BUFFER ||
|
|
|
|
broken(apiReturn == ERROR_NO_DATA), /* win95 */
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetTcpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
|
2008-12-01 02:09:11 +01:00
|
|
|
PMIB_TCPTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
apiReturn = gGetTcpTable(buf, &dwSize, FALSE);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetTcpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
2009-03-10 17:50:50 +01:00
|
|
|
|
|
|
|
if (apiReturn == NO_ERROR && winetest_debug > 1)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
trace( "TCP table: %u entries\n", buf->dwNumEntries );
|
|
|
|
for (i = 0; i < buf->dwNumEntries; i++)
|
|
|
|
{
|
|
|
|
char buffer[40];
|
|
|
|
sprintf( buffer, "local %s:%u",
|
|
|
|
ntoa(buf->table[i].dwLocalAddr), ntohs(buf->table[i].dwLocalPort) );
|
|
|
|
trace( "%u: %s remote %s:%u state %u\n",
|
|
|
|
i, buffer, ntoa( buf->table[i].dwRemoteAddr ),
|
|
|
|
ntohs(buf->table[i].dwRemotePort), buf->table[i].dwState );
|
|
|
|
}
|
|
|
|
}
|
2008-12-01 02:09:11 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-20 17:35:54 +02:00
|
|
|
static void testGetUdpTable(void)
|
2004-01-07 02:08:55 +01:00
|
|
|
{
|
|
|
|
if (gGetUdpTable) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
ULONG dwSize = 0;
|
|
|
|
|
2009-03-05 23:17:35 +01:00
|
|
|
apiReturn = gGetUdpTable(NULL, &dwSize, FALSE);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetUdpTable is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetUdpTable(NULL, &dwSize, FALSE) returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
2009-03-10 17:50:50 +01:00
|
|
|
if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
|
2008-12-01 02:09:11 +01:00
|
|
|
PMIB_UDPTABLE buf = HeapAlloc(GetProcessHeap(), 0, dwSize);
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
apiReturn = gGetUdpTable(buf, &dwSize, FALSE);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetUdpTable(buf, &dwSize, FALSE) returned %d, expected NO_ERROR\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
2009-03-10 17:50:50 +01:00
|
|
|
|
|
|
|
if (apiReturn == NO_ERROR && winetest_debug > 1)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
trace( "UDP table: %u entries\n", buf->dwNumEntries );
|
|
|
|
for (i = 0; i < buf->dwNumEntries; i++)
|
|
|
|
trace( "%u: %s:%u\n",
|
|
|
|
i, ntoa( buf->table[i].dwLocalAddr ), ntohs(buf->table[i].dwLocalPort) );
|
|
|
|
}
|
2008-12-01 02:09:11 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
still-to-be-tested NT4-onward functions:
|
|
|
|
CreateIpForwardEntry
|
|
|
|
DeleteIpForwardEntry
|
|
|
|
CreateIpNetEntry
|
|
|
|
DeleteIpNetEntry
|
|
|
|
GetFriendlyIfIndex
|
|
|
|
GetRTTAndHopCount
|
|
|
|
SetIfEntry
|
|
|
|
SetIpForwardEntry
|
|
|
|
SetIpNetEntry
|
|
|
|
SetIpStatistics
|
|
|
|
SetIpTTL
|
|
|
|
SetTcpEntry
|
|
|
|
*/
|
|
|
|
static void testWinNT4Functions(void)
|
|
|
|
{
|
|
|
|
testGetNumberOfInterfaces();
|
|
|
|
testGetIpAddrTable();
|
|
|
|
testGetIfTable();
|
|
|
|
testGetIpForwardTable();
|
|
|
|
testGetIpNetTable();
|
|
|
|
testGetIcmpStatistics();
|
|
|
|
testGetIpStatistics();
|
|
|
|
testGetTcpStatistics();
|
|
|
|
testGetUdpStatistics();
|
|
|
|
testGetTcpTable();
|
|
|
|
testGetUdpTable();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testGetInterfaceInfo(void)
|
|
|
|
{
|
|
|
|
if (gGetInterfaceInfo) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
ULONG len = 0;
|
|
|
|
|
|
|
|
apiReturn = gGetInterfaceInfo(NULL, NULL);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetInterfaceInfo is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetInterfaceInfo returned %d, expected ERROR_INVALID_PARAMETER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
apiReturn = gGetInterfaceInfo(NULL, &len);
|
|
|
|
ok(apiReturn == ERROR_INSUFFICIENT_BUFFER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetInterfaceInfo returned %d, expected ERROR_INSUFFICIENT_BUFFER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
if (apiReturn == ERROR_INSUFFICIENT_BUFFER) {
|
2008-12-01 02:09:11 +01:00
|
|
|
PIP_INTERFACE_INFO buf = HeapAlloc(GetProcessHeap(), 0, len);
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
apiReturn = gGetInterfaceInfo(buf, &len);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetInterfaceInfo(buf, &dwSize) returned %d, expected NO_ERROR\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
2008-12-01 02:09:11 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testGetAdaptersInfo(void)
|
|
|
|
{
|
|
|
|
if (gGetAdaptersInfo) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
ULONG len = 0;
|
|
|
|
|
|
|
|
apiReturn = gGetAdaptersInfo(NULL, NULL);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetAdaptersInfo is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetAdaptersInfo returned %d, expected ERROR_INVALID_PARAMETER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
apiReturn = gGetAdaptersInfo(NULL, &len);
|
|
|
|
ok(apiReturn == ERROR_NO_DATA || apiReturn == ERROR_BUFFER_OVERFLOW,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetAdaptersInfo returned %d, expected ERROR_NO_DATA or ERROR_BUFFER_OVERFLOW\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
if (apiReturn == ERROR_NO_DATA)
|
|
|
|
; /* no adapter's, that's okay */
|
|
|
|
else if (apiReturn == ERROR_BUFFER_OVERFLOW) {
|
2008-12-01 02:09:11 +01:00
|
|
|
PIP_ADAPTER_INFO buf = HeapAlloc(GetProcessHeap(), 0, len);
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
apiReturn = gGetAdaptersInfo(buf, &len);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetAdaptersInfo(buf, &dwSize) returned %d, expected NO_ERROR\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
2008-12-01 02:09:11 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testGetNetworkParams(void)
|
|
|
|
{
|
|
|
|
if (gGetNetworkParams) {
|
|
|
|
DWORD apiReturn;
|
|
|
|
ULONG len = 0;
|
|
|
|
|
|
|
|
apiReturn = gGetNetworkParams(NULL, NULL);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (apiReturn == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetNetworkParams is not supported\n");
|
2004-01-07 02:08:55 +01:00
|
|
|
return;
|
2008-08-04 14:29:41 +02:00
|
|
|
}
|
2004-01-07 02:08:55 +01:00
|
|
|
ok(apiReturn == ERROR_INVALID_PARAMETER,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetNetworkParams returned %d, expected ERROR_INVALID_PARAMETER\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
apiReturn = gGetNetworkParams(NULL, &len);
|
|
|
|
ok(apiReturn == ERROR_BUFFER_OVERFLOW,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetNetworkParams returned %d, expected ERROR_BUFFER_OVERFLOW\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
|
|
|
if (apiReturn == ERROR_BUFFER_OVERFLOW) {
|
2008-12-01 02:09:11 +01:00
|
|
|
PFIXED_INFO buf = HeapAlloc(GetProcessHeap(), 0, len);
|
2004-01-07 02:08:55 +01:00
|
|
|
|
|
|
|
apiReturn = gGetNetworkParams(buf, &len);
|
|
|
|
ok(apiReturn == NO_ERROR,
|
2006-10-07 20:18:10 +02:00
|
|
|
"GetNetworkParams(buf, &dwSize) returned %d, expected NO_ERROR\n",
|
2004-01-07 02:08:55 +01:00
|
|
|
apiReturn);
|
2008-12-01 02:09:11 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
still-to-be-tested 98-onward functions:
|
|
|
|
GetBestInterface
|
|
|
|
GetBestRoute
|
|
|
|
IpReleaseAddress
|
|
|
|
IpRenewAddress
|
|
|
|
*/
|
|
|
|
static void testWin98Functions(void)
|
|
|
|
{
|
|
|
|
testGetInterfaceInfo();
|
|
|
|
testGetAdaptersInfo();
|
|
|
|
testGetNetworkParams();
|
|
|
|
}
|
|
|
|
|
2008-07-02 17:27:37 +02:00
|
|
|
static void testGetPerAdapterInfo(void)
|
|
|
|
{
|
|
|
|
DWORD ret, needed;
|
|
|
|
void *buffer;
|
|
|
|
|
|
|
|
if (!gGetPerAdapterInfo) return;
|
|
|
|
ret = gGetPerAdapterInfo(1, NULL, NULL);
|
2008-08-04 14:29:41 +02:00
|
|
|
if (ret == ERROR_NOT_SUPPORTED) {
|
|
|
|
skip("GetPerAdapterInfo is not supported\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-07-02 17:27:37 +02:00
|
|
|
ok( ret == ERROR_INVALID_PARAMETER, "got %u instead of ERROR_INVALID_PARAMETER\n", ret );
|
|
|
|
needed = 0xdeadbeef;
|
|
|
|
ret = gGetPerAdapterInfo(1, NULL, &needed);
|
|
|
|
if (ret == ERROR_NO_DATA) return; /* no such adapter */
|
|
|
|
ok( ret == ERROR_BUFFER_OVERFLOW, "got %u instead of ERROR_BUFFER_OVERFLOW\n", ret );
|
|
|
|
ok( needed != 0xdeadbeef, "needed not set\n" );
|
|
|
|
buffer = HeapAlloc( GetProcessHeap(), 0, needed );
|
|
|
|
ret = gGetPerAdapterInfo(1, buffer, &needed);
|
|
|
|
ok( ret == NO_ERROR, "got %u instead of NO_ERROR\n", ret );
|
|
|
|
HeapFree( GetProcessHeap(), 0, buffer );
|
|
|
|
}
|
|
|
|
|
2004-01-07 02:08:55 +01:00
|
|
|
/*
|
|
|
|
still-to-be-tested 2K-onward functions:
|
|
|
|
AddIPAddress
|
|
|
|
CreateProxyArpEntry
|
|
|
|
DeleteIPAddress
|
|
|
|
DeleteProxyArpEntry
|
|
|
|
EnableRouter
|
|
|
|
FlushIpNetTable
|
|
|
|
GetAdapterIndex
|
|
|
|
NotifyAddrChange
|
|
|
|
NotifyRouteChange
|
|
|
|
SendARP
|
|
|
|
UnenableRouter
|
|
|
|
*/
|
|
|
|
static void testWin2KFunctions(void)
|
|
|
|
{
|
2008-07-02 17:27:37 +02:00
|
|
|
testGetPerAdapterInfo();
|
2004-01-07 02:08:55 +01:00
|
|
|
}
|
|
|
|
|
2009-04-29 11:57:48 +02:00
|
|
|
static void test_GetAdaptersAddresses(void)
|
|
|
|
{
|
|
|
|
ULONG ret, size;
|
|
|
|
IP_ADAPTER_ADDRESSES *aa;
|
|
|
|
IP_ADAPTER_UNICAST_ADDRESS *ua;
|
|
|
|
|
|
|
|
if (!gGetAdaptersAddresses)
|
|
|
|
{
|
|
|
|
win_skip("GetAdaptersAddresses not present\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, NULL);
|
|
|
|
ok(ret == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", ret);
|
|
|
|
|
2009-07-03 11:31:10 +02:00
|
|
|
size = 0;
|
2009-04-29 11:57:48 +02:00
|
|
|
ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size);
|
|
|
|
ok(ret == ERROR_BUFFER_OVERFLOW, "expected ERROR_BUFFER_OVERFLOW, got %u\n", ret);
|
|
|
|
if (ret != ERROR_BUFFER_OVERFLOW) return;
|
|
|
|
|
|
|
|
aa = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
ret = gGetAdaptersAddresses(AF_UNSPEC, 0, NULL, aa, &size);
|
|
|
|
ok(!ret, "expected ERROR_SUCCESS got %u\n", ret);
|
|
|
|
|
|
|
|
while (!ret && winetest_debug > 1 && aa)
|
|
|
|
{
|
2009-08-31 11:52:21 +02:00
|
|
|
trace("Length: %u\n", S(U(*aa)).Length);
|
|
|
|
trace("IfIndex: %u\n", S(U(*aa)).IfIndex);
|
2009-04-29 11:57:48 +02:00
|
|
|
trace("Next: %p\n", aa->Next);
|
|
|
|
trace("AdapterName: %s\n", aa->AdapterName);
|
|
|
|
trace("FirstUnicastAddress: %p\n", aa->FirstUnicastAddress);
|
|
|
|
ua = aa->FirstUnicastAddress;
|
|
|
|
while (ua)
|
|
|
|
{
|
2009-08-31 11:52:21 +02:00
|
|
|
trace("\tLength: %u\n", S(U(*ua)).Length);
|
|
|
|
trace("\tFlags: 0x%08x\n", S(U(*ua)).Flags);
|
2009-04-29 11:57:48 +02:00
|
|
|
trace("\tNext: %p\n", ua->Next);
|
|
|
|
trace("\tAddress.lpSockaddr: %p\n", ua->Address.lpSockaddr);
|
|
|
|
trace("\tAddress.iSockaddrLength: %d\n", ua->Address.iSockaddrLength);
|
|
|
|
trace("\tPrefixOrigin: %u\n", ua->PrefixOrigin);
|
|
|
|
trace("\tSuffixOrigin: %u\n", ua->SuffixOrigin);
|
|
|
|
trace("\tDadState: %u\n", ua->DadState);
|
|
|
|
trace("\tValidLifetime: 0x%08x\n", ua->ValidLifetime);
|
|
|
|
trace("\tPreferredLifetime: 0x%08x\n", ua->PreferredLifetime);
|
|
|
|
trace("\tLeaseLifetime: 0x%08x\n", ua->LeaseLifetime);
|
|
|
|
trace("\n");
|
|
|
|
ua = ua->Next;
|
|
|
|
}
|
|
|
|
trace("FirstAnycastAddress: %p\n", aa->FirstAnycastAddress);
|
|
|
|
trace("FirstMulticastAddress: %p\n", aa->FirstMulticastAddress);
|
|
|
|
trace("FirstDnsServerAddress: %p\n", aa->FirstDnsServerAddress);
|
|
|
|
trace("DnsSuffix: %p\n", aa->DnsSuffix);
|
|
|
|
trace("Description: %p\n", aa->Description);
|
|
|
|
trace("FriendlyName: %p\n", aa->FriendlyName);
|
|
|
|
trace("PhysicalAddress: %02x\n", aa->PhysicalAddress[0]);
|
|
|
|
trace("PhysicalAddressLength: %u\n", aa->PhysicalAddressLength);
|
|
|
|
trace("Flags: 0x%08x\n", aa->Flags);
|
|
|
|
trace("Mtu: %u\n", aa->Mtu);
|
|
|
|
trace("IfType: %u\n", aa->IfType);
|
|
|
|
trace("OperStatus: %u\n", aa->OperStatus);
|
|
|
|
trace("\n");
|
|
|
|
aa = aa->Next;
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, aa);
|
|
|
|
}
|
|
|
|
|
2004-01-07 02:08:55 +01:00
|
|
|
START_TEST(iphlpapi)
|
|
|
|
{
|
|
|
|
|
|
|
|
loadIPHlpApi();
|
|
|
|
if (hLibrary) {
|
|
|
|
testWin98OnlyFunctions();
|
|
|
|
testWinNT4Functions();
|
|
|
|
testWin98Functions();
|
|
|
|
testWin2KFunctions();
|
2009-04-29 11:57:48 +02:00
|
|
|
test_GetAdaptersAddresses();
|
2004-01-07 02:08:55 +01:00
|
|
|
freeIPHlpApi();
|
|
|
|
}
|
|
|
|
}
|