/// <summary> /// Generates the profile XML for the access point and password /// </summary> internal static string Generate(WlanAvailableNetwork network, string password) { string profile = string.Empty; string template = string.Empty; string name = Encoding.UTF8.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength); string hex = GetHexString(network.dot11Ssid.SSID); name = System.Security.SecurityElement.Escape(name); password = System.Security.SecurityElement.Escape(password); var authAlgo = network.dot11DefaultAuthAlgorithm; switch (network.dot11DefaultCipherAlgorithm) { case Dot11CipherAlgorithm.None: template = GetTemplate("OPEN"); profile = string.Format(template, name, hex); break; case Dot11CipherAlgorithm.WEP: template = GetTemplate("WEP"); profile = string.Format(template, name, hex, password); break; case Dot11CipherAlgorithm.CCMP: if (authAlgo == Dot11AuthAlgorithm.RSNA) { template = GetTemplate("WPA2-Enterprise-PEAP-MSCHAPv2"); profile = string.Format(template, name, hex); } else // PSK { template = GetTemplate("WPA2-PSK"); profile = string.Format(template, name, hex, password); } break; case Dot11CipherAlgorithm.TKIP: #warning Robin: Not sure WPA uses RSNA if (authAlgo == Dot11AuthAlgorithm.RSNA) { template = GetTemplate("WPA-Enterprise-PEAP-MSCHAPv2"); profile = string.Format(template, name, hex); } else // PSK { template = GetTemplate("WPA-PSK"); profile = string.Format(template, name, hex, password); } break; default: throw new NotImplementedException("Profile for selected cipher algorithm is not implemented"); } return(profile); }
internal AccessPoint(WlanInterface interfac, WlanAvailableNetwork network) { Interface = interfac; Network = network; //For WIndows 7 //If XP Return ERROR_NOT_SUPPORTED //The request is not supported.This error is returned if this function was called from a Windows XP with SP3 or Wireless LAN API for Windows XP with SP2 client.This error is also returned if the WLAN AutoConfig service is disabled. Bssids = Interface.GetNetworkBssList(Network.dot11Ssid, Network.dot11BssType).ToList(); }
internal JAccessPoint(WlanInterface wlanInterface, WlanAvailableNetwork network, AccessPoint thisAP) { InterfaceName = wlanInterface.InterfaceName; name = thisAP.Name; signalStrength = thisAP.SignalStrength; AuthAlgorithm = Enum.GetName(typeof(Dot11AuthAlgorithm), network.dot11DefaultAuthAlgorithm); CipherAlgorithm = Enum.GetName(typeof(Dot11CipherAlgorithm), network.dot11DefaultCipherAlgorithm); BssType = Enum.GetName(typeof(Dot11BssType), network.dot11BssType); connectable = network.networkConnectable; wlanNotConnectableReason = Enum.GetName(typeof(WlanReasonCode), network.wlanNotConnectableReason); }
/// <summary> /// Constructor to create authentication settings /// </summary> /// <param name="wirelessNetwork">Wireless Network object</param> public AuthSettings(WirelessNetwork wirelessNetwork) { _network = wirelessNetwork.Network; _wlanInterface = wirelessNetwork.Interface; // read the wifi network settings and assign local properties IsPasswordRequired = _network.securityEnabled && _network.dot11DefaultCipherAlgorithm != Dot11CipherAlgorithm.None; bool isEAPStore = _network.dot11DefaultAuthAlgorithm == Dot11AuthAlgorithm.RSNA || _network.dot11DefaultAuthAlgorithm == Dot11AuthAlgorithm.WPA; IsUsernameRequired = isEAPStore; IsDomainSupported = isEAPStore; }
/// <summary> /// Converts a pointer to a available networks list (header + entries) to an array of available network entries. /// </summary> /// <param name="bssListPtr">A pointer to an available networks list's header.</param> /// <returns>An array of available network entries.</returns> private static WlanAvailableNetwork[] ConvertAvailableNetworkListPtr(IntPtr availNetListPtr) { WlanAvailableNetworkListHeader availNetListHeader = (WlanAvailableNetworkListHeader)Marshal.PtrToStructure(availNetListPtr, typeof(WlanAvailableNetworkListHeader)); long availNetListIt = availNetListPtr.ToInt64() + Marshal.SizeOf(typeof(WlanAvailableNetworkListHeader)); WlanAvailableNetwork[] availNets = new WlanAvailableNetwork[availNetListHeader.numberOfItems]; for (int i = 0; i < availNetListHeader.numberOfItems; ++i) { availNets[i] = (WlanAvailableNetwork)Marshal.PtrToStructure(new IntPtr(availNetListIt), typeof(WlanAvailableNetwork)); availNetListIt += Marshal.SizeOf(typeof(WlanAvailableNetwork)); } return(availNets); }
public AuthRequest(AccessPoint ap) { _network = ap.Network; _interface = ap.Interface; _ssidBroadcast = ap.IsSsidBroadcasted; _isPasswordRequired = _network.securityEnabled && _network.dot11DefaultCipherAlgorithm != Dot11CipherAlgorithm.None; _isEAPStore = _network.dot11DefaultAuthAlgorithm == Dot11AuthAlgorithm.RSNA || _network.dot11DefaultAuthAlgorithm == Dot11AuthAlgorithm.WPA; _isUsernameRequired = _isEAPStore; _isDomainSupported = _isEAPStore; }
public static JAccessPoint Translate(AccessPoint thisAp) { WlanInterface wlanInterface = thisAp.GetFieldValue <WlanInterface>("_interface"); WlanAvailableNetwork network = thisAp.GetFieldValue <WlanAvailableNetwork>("_network"); JAccessPoint customAp = new JAccessPoint { //TODO: Figure out why this line is so damn costly (and maybe replace it with interface Guid) InterfaceName = wlanInterface.InterfaceName, Name = thisAp.Name, SignalStrength = (int)thisAp.SignalStrength, AuthAlgorithm = Enum.GetName(typeof(Dot11AuthAlgorithm), network.dot11DefaultAuthAlgorithm), CipherAlgorithm = Enum.GetName(typeof(Dot11CipherAlgorithm), network.dot11DefaultCipherAlgorithm), BssType = Enum.GetName(typeof(Dot11BssType), network.dot11BssType), Connectable = network.networkConnectable, WlanNotConnectableReason = Enum.GetName(typeof(WlanReasonCode), network.wlanNotConnectableReason) }; return(customAp); }
internal AccessPoint(WlanInterface interfac, WlanAvailableNetwork network) { _interface = interfac; _network = network; }
public AccessPoint(WlanInterface interfac, WlanAvailableNetwork network, bool ssidBroadcasted = false) { _interface = interfac; _network = network; }