From 3020b07c4b03f9baff73c3961e05c27547c97494 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Thu, 27 Feb 2020 14:10:32 +0300 Subject: [PATCH] iphlpapi: Support InitialNotification flag in NotifyUnicastIpAddressChange(). Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48669 Signed-off-by: Paul Gofman Signed-off-by: Alexandre Julliard (cherry picked from commit 5cdd3848f500350dd02e3b8f6d87766c3689f48a) Signed-off-by: Michael Stefaniuc --- dlls/iphlpapi/iphlpapi_main.c | 6 ++++- dlls/iphlpapi/tests/iphlpapi.c | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 8c7c9018c48..8338a7f0254 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -2791,9 +2791,13 @@ DWORD WINAPI NotifyRouteChange(PHANDLE Handle, LPOVERLAPPED overlapped) DWORD WINAPI NotifyUnicastIpAddressChange(ADDRESS_FAMILY family, PUNICAST_IPADDRESS_CHANGE_CALLBACK callback, PVOID context, BOOLEAN init_notify, PHANDLE handle) { - FIXME("(family %d, callback %p, context %p, init_notify %d, handle %p): stub\n", + FIXME("(family %d, callback %p, context %p, init_notify %d, handle %p): semi-stub\n", family, callback, context, init_notify, handle); if (handle) *handle = NULL; + + if (init_notify) + callback(context, NULL, MibInitialNotification); + return ERROR_NOT_SUPPORTED; } diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index 1b0bc9383a8..02bb783efdd 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -100,6 +100,9 @@ static DWORD (WINAPI *pConvertInterfaceNameToLuidA)(const char*,NET_LUID*); static DWORD (WINAPI *pConvertInterfaceNameToLuidW)(const WCHAR*,NET_LUID*); static DWORD (WINAPI *pConvertLengthToIpv4Mask)(ULONG,ULONG*); static DWORD (WINAPI *pParseNetworkString)(const WCHAR*,DWORD,NET_ADDRESS_INFO*,USHORT*,BYTE*); +static DWORD (WINAPI *pNotifyUnicastIpAddressChange)(ADDRESS_FAMILY, PUNICAST_IPADDRESS_CHANGE_CALLBACK, + PVOID, BOOLEAN, HANDLE *); +static DWORD (WINAPI *pCancelMibChangeNotify2)(HANDLE); static PCHAR (WINAPI *pif_indextoname)(NET_IFINDEX,PCHAR); static NET_IFINDEX (WINAPI *pif_nametoindex)(const char*); @@ -158,6 +161,8 @@ static void loadIPHlpApi(void) pParseNetworkString = (void *)GetProcAddress(hLibrary, "ParseNetworkString"); pif_indextoname = (void *)GetProcAddress(hLibrary, "if_indextoname"); pif_nametoindex = (void *)GetProcAddress(hLibrary, "if_nametoindex"); + pNotifyUnicastIpAddressChange = (void *)GetProcAddress(hLibrary, "NotifyUnicastIpAddressChange"); + pCancelMibChangeNotify2 = (void *)GetProcAddress(hLibrary, "CancelMibChangeNotify2"); } } @@ -2381,6 +2386,41 @@ static void test_ParseNetworkString(void) } } +static void WINAPI test_ipaddtess_change_callback(PVOID context, PMIB_UNICASTIPADDRESS_ROW row, + MIB_NOTIFICATION_TYPE notification_type) +{ + BOOL *callback_called = context; + + *callback_called = TRUE; + + ok(notification_type == MibInitialNotification, "Unexpected notification_type %#x.\n", + notification_type); + ok(!row, "Unexpected row %p.\n", row); +} + +static void test_NotifyUnicastIpAddressChange(void) +{ + BOOL callback_called; + HANDLE handle; + DWORD ret; + + if (!pNotifyUnicastIpAddressChange) + { + win_skip("NotifyUnicastIpAddressChange not available.\n"); + return; + } + + callback_called = FALSE; + ret = pNotifyUnicastIpAddressChange(AF_INET, test_ipaddtess_change_callback, + &callback_called, TRUE, &handle); + todo_wine ok(ret == NO_ERROR, "Unexpected ret %#x.\n", ret); + ok(callback_called, "Callback was not called.\n"); + + ret = pCancelMibChangeNotify2(handle); + ok(ret == NO_ERROR, "Unexpected ret %#x.\n", ret); + ok(!CloseHandle(handle), "CloseHandle() succeded.\n"); +} + START_TEST(iphlpapi) { @@ -2411,6 +2451,7 @@ START_TEST(iphlpapi) test_ConvertLengthToIpv4Mask(); test_GetUdp6Table(); test_ParseNetworkString(); + test_NotifyUnicastIpAddressChange(); freeIPHlpApi(); } }