Commit 18ba68ea authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

iphlpapi: Implement GetExtendedUdpTable.

parent bde51568
......@@ -81,7 +81,7 @@
@ stub GetBestRouteFromStack
#@ stub GetCurrentThreadCompartmentId
@ stdcall GetExtendedTcpTable( ptr ptr long long long long )
#@ stub GetExtendedUdpTable
@ stdcall GetExtendedUdpTable( ptr ptr long long long long )
@ stdcall GetFriendlyIfIndex( long )
#@ stub GetIcmpStatisticsEx
@ stdcall GetIcmpStatistics( ptr )
......
......@@ -1917,31 +1917,46 @@ DWORD WINAPI GetExtendedTcpTable(PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder,
*/
DWORD WINAPI GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
{
DWORD ret;
PMIB_UDPTABLE table;
return GetExtendedUdpTable(pUdpTable, pdwSize, bOrder, AF_INET, UDP_TABLE_BASIC, 0);
}
TRACE("pUdpTable %p, pdwSize %p, bOrder %d\n", pUdpTable, pdwSize, bOrder);
/******************************************************************
* GetExtendedUdpTable (IPHLPAPI.@)
*/
DWORD WINAPI GetExtendedUdpTable(PVOID pUdpTable, PDWORD pdwSize, BOOL bOrder,
ULONG ulAf, UDP_TABLE_CLASS TableClass, ULONG Reserved)
{
DWORD ret, size;
void *table;
TRACE("pUdpTable %p, pdwSize %p, bOrder %d, ulAf %u, TableClass %u, Reserved %u\n",
pUdpTable, pdwSize, bOrder, ulAf, TableClass, Reserved);
if (!pdwSize) return ERROR_INVALID_PARAMETER;
ret = AllocateAndGetUdpTableFromStack( &table, bOrder, GetProcessHeap(), 0 );
if (!ret) {
DWORD size = FIELD_OFFSET( MIB_UDPTABLE, table[table->dwNumEntries] );
if (!pUdpTable || *pdwSize < size) {
*pdwSize = size;
ret = ERROR_INSUFFICIENT_BUFFER;
}
else {
*pdwSize = size;
memcpy(pUdpTable, table, size);
}
HeapFree(GetProcessHeap(), 0, table);
if (ulAf != AF_INET ||
(TableClass != UDP_TABLE_BASIC && TableClass != UDP_TABLE_OWNER_PID))
{
FIXME("ulAf = %u, TableClass = %u not supported\n", ulAf, TableClass);
return ERROR_NOT_SUPPORTED;
}
TRACE("returning %d\n", ret);
if ((ret = build_udp_table(TableClass, &table, bOrder, GetProcessHeap(), 0, &size)))
return ret;
if (!pUdpTable || *pdwSize < size)
{
*pdwSize = size;
ret = ERROR_INSUFFICIENT_BUFFER;
}
else
{
*pdwSize = size;
memcpy(pUdpTable, table, size);
}
HeapFree(GetProcessHeap(), 0, table);
return ret;
}
/******************************************************************
* GetUniDirectionalAdapterInfo (IPHLPAPI.@)
*
......
......@@ -38,5 +38,6 @@ DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable, BO
DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForwardTable, BOOL bOrder, HANDLE heap, DWORD flags) DECLSPEC_HIDDEN;
DWORD build_tcp_table(TCP_TABLE_CLASS, void **, BOOL, HANDLE, DWORD, DWORD *) DECLSPEC_HIDDEN;
DWORD build_udp_table(UDP_TABLE_CLASS, void **, BOOL, HANDLE, DWORD, DWORD *) DECLSPEC_HIDDEN;
#endif /* ndef WINE_IPSTATS_H_ */
......@@ -71,6 +71,7 @@ static DWORD (WINAPI *pGetAdaptersAddresses)(ULONG,ULONG,PVOID,PIP_ADAPTER_ADDRE
static DWORD (WINAPI *pNotifyAddrChange)(PHANDLE,LPOVERLAPPED);
static BOOL (WINAPI *pCancelIPChangeNotify)(LPOVERLAPPED);
static DWORD (WINAPI *pGetExtendedTcpTable)(PVOID,PDWORD,BOOL,ULONG,TCP_TABLE_CLASS,ULONG);
static DWORD (WINAPI *pGetExtendedUdpTable)(PVOID,PDWORD,BOOL,ULONG,UDP_TABLE_CLASS,ULONG);
static DWORD (WINAPI *pSetTcpEntry)(PMIB_TCPROW);
static void loadIPHlpApi(void)
......@@ -102,6 +103,7 @@ static void loadIPHlpApi(void)
pNotifyAddrChange = (void *)GetProcAddress(hLibrary, "NotifyAddrChange");
pCancelIPChangeNotify = (void *)GetProcAddress(hLibrary, "CancelIPChangeNotify");
pGetExtendedTcpTable = (void *)GetProcAddress(hLibrary, "GetExtendedTcpTable");
pGetExtendedUdpTable = (void *)GetProcAddress(hLibrary, "GetExtendedUdpTable");
pSetTcpEntry = (void *)GetProcAddress(hLibrary, "SetTcpEntry");
}
}
......@@ -1203,6 +1205,39 @@ static void test_GetExtendedTcpTable(void)
HeapFree( GetProcessHeap(), 0, table_pid );
}
static void test_GetExtendedUdpTable(void)
{
DWORD ret, size;
MIB_UDPTABLE *table;
MIB_UDPTABLE_OWNER_PID *table_pid;
if (!pGetExtendedUdpTable)
{
win_skip("GetExtendedUdpTable not available\n");
return;
}
ret = pGetExtendedUdpTable( NULL, NULL, TRUE, AF_INET, UDP_TABLE_BASIC, 0 );
ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
size = 0;
ret = pGetExtendedUdpTable( NULL, &size, TRUE, AF_INET, UDP_TABLE_BASIC, 0 );
ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
table = HeapAlloc( GetProcessHeap(), 0, size );
ret = pGetExtendedUdpTable( table, &size, TRUE, AF_INET, UDP_TABLE_BASIC, 0 );
ok( ret == ERROR_SUCCESS, "got %u\n", ret );
HeapFree( GetProcessHeap(), 0, table );
size = 0;
ret = pGetExtendedUdpTable( NULL, &size, TRUE, AF_INET, UDP_TABLE_OWNER_PID, 0 );
ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
table_pid = HeapAlloc( GetProcessHeap(), 0, size );
ret = pGetExtendedUdpTable( table_pid, &size, TRUE, AF_INET, UDP_TABLE_OWNER_PID, 0 );
ok( ret == ERROR_SUCCESS, "got %u\n", ret );
HeapFree( GetProcessHeap(), 0, table_pid );
}
START_TEST(iphlpapi)
{
......@@ -1221,6 +1256,7 @@ START_TEST(iphlpapi)
testWin2KFunctions();
test_GetAdaptersAddresses();
test_GetExtendedTcpTable();
test_GetExtendedUdpTable();
freeIPHlpApi();
}
}
......@@ -29,6 +29,9 @@ extern "C" {
DWORD WINAPI GetExtendedTcpTable(PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder,
ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved);
DWORD WINAPI GetExtendedUdpTable(PVOID pUdpTable, PDWORD pdwSize, BOOL bOrder,
ULONG ulAf, UDP_TABLE_CLASS TableClass, ULONG Reserved);
DWORD WINAPI GetNumberOfInterfaces(PDWORD pdwNumIf);
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow);
......
......@@ -38,4 +38,11 @@ typedef enum _TCP_TABLE_CLASS
TCP_TABLE_OWNER_MODULE_ALL
} TCP_TABLE_CLASS, *PTCP_TABLE_CLASS;
typedef enum _UDP_TABLE_CLASS
{
UDP_TABLE_BASIC,
UDP_TABLE_OWNER_PID,
UDP_TABLE_OWNER_MODULE
} UDP_TABLE_CLASS, *PUDP_TABLE_CLASS;
#endif /* WINE_IPRTRMIB_H__ */
......@@ -39,6 +39,7 @@ typedef struct _MIB_UDPROW_OWNER_PID
{
DWORD dwLocalAddr;
DWORD dwLocalPort;
DWORD dwOwningPid;
} MIB_UDPROW_OWNER_PID, *PMIB_UDPROW_OWNER_PID;
typedef struct _MIB_UDPTABLE_OWNER_PID
......@@ -47,7 +48,6 @@ typedef struct _MIB_UDPTABLE_OWNER_PID
MIB_UDPROW_OWNER_PID table[1];
} MIB_UDPTABLE_OWNER_PID, *PMIB_UDPTABLE_OWNER_PID;
/* UDP statistics */
typedef struct _MIB_UDPSTATS
......
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