

How should I interpret the various values of NLM_CONNECTIVITY?
source link: https://devblogs.microsoft.com/oldnewthing/20230112-00/?p=107700
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How should I interpret the various values of NLM_CONNECTIVITY
?

Raymond Chen
The NLM_CONNECTIVITY
flags enumeration describes what types of network connectivity are available, as far as the networking infrastructure can tell.
Mind you, network connectivity is a hazy concept, because whether a particular endpoint can be reached is dependent not only on the configuration of the local system, but also on the configuration of every machine between you and the endpoint, and those configurations can change at any time. A hunter accidentally damages a power line and suddenly you lose connection to a server. The system won’t know about this until you try to contact that server.
Even for the state of the local system, it takes time for the system to re-evaluate the network connectivity after a change in configuration (such as an unplugged network cable), so you have to accept that the values you receive are based on the most recent information available, but that information may be in flux. And of course there are the shenanigans noted above.
The networking folks gave me this breakdown of what the flags mean and how apps should deal with them.
Flag | Meaning | Recommendation |
---|---|---|
DISCONNECTED |
No network interface detects any network. | Treat as offline. |
NOTRAFFIC |
An interface is connected, but it cannot send or receive network traffic. | |
SUBNET |
An interface has been configured to send traffic, but the system cannot confirm Internet connectivity. | Make one attempt to contact service. |
LOCALNETWORK |
||
INTERNET |
The system has confirmed access to Microsoft Internet sites. |
Treat as fully online. |
In the case of SUBNET
or LOCALNETWORK
, you can make one attempt to contact your Internet service even though Windows doesn’t think it’s going to work. This deals with the case where people employ shenanigans to prevent Windows from detecting Internet connectivity, such as blocking access to the msftconnecttest.com
site, or to all Microsoft-owned IP addresses.
The IsConnected
property considers your network to be connected if it is connected to a LOCALNETWORK
or INTERNET
. The IsConnectedToInternet
property requires INTERNET
.
If the system is trapped behind a captive portal, it will report itself as LOCALNETWORK
. To identify the captive portal case specifically, call INetworkListManager::GetNetworks
and use the IEnumNetworks
to enumerate all the INetwork
objects. Query each INetwork
for IPropertyBag
and check the NA_InternetConnectivityV4
and NA_InternetConnectivityV6
properties. If either one has the NLM_INTERNET_CONNECTIVITY_WEBHIJACK
flag set, then you are trapped in a captive portal.
Another way to check whether you’re stuck in a captive portal is to call ConnectionProfile.GetNetworkConnectivityLevel
and check for ConstrainedInternetAccess
, which is the name NetworkConnectivityLevel
gives to being stuck in a captive portal.
(I’m sorry it’s so complicated, but networking is complicated.)
Recommend
-
52
GitHub is where people build software. More than 27 million people use GitHub to discover, fork, and contribute to over 80 million projects.
-
49
This is joint post with Yoel Zeldes , was originally posted in...
-
57
README.md Morse Vision More Vision is a simple app that utilizes ARKit to interpret blinks as morse code which are then transcribed to text. Alternativ...
-
30
There’s no shortage of great HTTP server libraries in Scala: akka-http , http4s , play
-
84
README.md InterpretML - Alpha Release
-
51
Join GitHub today GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
-
24
Demand for data science services continues to accelerate, which has fueled the rapid development of ever more complex models. That com...
-
27
Image by
-
11
SymCC Symbolic execution with SymCC: Don't interpret, compile! Sebastian Poeplau and Aurélien Francillon Proceedings of the 29th USENIX Security Symposium (USENIX Security 20), Bost...
-
7
How to interpret graphs in a principal component analysis 3 U...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK