Paul Gofman : iphlpapi: Support InitialNotification flag in NotifyUnicastIpAddressChange().

Alexandre Julliard julliard at winehq.org
Tue Jun 2 08:11:17 CDT 2020


Module: wine
Branch: stable
Commit: 3020b07c4b03f9baff73c3961e05c27547c97494
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=3020b07c4b03f9baff73c3961e05c27547c97494

Author: Paul Gofman <gofmanp at gmail.com>
Date:   Thu Feb 27 14:10:32 2020 +0300

iphlpapi: Support InitialNotification flag in NotifyUnicastIpAddressChange().

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48669
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 5cdd3848f500350dd02e3b8f6d87766c3689f48a)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 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 8c7c9018c4..8338a7f025 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 1b0bc9383a..02bb783efd 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();
   }
 }




More information about the wine-cvs mailing list