From: "Bernhard Übelacker" Subject: [PATCH 3/3] inetmib1/tests: Add function to trace result of GetUdpTable. Message-Id: <20211216102909.39696-3-bernhardu@mailbox.org> Date: Thu, 16 Dec 2021 11:29:09 +0100 In-Reply-To: <20211216102909.39696-1-bernhardu@mailbox.org> References: <20211216102909.39696-1-bernhardu@mailbox.org> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52224 Signed-off-by: Bernhard Übelacker --- 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 #include #include +#include +#include #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(); -- 2.34.1