[PATCH 1/2] iphlpapi: Support InitialNotification flag in NotifyUnicastIpAddressChange().

Paul Gofman gofmanp at gmail.com
Thu Feb 27 05:10:32 CST 2020


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48669
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
 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 429958198d..c248fb50b4 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -2801,9 +2801,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 8ccbf5f9b6..9979cd5abc 100644
--- a/dlls/iphlpapi/tests/iphlpapi.c
+++ b/dlls/iphlpapi/tests/iphlpapi.c
@@ -75,6 +75,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*);
@@ -107,6 +110,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");
   }
 }
 
@@ -2287,6 +2292,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)
 {
 
@@ -2318,6 +2358,7 @@ START_TEST(iphlpapi)
     test_GetTcp6Table();
     test_GetUdp6Table();
     test_ParseNetworkString();
+    test_NotifyUnicastIpAddressChange();
     freeIPHlpApi();
   }
 }
-- 
2.24.1




More information about the wine-devel mailing list