Commit c77b11eb authored by André Hentschel's avatar André Hentschel Committed by Alexandre Julliard

iphlpapi/tests: Add test for AllocateAndGetTcpExTableFromStack.

parent fdf80ad7
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
static HMODULE hLibrary = NULL; static HMODULE hLibrary = NULL;
static DWORD (WINAPI *pAllocateAndGetTcpExTableFromStack)(void**,BOOL,HANDLE,DWORD,DWORD);
static DWORD (WINAPI *pGetNumberOfInterfaces)(PDWORD); static DWORD (WINAPI *pGetNumberOfInterfaces)(PDWORD);
static DWORD (WINAPI *pGetIpAddrTable)(PMIB_IPADDRTABLE,PULONG,BOOL); static DWORD (WINAPI *pGetIpAddrTable)(PMIB_IPADDRTABLE,PULONG,BOOL);
static DWORD (WINAPI *pGetIfEntry)(PMIB_IFROW); static DWORD (WINAPI *pGetIfEntry)(PMIB_IFROW);
...@@ -97,6 +98,7 @@ static void loadIPHlpApi(void) ...@@ -97,6 +98,7 @@ static void loadIPHlpApi(void)
{ {
hLibrary = LoadLibraryA("iphlpapi.dll"); hLibrary = LoadLibraryA("iphlpapi.dll");
if (hLibrary) { if (hLibrary) {
pAllocateAndGetTcpExTableFromStack = (void *)GetProcAddress(hLibrary, "AllocateAndGetTcpExTableFromStack");
pGetNumberOfInterfaces = (void *)GetProcAddress(hLibrary, "GetNumberOfInterfaces"); pGetNumberOfInterfaces = (void *)GetProcAddress(hLibrary, "GetNumberOfInterfaces");
pGetIpAddrTable = (void *)GetProcAddress(hLibrary, "GetIpAddrTable"); pGetIpAddrTable = (void *)GetProcAddress(hLibrary, "GetIpAddrTable");
pGetIfEntry = (void *)GetProcAddress(hLibrary, "GetIfEntry"); pGetIfEntry = (void *)GetProcAddress(hLibrary, "GetIfEntry");
...@@ -1562,6 +1564,52 @@ static void test_GetExtendedTcpTable(void) ...@@ -1562,6 +1564,52 @@ static void test_GetExtendedTcpTable(void)
HeapFree( GetProcessHeap(), 0, table_module ); HeapFree( GetProcessHeap(), 0, table_module );
} }
static void test_AllocateAndGetTcpExTableFromStack(void)
{
DWORD ret;
MIB_TCPTABLE_OWNER_PID *table_ex = NULL;
if (!pAllocateAndGetTcpExTableFromStack)
{
skip("AllocateAndGetTcpExTableFromStack not available\n");
return;
}
if (0)
{
/* crashes on native */
ret = pAllocateAndGetTcpExTableFromStack( NULL, FALSE, INVALID_HANDLE_VALUE, 0, 0 );
ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
ret = pAllocateAndGetTcpExTableFromStack( (void **)&table_ex, FALSE, INVALID_HANDLE_VALUE, 0, AF_INET );
ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
ret = pAllocateAndGetTcpExTableFromStack( (void **)NULL, FALSE, GetProcessHeap(), 0, AF_INET );
ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
}
ret = pAllocateAndGetTcpExTableFromStack( (void **)&table_ex, FALSE, GetProcessHeap(), 0, 0 );
ok( ret == ERROR_INVALID_PARAMETER || broken(ERROR_NOT_SUPPORTED) /* win2k */, "got %u\n", ret );
ret = pAllocateAndGetTcpExTableFromStack( (void **)&table_ex, FALSE, GetProcessHeap(), 0, AF_INET );
ok( ret == ERROR_SUCCESS, "got %u\n", ret );
if (ret == NO_ERROR && winetest_debug > 1)
{
DWORD i;
trace( "AllocateAndGetTcpExTableFromStack table: %u entries\n", table_ex->dwNumEntries );
for (i = 0; i < table_ex->dwNumEntries; i++)
{
trace( "%u: local %s:%u remote %s:%u state %u pid %u\n", i,
ntoa(table_ex->table[i].dwLocalAddr), ntohs(table_ex->table[i].dwLocalPort),
ntoa( table_ex->table[i].dwRemoteAddr ), ntohs(table_ex->table[i].dwRemotePort),
U(table_ex->table[i]).dwState, table_ex->table[i].dwOwningPid );
}
}
HeapFree(GetProcessHeap(), 0, table_ex);
ret = pAllocateAndGetTcpExTableFromStack( (void **)&table_ex, FALSE, GetProcessHeap(), 0, AF_INET6 );
ok( ret == ERROR_NOT_SUPPORTED, "got %u\n", ret );
}
static void test_GetExtendedUdpTable(void) static void test_GetExtendedUdpTable(void)
{ {
DWORD ret, size; DWORD ret, size;
...@@ -1923,6 +1971,7 @@ START_TEST(iphlpapi) ...@@ -1923,6 +1971,7 @@ START_TEST(iphlpapi)
test_GetAdaptersAddresses(); test_GetAdaptersAddresses();
test_GetExtendedTcpTable(); test_GetExtendedTcpTable();
test_GetExtendedUdpTable(); test_GetExtendedUdpTable();
test_AllocateAndGetTcpExTableFromStack();
test_CreateSortedAddressPairs(); test_CreateSortedAddressPairs();
test_interface_identifier_conversion(); test_interface_identifier_conversion();
test_GetIfEntry2(); test_GetIfEntry2();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment