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

iphlpapi: Implement GetExtendedUdpTable.

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