-- v2: netprofm: Handle non-internet connectivity. wininet: Handle offline state in InternetGetConnectedStateExW.
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/netprofm/list.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/dlls/netprofm/list.c b/dlls/netprofm/list.c index 254cf60c263..e22609dcaf6 100644 --- a/dlls/netprofm/list.c +++ b/dlls/netprofm/list.c @@ -480,9 +480,17 @@ static HRESULT WINAPI network_GetConnectivity( INetwork *iface, NLM_CONNECTIVITY *pConnectivity ) { + struct network *network = impl_from_INetwork( iface ); + FIXME( "%p, %p\n", iface, pConnectivity );
- *pConnectivity = NLM_CONNECTIVITY_IPV4_INTERNET; + *pConnectivity = NLM_CONNECTIVITY_DISCONNECTED; + + if (network->connected_to_internet) + *pConnectivity |= NLM_CONNECTIVITY_IPV4_INTERNET; + else if (network->connected) + *pConnectivity |= NLM_CONNECTIVITY_IPV4_LOCALNETWORK; + return S_OK; }
@@ -1330,9 +1338,21 @@ static HRESULT WINAPI list_manager_GetConnectivity( INetworkListManager *iface, NLM_CONNECTIVITY *pConnectivity ) { + struct list_manager *mgr = impl_from_INetworkListManager( iface ); + struct network *network; + FIXME( "%p, %p\n", iface, pConnectivity );
- *pConnectivity = NLM_CONNECTIVITY_IPV4_INTERNET; + *pConnectivity = NLM_CONNECTIVITY_DISCONNECTED; + + LIST_FOR_EACH_ENTRY( network, &mgr->networks, struct network, entry ) + { + if (network->connected_to_internet) + *pConnectivity |= NLM_CONNECTIVITY_IPV4_INTERNET; + else if (network->connected) + *pConnectivity |= NLM_CONNECTIVITY_IPV4_LOCALNETWORK; + } + return S_OK; }
@@ -1565,9 +1585,17 @@ static HRESULT WINAPI connection_GetConnectivity( INetworkConnection *iface, NLM_CONNECTIVITY *pConnectivity ) { + struct connection *connection = impl_from_INetworkConnection( iface ); + FIXME( "%p, %p\n", iface, pConnectivity );
- *pConnectivity = NLM_CONNECTIVITY_IPV4_INTERNET; + *pConnectivity = NLM_CONNECTIVITY_DISCONNECTED; + + if (connection->connected_to_internet) + *pConnectivity |= NLM_CONNECTIVITY_IPV4_INTERNET; + else if (connection->connected) + *pConnectivity |= NLM_CONNECTIVITY_IPV4_LOCALNETWORK; + return S_OK; }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=125098
Your paranoid android.
=== debian11 (32 bit report) ===
ddraw: ddraw7.c:15663: Test failed: Expected unsynchronised map for flags 0x1000. ddraw7.c:15663: Test failed: Expected unsynchronised map for flags 0x3000.
=== debian11 (build log) ===
Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24742. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24742. Use of uninitialized value $Flaky in addition (+) at /home/testbot/lib/WineTestBot/LogUtils.pm line 720, <$LogFile> line 24742.
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Some applications (e.g. Deus Ex Human Revolution: Director's Cut) use the output from this function to determine whether they should connect.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/wininet/internet.c | 54 +++++++++++++++++++++++++++++++---- dlls/wininet/tests/internet.c | 9 ++++-- 2 files changed, 56 insertions(+), 7 deletions(-)
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 120cc9af4cc..42015ac1eb1 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -1206,24 +1206,68 @@ BOOL WINAPI InternetGetConnectedState(LPDWORD lpdwStatus, DWORD dwReserved) BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnectionName, DWORD dwNameLen, DWORD dwReserved) { + IP_ADAPTER_ADDRESSES *buf = NULL, *aa; + ULONG size = 0; + DWORD status; + TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved);
/* Must be zero */ if(dwReserved) return FALSE;
- if (lpdwStatus) { - WARN("always returning LAN connection and RAS installed.\n"); - *lpdwStatus = INTERNET_CONNECTION_LAN | INTERNET_RAS_INSTALLED; + for (;;) + { + ULONG flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | + GAA_FLAG_SKIP_FRIENDLY_NAME | GAA_FLAG_INCLUDE_ALL_GATEWAYS; + ULONG errcode = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, buf, &size); + + if (errcode == ERROR_SUCCESS) + break; + heap_free(buf); + if (errcode == ERROR_BUFFER_OVERFLOW && !(buf = heap_alloc(size))) + errcode = ERROR_NOT_ENOUGH_MEMORY; + if (errcode != ERROR_BUFFER_OVERFLOW) + { + SetLastError(errcode); + return FALSE; + } }
+ status = INTERNET_RAS_INSTALLED; + for (aa = buf; aa; aa = aa->Next) + { + /* Connected, but not necessarily to internet */ + if (aa->FirstUnicastAddress) + status |= INTERNET_CONNECTION_OFFLINE; + + /* Connected to internet */ + if (aa->FirstGatewayAddress) + { + WARN("always returning LAN connection.\n"); + status &= ~INTERNET_CONNECTION_OFFLINE; + status |= INTERNET_CONNECTION_LAN; + break; + } + } + heap_free(buf); + + if (lpdwStatus) *lpdwStatus = status; + /* When the buffer size is zero LoadStringW fills the buffer with a pointer to * the resource, avoid it as we must not change the buffer in this case */ - if(lpszConnectionName && dwNameLen) { + if (lpszConnectionName && dwNameLen) + { *lpszConnectionName = '\0'; - LoadStringW(WININET_hModule, IDS_LANCONNECTION, lpszConnectionName, dwNameLen); + if (status & INTERNET_CONNECTION_LAN) + LoadStringW(WININET_hModule, IDS_LANCONNECTION, lpszConnectionName, dwNameLen); }
+ if (!(status & (INTERNET_CONNECTION_LAN | INTERNET_CONNECTION_MODEM | INTERNET_CONNECTION_PROXY))) + { + SetLastError(ERROR_SUCCESS); + return FALSE; + } return TRUE; }
diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c index 97bd36f9427..0d58a12558e 100644 --- a/dlls/wininet/tests/internet.c +++ b/dlls/wininet/tests/internet.c @@ -1730,12 +1730,17 @@ static void test_InternetGetConnectedStateExW(void) }
flags = 0; - buffer[0] = 0; + wcscpy(buffer, L"wine"); + SetLastError(0xdeadbeef); res = pInternetGetConnectedStateExW(&flags, buffer, ARRAY_SIZE(buffer), 0); trace("Internet Connection: Flags 0x%02lx - Name '%s'\n", flags, wine_dbgstr_w(buffer)); ok (flags & INTERNET_RAS_INSTALLED, "Missing RAS flag\n"); if(!res) { - win_skip("InternetGetConnectedStateExW tests require a valid connection\n"); + DWORD error = GetLastError(); + ok(error == ERROR_SUCCESS, "Last error = %#lx\n", error); + ok(!buffer[0], "Expected empty connection name, got %s\n", wine_dbgstr_w(buffer)); + + skip("InternetGetConnectedStateExW tests require a valid connection\n"); return; }
Oops, forgot to handle case when there's nothing returned.