Skip to content

Commit be5f7a1

Browse files
authored
Feature: Support WiFi 6 GHz & WPA3 (#2912)
* Feature: Support WiFi 6 GHz & WPA3 * Docs: Fix website layout
1 parent d97b81d commit be5f7a1

File tree

19 files changed

+190
-143
lines changed

19 files changed

+190
-143
lines changed

Source/NETworkManager.Controls/NETworkManager.Controls.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<OutputType>Library</OutputType>
55
<RootNamespace>NETworkManager.Controls</RootNamespace>
66
<AssemblyName>NETworkManager.Controls</AssemblyName>
7-
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
7+
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
88
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
99
<PlatformTarget>x64</PlatformTarget>
1010
<SelfContained>false</SelfContained>

Source/NETworkManager.Converters/NETworkManager.Converters.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<AppDesignerFolder>Properties</AppDesignerFolder>
66
<RootNamespace>NETworkManager.Converters</RootNamespace>
77
<AssemblyName>NETworkManager.Converters</AssemblyName>
8-
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
8+
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
99
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
1010
<PlatformTarget>x64</PlatformTarget>
1111
<SelfContained>false</SelfContained>

Source/NETworkManager.Documentation/NETworkManager.Documentation.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<AppDesignerFolder>Properties</AppDesignerFolder>
66
<RootNamespace>NETworkManager.Documentation</RootNamespace>
77
<AssemblyName>NETworkManager.Documentation</AssemblyName>
8-
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
8+
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
99
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
1010
<PlatformTarget>x64</PlatformTarget>
1111
<SelfContained>false</SelfContained>

Source/NETworkManager.Localization/NETworkManager.Localization.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<OutputType>Library</OutputType>
55
<RootNamespace>NETworkManager.Localization</RootNamespace>
66
<AssemblyName>NETworkManager.Localization</AssemblyName>
7-
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
7+
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
88
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
99
<PlatformTarget>x64</PlatformTarget>
1010
<SelfContained>false</SelfContained>

Source/NETworkManager.Models/NETworkManager.Models.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<ProjectGuid>{8A2859DC-38B6-4E9D-A6B2-1828DC6641B3}</ProjectGuid>
44
<OutputType>Library</OutputType>
55
<RootNamespace>NETworkManager.Models</RootNamespace>
66
<AssemblyName>NETworkManager.Models</AssemblyName>
7-
<TargetFramework>net8.0-windows10.0.17763.0</TargetFramework>
7+
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
88
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
99
<PlatformTarget>x64</PlatformTarget>
1010
<SelfContained>false</SelfContained>

Source/NETworkManager.Models/Network/WiFi.cs

Lines changed: 81 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1-
using System;
1+
using log4net;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Threading.Tasks;
56
using Windows.Devices.WiFi;
67
using Windows.Networking.Connectivity;
78
using Windows.Security.Credentials;
8-
using log4net;
9-
10-
//https://docs.microsoft.com/en-us/uwp/api/windows.devices.wifi.wifiadapter.requestaccessasync
11-
//var access = await WiFiAdapter.RequestAccessAsync() == WiFiAccessStatus.Allowed;
129

1310
namespace NETworkManager.Models.Network;
1411

1512
/// <summary>
16-
/// Class with WiFi related methods.
13+
/// Class with Wi-Fi related methods.
1714
/// </summary>
1815
public static class WiFi
1916
{
2017
private static readonly ILog Log = LogManager.GetLogger(typeof(WiFi));
2118

2219
/// <summary>
23-
/// Get all WiFi adapters async with additional information from <see cref="NetworkInterface" />.
20+
/// Get all Wi-Fi adapters async with additional information from <see cref="NetworkInterface" />.
2421
/// </summary>
2522
/// <returns>
2623
/// <see cref="WiFiAdapterInfo" /> with <see cref="NetworkInterface" /> and <see cref="WiFiAdapter" /> as
@@ -58,7 +55,7 @@ public static async Task<List<WiFiAdapterInfo>> GetAdapterAsync()
5855
}
5956

6057
/// <summary>
61-
/// Get all available WiFi networks for an adapter with additional information's.
58+
/// Get all available Wi-Fi networks for an adapter with additional information's.
6259
/// </summary>
6360
/// <param name="adapter">WiFi adapter as <see cref="WiFiAdapter" />.</param>
6461
/// <returns>A report as <see cref="WiFiNetworkScanInfo" /> including a list of <see cref="WiFiNetworkInfo" />.</returns>
@@ -67,7 +64,7 @@ public static async Task<WiFiNetworkScanInfo> GetNetworksAsync(WiFiAdapter adapt
6764
// Scan network adapter async
6865
await adapter.ScanAsync();
6966

70-
// Try to get the current connected wifi network of this network adapter
67+
// Try to get the current connected Wi-Fi network of this network adapter
7168
var (_, bssid) = TryGetConnectedNetworkFromWiFiAdapter(adapter.NetworkAdapter.NetworkAdapterId.ToString());
7269

7370
var wifiNetworkInfos = adapter.NetworkReport.AvailableNetworks.Select(availableNetwork => new WiFiNetworkInfo
@@ -86,14 +83,14 @@ public static async Task<WiFiNetworkScanInfo> GetNetworksAsync(WiFiAdapter adapt
8683
}
8784

8885
/// <summary>
89-
/// Try to get the current connected wifi network (SSID and BSSID) of a network adapter from
86+
/// Try to get the current connected Wi-Fi network (SSID and BSSID) of a network adapter from
9087
/// netsh.exe.
9188
/// Calling netsh.exe and parsing the output feels so dirty, but Microsoft's API returns only
9289
/// the WLAN profile and the SSID of the connected network. The BSSID is needed to find a
9390
/// specific access point among several.
9491
/// </summary>
95-
/// <param name="adapterId">GUID of the WiFi network adapter.</param>
96-
/// <returns>SSID and BSSID of the connected wifi network. Values are null if not detected.</returns>
92+
/// <param name="adapterId">GUID of the Wi-Fi network adapter.</param>
93+
/// <returns>SSID and BSSID of the connected Wi-Fi network. Values are null if not detected.</returns>
9794
// ReSharper disable once UnusedTupleComponentInReturnValue
9895
private static (string SSID, string BSSID) TryGetConnectedNetworkFromWiFiAdapter(string adapterId)
9996
{
@@ -151,10 +148,10 @@ private static (string SSID, string BSSID) TryGetConnectedNetworkFromWiFiAdapter
151148
}
152149

153150
/// <summary>
154-
/// Connect to a WiFi network with Pre-shared key, EAP or no security.
151+
/// Connect to a Wi-Fi network with Pre-shared key, EAP or no security.
155152
/// </summary>
156-
/// <param name="adapter">WiFi adapter which should be used for the connection.</param>
157-
/// <param name="network">WiFi network to connect to.</param>
153+
/// <param name="adapter">Wi-Fi adapter which should be used for the connection.</param>
154+
/// <param name="network">Wi-Fi network to connect to.</param>
158155
/// <param name="reconnectionKind">Reconnection type to automatically or manuel reconnect.</param>
159156
/// <param name="credential">Credentials for EAP or PSK. Empty for open networks.</param>
160157
/// <param name="ssid">SSID for hidden networks.</param>
@@ -178,10 +175,10 @@ public static async Task<WiFiConnectionStatus> ConnectAsync(WiFiAdapter adapter,
178175
}
179176

180177
/// <summary>
181-
/// Connect to a WiFi network with WPS push button.
178+
/// Connect to a Wi-Fi network with WPS push button.
182179
/// </summary>
183-
/// <param name="adapter">WiFi adapter which should be used for the connection.</param>
184-
/// <param name="network">WiFi network to connect to.</param>
180+
/// <param name="adapter">Wi-Fi adapter which should be used for the connection.</param>
181+
/// <param name="network">Wi-Fi network to connect to.</param>
185182
/// <param name="reconnectionKind">Reconnection type to automatically or manuel reconnect.</param>
186183
/// <returns></returns>
187184
public static async Task<WiFiConnectionStatus> ConnectWpsAsync(WiFiAdapter adapter, WiFiAvailableNetwork network,
@@ -199,25 +196,24 @@ public static async Task<WiFiConnectionStatus> ConnectWpsAsync(WiFiAdapter adapt
199196
}
200197

201198
/// <summary>
202-
/// Disconnect the wifi adapter from the current wifi network.
199+
/// Disconnect the Wi-Fi adapter from the current Wi-Fi network.
203200
/// </summary>
204-
/// <param name="adapter">WiFi adapter from which the wifi network should be disconnected.</param>
201+
/// <param name="adapter">Wi-Fi adapter from which the Wi-Fi network should be disconnected.</param>
205202
public static void Disconnect(WiFiAdapter adapter)
206203
{
207204
adapter.Disconnect();
208205
}
209206

210207
/// <summary>
211-
/// Get the connect mode of a wifi network like Open, Eap (WPA2-Enterprise)
208+
/// Get the connect mode of a Wi-Fi network like Open, Eap (WPA2-Enterprise)
212209
/// or Psk (WPA2-Personal).
213210
/// </summary>
214-
/// <param name="network">WiFi network as <see cref="WiFiAvailableNetwork" />.</param>
211+
/// <param name="network">Wi-Fi network as <see cref="WiFiAvailableNetwork" />.</param>
215212
/// <returns>Connect mode as <see cref="WiFiConnectMode" />.</returns>
216213
public static WiFiConnectMode GetConnectMode(WiFiAvailableNetwork network)
217214
{
218215
// Enterprise
219-
if (network.SecuritySettings.NetworkAuthenticationType == NetworkAuthenticationType.Rsna ||
220-
network.SecuritySettings.NetworkAuthenticationType == NetworkAuthenticationType.Wpa)
216+
if (network.SecuritySettings.NetworkAuthenticationType is NetworkAuthenticationType.Rsna or NetworkAuthenticationType.Wpa)
221217
return WiFiConnectMode.Eap;
222218

223219
// Open
@@ -230,11 +226,11 @@ public static WiFiConnectMode GetConnectMode(WiFiAvailableNetwork network)
230226
}
231227

232228
/// <summary>
233-
/// Check if WPS is available for a wifi network.
229+
/// Check if WPS is available for a Wi-Fi network.
234230
/// </summary>
235231
/// <param name="adapter">WiFi adapter as <see cref="WiFiAdapter" />.</param>
236232
/// <param name="network">WiFi network as <see cref="WiFiAvailableNetwork" />.</param>
237-
/// <returns></returns>
233+
/// <returns>Ture if WPS is available.</returns>
238234
public static async Task<bool> IsWpsAvailable(WiFiAdapter adapter, WiFiAvailableNetwork network)
239235
{
240236
var result = await adapter.GetWpsConfigurationAsync(network);
@@ -243,7 +239,7 @@ public static async Task<bool> IsWpsAvailable(WiFiAdapter adapter, WiFiAvailable
243239
}
244240

245241
/// <summary>
246-
/// Get the WiFi channel from channel frequency.
242+
/// Get the Wi-Fi channel from channel frequency.
247243
/// </summary>
248244
/// <param name="kilohertz">Input like 2422000 or 5240000.</param>
249245
/// <returns>WiFi channel like 3 or 48.</returns>
@@ -252,7 +248,7 @@ public static int GetChannelFromChannelFrequency(int kilohertz)
252248
return ConvertChannelFrequencyToGigahertz(kilohertz) switch
253249
{
254250
// 2.4 GHz
255-
2.412 => 1,
251+
2.412 => 1,
256252
2.417 => 2,
257253
2.422 => 3,
258254
2.427 => 4,
@@ -265,32 +261,33 @@ public static int GetChannelFromChannelFrequency(int kilohertz)
265261
2.462 => 11,
266262
2.467 => 12,
267263
2.472 => 13,
264+
2.484 => 14, // Most countries do not allow this channel
268265
// 5 GHz
269-
5.180 => 36,
270-
5.200 => 40,
271-
5.220 => 44,
272-
5.240 => 48,
273-
5.260 => 52,
274-
5.280 => 56,
275-
5.300 => 60,
276-
5.320 => 64,
277-
5.500 => 100,
278-
5.520 => 104,
279-
5.540 => 108,
280-
5.560 => 112,
281-
5.580 => 116,
282-
5.600 => 120,
283-
5.620 => 124,
284-
5.640 => 128,
285-
5.660 => 132,
286-
5.680 => 136,
287-
5.700 => 140,
288-
5.720 => 144,
289-
5.745 => 149,
290-
5.765 => 153,
291-
5.785 => 157,
292-
5.805 => 161,
293-
5.825 => 165,
266+
5.180 => 36, // UNII-1
267+
5.200 => 40, // UNII-1
268+
5.220 => 44, // UNII-1
269+
5.240 => 48, // UNII-1
270+
5.260 => 52, // UNII-2, DFS
271+
5.280 => 56, // UNII-2, DFS
272+
5.300 => 60, // UNII-2, DFS
273+
5.320 => 64, // UNII-2, DFS
274+
5.500 => 100, // UNII-2 Extended, DFS
275+
5.520 => 104, // UNII-2 Extended, DFS
276+
5.540 => 108, // UNII-2 Extended, DFS
277+
5.560 => 112, // UNII-2 Extended, DFS
278+
5.580 => 116, // UNII-2 Extended, DFS
279+
5.600 => 120, // UNII-2 Extended, DFS
280+
5.620 => 124, // UNII-2 Extended, DFS
281+
5.640 => 128, // UNII-2 Extended, DFS
282+
5.660 => 132, // UNII-2 Extended, DFS
283+
5.680 => 136, // UNII-2 Extended, DFS
284+
5.700 => 140, // UNII-2 Extended, DFS
285+
5.720 => 144, // UNII-2 Extended, DFS
286+
5.745 => 149, // UNII-3
287+
5.765 => 153, // UNII-3
288+
5.785 => 157, // UNII-3
289+
5.805 => 161, // UNII-3
290+
5.825 => 165, // UNII-3
294291
_ => -1
295292
};
296293
}
@@ -306,69 +303,82 @@ public static double ConvertChannelFrequencyToGigahertz(int kilohertz)
306303
}
307304

308305
/// <summary>
309-
/// Check if the WiFi network is a 2.4 GHz network.
306+
/// Check if the Wi-Fi network is a 2.4 GHz network.
310307
/// </summary>
311308
/// <param name="kilohertz">Frequency in kilohertz like 2422000 or 5240000.</param>
312-
/// <returns>True if WiFi network is 2.4 GHz.</returns>
309+
/// <returns>True if Wi-Fi network is 2.4 GHz.</returns>
313310
public static bool Is2dot4GHzNetwork(int kilohertz)
314311
{
315312
var x = ConvertChannelFrequencyToGigahertz(kilohertz);
316313

317-
return x is >= 2.412 and <= 2.472;
314+
return x is >= 2.412 and <= 2.484;
318315
}
319316

320317
/// <summary>
321-
/// Check if the WiFi network is a 5 GHz network.
318+
/// Check if the Wi-Fi network is a 5 GHz network.
322319
/// </summary>
323320
/// <param name="kilohertz">Frequency in kilohertz like 2422000 or 5240000.</param>
324-
/// <returns>True if WiFi network is 5 GHz.</returns>
321+
/// <returns>True if Wi-Fi network is 5 GHz.</returns>
325322
public static bool Is5GHzNetwork(int kilohertz)
326323
{
327324
var x = ConvertChannelFrequencyToGigahertz(kilohertz);
328325

329326
return x is >= 5.180 and <= 5.825;
330327
}
328+
329+
public static bool Is6GHzNetwork(int kilohertz)
330+
{
331+
var x = ConvertChannelFrequencyToGigahertz(kilohertz);
332+
333+
return x is >= 5.925 and <= 7.125;
334+
}
331335

332336
/// <summary>
333-
/// Get the human readable network authentication type.
337+
/// Get the human-readable network authentication type.
334338
/// </summary>
335-
/// <param name="networkAuthenticationType">WiFi network authentication type as <see cref="NetworkAuthenticationType" />.</param>
336-
/// <returns>Human readable authentication type as string like "Open" or "WPA2 Enterprise".</returns>
339+
/// <param name="networkAuthenticationType">Wi-Fi network authentication type as <see cref="NetworkAuthenticationType" />.</param>
340+
/// <returns>Human-readable authentication type as string like "Open" or "WPA2 Enterprise".</returns>
337341
public static string GetHumanReadableNetworkAuthenticationType(NetworkAuthenticationType networkAuthenticationType)
338342
{
339343
return networkAuthenticationType switch
340344
{
345+
NetworkAuthenticationType.None => "-/-",
346+
NetworkAuthenticationType.Unknown => "Unknown",
341347
NetworkAuthenticationType.Open80211 => "Open",
342-
NetworkAuthenticationType.Rsna => "WPA2 Enterprise",
343-
NetworkAuthenticationType.RsnaPsk => "WPA2 PSK",
348+
NetworkAuthenticationType.SharedKey80211 => "WEP",
344349
NetworkAuthenticationType.Wpa => "WPA Enterprise",
345-
NetworkAuthenticationType.WpaNone => "WPA None",
346350
NetworkAuthenticationType.WpaPsk => "WPA PSK",
347-
NetworkAuthenticationType.SharedKey80211 => "WEP",
351+
NetworkAuthenticationType.WpaNone => "WPA None",
352+
NetworkAuthenticationType.Rsna => "WPA2 Enterprise",
353+
NetworkAuthenticationType.RsnaPsk => "WPA2 Personal (PSK)",
348354
NetworkAuthenticationType.Ihv => "IHV",
349-
NetworkAuthenticationType.Unknown => "Unknown",
350-
NetworkAuthenticationType.None => "-/-",
355+
NetworkAuthenticationType.Wpa3Enterprise192Bits => "WPA3 Enterprise (192-bit)", // Same as Wpa3
356+
NetworkAuthenticationType.Wpa3Sae => "WPA3 Personal (SAE)",
357+
NetworkAuthenticationType.Owe => "OWE",
358+
NetworkAuthenticationType.Wpa3Enterprise => "WPA3 Enterprise",
351359
_ => "-/-"
352360
};
353361
}
354362

355363
/// <summary>
356-
/// Get the human readable network phy kind.
364+
/// Get the human-readable network phy kind.
357365
/// </summary>
358-
/// <param name="phyKind">WiFi network phy kind as <see cref="WiFiPhyKind" />.</param>
359-
/// <returns>Human readable phy kind as string like "802.11g" or "802.11ax".</returns>
366+
/// <param name="phyKind">Wi-Fi network phy kind as <see cref="WiFiPhyKind" />.</param>
367+
/// <returns>Human-readable phy kind as string like "802.11g" or "802.11ax".</returns>
360368
public static string GetHumanReadablePhyKind(WiFiPhyKind phyKind)
361369
{
362370
return phyKind switch
363371
{
372+
WiFiPhyKind.Unknown => "Unknown",
364373
WiFiPhyKind.Dsss or WiFiPhyKind.Fhss => "802.11",
365374
WiFiPhyKind.Ofdm => "802.11a",
366375
WiFiPhyKind.Hrdsss => "802.11b",
367376
WiFiPhyKind.Erp => "802.11g",
368377
WiFiPhyKind.HT => "802.11n",
369-
WiFiPhyKind.Dmg => "802.11ad",
370378
WiFiPhyKind.Vht => "802.11ac",
379+
WiFiPhyKind.Dmg => "802.11ad",
371380
WiFiPhyKind.HE => "802.11ax",
381+
WiFiPhyKind.Eht => "802.11be",
372382
_ => "-/-"
373383
};
374384
}

Source/NETworkManager.Models/Network/WiFiNetworkInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace NETworkManager.Models.Network;
44

55
/// <summary>
6-
/// Class contains information about a WiFi network.
6+
/// Class contains information about a Wi-Fi network.
77
/// </summary>
88
public class WiFiNetworkInfo
99
{
@@ -17,17 +17,17 @@ public WiFiNetworkInfo()
1717
#region Variables
1818

1919
/// <summary>
20-
/// Information's about an available WiFi network.
20+
/// Information's about an available Wi-Fi network.
2121
/// </summary>
2222
public WiFiAvailableNetwork AvailableNetwork { get; init; }
2323

2424
/// <summary>
25-
/// Indicates if the WiFi network Ssid is hidden.
25+
/// Indicates if the Wi-Fi network Ssid is hidden.
2626
/// </summary>
2727
public bool IsHidden { get; set; }
2828

2929
/// <summary>
30-
/// Indicates if the WiFi network is connected to the current WiFi adapter.
30+
/// Indicates if the Wi-Fi network is connected to the current WiFi adapter.
3131
/// </summary>
3232
public bool IsConnected { get; set; }
3333

0 commit comments

Comments
 (0)