Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance simplewifi for adding own (hidden) networks #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion SimpleWifi/AccessPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -103,6 +104,11 @@ internal WlanInterface Interface
}
}

internal bool IsSsidBroadcasted
{
get { return _isSsidBroadcasted; }
}

/// <summary>
/// Checks that the password format matches this access point's encryption method.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions SimpleWifi/AuthRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,7 +19,7 @@ public AuthRequest(AccessPoint ap)
{
_network = ap.Network;
_interface = ap.Interface;

_ssidBroadcast = ap.IsSsidBroadcasted;
_isPasswordRequired =
_network.securityEnabled &&
_network.dot11DefaultCipherAlgorithm != Dot11CipherAlgorithm.None;
Expand Down Expand Up @@ -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())
Expand Down
4 changes: 2 additions & 2 deletions SimpleWifi/ProfileFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class ProfileFactory
/// <summary>
/// Generates the profile XML for the access point and password
/// </summary>
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;
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions SimpleWifi/ProfileXML/WPA2-PSK.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<SSID>
<name>{0}</name>
</SSID>
<nonBroadcast>{2}</nonBroadcast>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>auto</connectionMode>
Expand Down
5 changes: 5 additions & 0 deletions SimpleWifi/Win32/Interop/Structs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public Dot11PhyType[] Dot11PhyTypes
Array.Copy(dot11PhyTypes, ret, numberOfPhyTypes);
return ret;
}

set
{
dot11PhyTypes = value;
}
}
/// <summary>
/// Specifies if there are more than 8 PHY types supported.
Expand Down