From 5afb22c34de21dc072fad59130214fdb0510b318 Mon Sep 17 00:00:00 2001 From: "a.tischer" Date: Wed, 21 Jun 2017 11:35:58 +0200 Subject: [PATCH] + make accesspoint constructor public + add boolean ssidBroadcast variable to handle hidden networks + enhance WPA2-PSK.xml with nonBroadcast-Tag --- SimpleWifi/AccessPoint.cs | 8 +++++++- SimpleWifi/AuthRequest.cs | 6 +++--- SimpleWifi/ProfileFactory.cs | 4 ++-- SimpleWifi/ProfileXML/WPA2-PSK.xml | 1 + SimpleWifi/Win32/Interop/Structs.cs | 5 +++++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/SimpleWifi/AccessPoint.cs b/SimpleWifi/AccessPoint.cs index c1d10ae..ee516ac 100644 --- a/SimpleWifi/AccessPoint.cs +++ b/SimpleWifi/AccessPoint.cs @@ -14,8 +14,9 @@ public class AccessPoint { private WlanInterface _interface; private WlanAvailableNetwork _network; + private bool _isSsidBroadcasted; - internal AccessPoint(WlanInterface interfac, WlanAvailableNetwork network) + public AccessPoint(WlanInterface interfac, WlanAvailableNetwork network, bool ssidBroadcasted = false) { _interface = interfac; _network = network; @@ -103,6 +104,11 @@ internal WlanInterface Interface } } + internal bool IsSsidBroadcasted + { + get { return _isSsidBroadcasted; } + } + /// /// Checks that the password format matches this access point's encryption method. /// diff --git a/SimpleWifi/AuthRequest.cs b/SimpleWifi/AuthRequest.cs index 19b0f59..9f2ee44 100644 --- a/SimpleWifi/AuthRequest.cs +++ b/SimpleWifi/AuthRequest.cs @@ -10,7 +10,7 @@ namespace SimpleWifi { public class AuthRequest { - private bool _isPasswordRequired, _isUsernameRequired, _isDomainSupported, _isEAPStore; + private bool _isPasswordRequired, _isUsernameRequired, _isDomainSupported, _isEAPStore, _ssidBroadcast; private string _password, _username, _domain; private WlanAvailableNetwork _network; private WlanInterface _interface; @@ -19,7 +19,7 @@ public AuthRequest(AccessPoint ap) { _network = ap.Network; _interface = ap.Interface; - + _ssidBroadcast = ap.IsSsidBroadcasted; _isPasswordRequired = _network.securityEnabled && _network.dot11DefaultCipherAlgorithm != Dot11CipherAlgorithm.None; @@ -79,7 +79,7 @@ internal bool Process() if (!IsPasswordValid) return false; - string profileXML = ProfileFactory.Generate(_network, _password); + string profileXML = ProfileFactory.Generate(_network, _password, _ssidBroadcast); _interface.SetProfile(WlanProfileFlags.AllUser, profileXML, true); if (_isEAPStore && !SaveToEAP()) diff --git a/SimpleWifi/ProfileFactory.cs b/SimpleWifi/ProfileFactory.cs index 8b78821..62851de 100644 --- a/SimpleWifi/ProfileFactory.cs +++ b/SimpleWifi/ProfileFactory.cs @@ -14,7 +14,7 @@ internal static class ProfileFactory /// /// Generates the profile XML for the access point and password /// - internal static string Generate(WlanAvailableNetwork network, string password) + internal static string Generate(WlanAvailableNetwork network, string password, bool ssidBroadcast) { string profile = string.Empty; string template = string.Empty; @@ -42,7 +42,7 @@ internal static string Generate(WlanAvailableNetwork network, string password) else // PSK { template = GetTemplate("WPA2-PSK"); - profile = string.Format(template, name, password); + profile = string.Format(template, name, password, ssidBroadcast ? "false" : "true"); } break; case Dot11CipherAlgorithm.TKIP: diff --git a/SimpleWifi/ProfileXML/WPA2-PSK.xml b/SimpleWifi/ProfileXML/WPA2-PSK.xml index d6cd1d3..05dcd91 100644 --- a/SimpleWifi/ProfileXML/WPA2-PSK.xml +++ b/SimpleWifi/ProfileXML/WPA2-PSK.xml @@ -5,6 +5,7 @@ {0} + {2} ESS auto diff --git a/SimpleWifi/Win32/Interop/Structs.cs b/SimpleWifi/Win32/Interop/Structs.cs index cc10b29..bdf2e98 100644 --- a/SimpleWifi/Win32/Interop/Structs.cs +++ b/SimpleWifi/Win32/Interop/Structs.cs @@ -79,6 +79,11 @@ public Dot11PhyType[] Dot11PhyTypes Array.Copy(dot11PhyTypes, ret, numberOfPhyTypes); return ret; } + + set + { + dot11PhyTypes = value; + } } /// /// Specifies if there are more than 8 PHY types supported.