Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52224 Signed-off-by: Bernhard Übelacker bernhardu@mailbox.org --- dlls/inetmib1/tests/main.c | 45 +++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
diff --git a/dlls/inetmib1/tests/main.c b/dlls/inetmib1/tests/main.c index 5a48276074c..48bc910c93b 100644 --- a/dlls/inetmib1/tests/main.c +++ b/dlls/inetmib1/tests/main.c @@ -20,23 +20,30 @@ #include <windef.h> #include <winbase.h> #include <snmp.h> +#include <iphlpapi.h> +#include <winsock2.h>
#include "wine/test.h"
static BOOL (WINAPI *pSnmpExtensionInit)(DWORD, HANDLE*, AsnObjectIdentifier*); static BOOL (WINAPI *pSnmpExtensionQuery)(BYTE, SnmpVarBindList*, AsnInteger32*, AsnInteger32*);
+static DWORD (WINAPI *pGetUdpTable)(PMIB_UDPTABLE, PDWORD, BOOL); + static HMODULE init_test_functions(void) { HMODULE mod = LoadLibraryA("inetmib1"); + HMODULE mod_iphlpapi = LoadLibraryA("iphlpapi");
ok(mod != NULL, "failed to load inetmib1.dll\n"); - if (!mod) return NULL;
pSnmpExtensionInit = (void *)GetProcAddress(mod, "SnmpExtensionInit"); pSnmpExtensionQuery = (void *)GetProcAddress(mod, "SnmpExtensionQuery");
+ if (mod_iphlpapi) + pGetUdpTable = (void *)GetProcAddress(mod_iphlpapi, "GetUdpTable"); + return mod; }
@@ -523,6 +530,41 @@ if (0) /* crashes on native */ SnmpUtilVarBindFree(&vars2[0]); }
+static void trace_GetUdpTable(void) +{ + DWORD size = 0; + DWORD ret; + + if (!pGetUdpTable) + { + skip("no GetUdpTable\n"); + return; + } + + ret = pGetUdpTable(NULL, &size, TRUE); + + if (ret == ERROR_INSUFFICIENT_BUFFER) + { + MIB_UDPTABLE *table = HeapAlloc(GetProcessHeap(), 0, size); + if (table) + { + if (pGetUdpTable(table, &size, TRUE) == NO_ERROR) + { + for (int i = 0; i < table->dwNumEntries; i++) + { + trace("udp: %d.%d.%d.%d:%d\n", + (table->table[i].dwLocalAddr >> 0) & 0xff, + (table->table[i].dwLocalAddr >> 8) & 0xff, + (table->table[i].dwLocalAddr >> 16) & 0xff, + (table->table[i].dwLocalAddr >> 24) & 0xff, + ntohs(table->table[i].dwLocalPort)); + } + } + HeapFree(GetProcessHeap(), 0, table); + } + } +} + START_TEST(main) { HMODULE mod; @@ -530,6 +572,7 @@ START_TEST(main) if (!(mod = init_test_functions())) return;
+ trace_GetUdpTable(); testInit(); testQuery();