public string GetStringForReasonCode(Wlan.WlanReasonCode reasonCode) { StringBuilder stringBuffer = new StringBuilder(0x400); Wlan.ThrowIfError(Wlan.WlanReasonCodeToString(reasonCode, stringBuffer.Capacity, stringBuffer, IntPtr.Zero)); return(stringBuffer.ToString()); }
/// <summary> /// Gets a string that describes a specified reason code. /// </summary> /// <param name="reasonCode">The reason code.</param> /// <returns>The string.</returns> public string GetStringForReasonCode(Wlan.WlanReasonCode reasonCode) { StringBuilder sb = new StringBuilder(1024); // the 1024 size here is arbitrary; the WlanReasonCodeToString docs fail to specify a recommended size Wlan.ThrowIfError( Wlan.WlanReasonCodeToString(reasonCode, sb.Capacity, sb, IntPtr.Zero)); return(sb.ToString()); }
internal void OnWlanReason(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode) { if (WlanReasonNotification != null) { WlanReasonNotification(notifyData, reasonCode); } if (queueEvents) { WlanReasonNotificationData queuedEvent = new WlanReasonNotificationData(); queuedEvent.notifyData = notifyData; queuedEvent.reasonCode = reasonCode; EnqueueEvent(queuedEvent); } }
internal void OnWlanReason(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode) { if (WlanReasonNotification != null) { WlanReasonNotification(notifyData, reasonCode); } if (_queueEvents) { WlanReasonNotificationData data2 = new WlanReasonNotificationData { NotifyData = notifyData, ReasonCode = reasonCode }; WlanReasonNotificationData queuedEvent = data2; EnqueueEvent(queuedEvent); } }
internal void OnWlanReason(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode) { // ISSUE: reference to a compiler-generated field if (this.WlanReasonNotification != null) { // ISSUE: reference to a compiler-generated field this.WlanReasonNotification(notifyData, reasonCode); } if (!this.queueEvents) { return; } this.EnqueueEvent((object)new WlanClient.WlanInterface.WlanReasonNotificationData() { notifyData = notifyData, reasonCode = reasonCode }); }
void ConnectNewSecureNetwork(string ssid, string key, WlanClient.WlanInterface nic, Wlan.WlanAvailableNetwork network) { var log = ServiceRegistration.Get <ILogger>(); log.Info("WifiConfiguration: Building new Profile to connect to WLAN '{0}'", ssid); string profileXml = Helper.GetProfileXml(ssid, key, network.dot11DefaultAuthAlgorithm, network.dot11DefaultCipherAlgorithm); if (profileXml != null) { string error = null; try { Wlan.WlanReasonCode reasonCode = nic.SetProfile(Wlan.WlanProfileFlags.User, profileXml, true); if (reasonCode != Wlan.WlanReasonCode.Success) { error = reasonCode.ToString(); } } catch (Exception ex) { error = ex.Message; } if (error == null) { nic.ConnectSynchronously(Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, ssid, CONNECTION_TIMEOUT_SECONDS); } else { log.Warn("WifiConfiguration: Setting Profile for WLAN '{0}' failed: '{1}'", ssid, error); ServiceRegistration.Get <IDialogManager>().ShowDialog("[Dialogs.ErrorHeaderText]", error, DialogType.OkDialog, false, DialogButtonType.Ok); } } else { // don't know how to build profile log.Warn("WifiConfiguration: No known Mapping to create Profile '{0}' for AuthAlg: '{1}' and CipherAlg: '{2}'", ssid, network.dot11DefaultAuthAlgorithm, network.dot11DefaultCipherAlgorithm); ServiceRegistration.Get <IDialogManager>().ShowDialog("[Dialogs.ErrorHeaderText]", "Unable to build profile. Connect in Windows.", DialogType.OkDialog, false, DialogButtonType.Ok); } }
private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context) { WlanInterface wlanIface = null;// = GenericInfo.WlanInterface; foreach (WlanInterface wli in this.Interfaces) { if (wli.InterfaceGuid == notifyData.interfaceGuid) { wlanIface = wli; } } switch (notifyData.notificationSource) { case Wlan.WlanNotificationSource.ACM: Console.WriteLine("ACM-EVENT: " + (Wlan.WlanNotificationCodeAcm)notifyData.NotificationCode); switch ((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeAcm.ConnectionStart: break; case Wlan.WlanNotificationCodeAcm.ConnectionComplete: wlanIface.LatestConnection = wlanIface.CurrentConnection; //LINK UP INDICATION LINK_SAP_CS_80211.LINK_SAP_80211.Events.EventHandler.HandleLinkUp(notifyData); break; case Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail: break; case Wlan.WlanNotificationCodeAcm.Disconnecting: break; case Wlan.WlanNotificationCodeAcm.Disconnected: //LINK DOWN INDICATION LINK_SAP_CS_80211.LINK_SAP_80211.Events.EventHandler.HandleLinkDown(notifyData); Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; case Wlan.WlanNotificationCodeAcm.ScanComplete: //Handles LINK DETECTED INDICATION LINK_SAP_CS_80211.LINK_SAP_80211.Events.EventHandler.HandleScanComplete(notifyData); break; case Wlan.WlanNotificationCodeAcm.ScanFail: { int expectedSize = Marshal.SizeOf(typeof(int)); if (notifyData.dataSize >= expectedSize) { Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr); if (wlanIface != null) { wlanIface.OnWlanReason(notifyData, reasonCode); } } } break; } break; case Wlan.WlanNotificationSource.MSM: Console.WriteLine("MSM-EVENT: " + (Wlan.WlanNotificationCodeMsm)notifyData.NotificationCode); switch ((Wlan.WlanNotificationCodeMsm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeMsm.SignalQualityChange: LINK_SAP_CS_80211.LINK_SAP_80211.Events.EventHandler.HandleParamsReport(notifyData); break; case Wlan.WlanNotificationCodeMsm.Associating: break; case Wlan.WlanNotificationCodeMsm.Associated: break; case Wlan.WlanNotificationCodeMsm.Authenticating: break; case Wlan.WlanNotificationCodeMsm.Connected: break; case Wlan.WlanNotificationCodeMsm.RoamingStart: break; case Wlan.WlanNotificationCodeMsm.RoamingEnd: break; case Wlan.WlanNotificationCodeMsm.Disassociating: break; case Wlan.WlanNotificationCodeMsm.Disconnected: break; case Wlan.WlanNotificationCodeMsm.PeerJoin: break; case Wlan.WlanNotificationCodeMsm.PeerLeave: break; case Wlan.WlanNotificationCodeMsm.AdapterRemoval: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; } break; } if (wlanIface != null) { wlanIface.OnWlanNotification(notifyData); } }
public static extern int WlanReasonCodeToString([In] Wlan.WlanReasonCode reasonCode, [In] int bufferSize, [In, Out] StringBuilder stringBuffer, IntPtr pReserved);
public static extern int WlanSetProfile([In] IntPtr clientHandle, [MarshalAs(UnmanagedType.LPStruct), In] Guid interfaceGuid, [In] Wlan.WlanProfileFlags flags, [MarshalAs(UnmanagedType.LPWStr), In] string profileXml, [MarshalAs(UnmanagedType.LPWStr), In, Optional] string allUserProfileSecurity, [In] bool overwrite, [In] IntPtr pReserved, out Wlan.WlanReasonCode reasonCode);
public WlanException(Wlan.WlanReasonCode reasonCode) { this.reasonCode = reasonCode; }
private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context) { WlanInterface wlanIface = ifaces.ContainsKey(notifyData.interfaceGuid) ? ifaces[notifyData.interfaceGuid] : null; switch (notifyData.notificationSource) { case Wlan.WlanNotificationSource.ACM: switch ((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeAcm.ConnectionStart: case Wlan.WlanNotificationCodeAcm.ConnectionComplete: case Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail: case Wlan.WlanNotificationCodeAcm.Disconnecting: case Wlan.WlanNotificationCodeAcm.Disconnected: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; case Wlan.WlanNotificationCodeAcm.ScanFail: { //HACK: Prevents exception on WLAN connection: System.ArgumentException: Type 'NativeWifi.Wlan+WlanReasonCode' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed. int expectedSize = 0; //Marshal.SizeOf(typeof (Wlan.WlanReasonCode)); if (notifyData.dataSize >= expectedSize) { Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr); if (wlanIface != null) { wlanIface.OnWlanReason(notifyData, reasonCode); } } } break; } break; case Wlan.WlanNotificationSource.MSM: switch ((Wlan.WlanNotificationCodeMsm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeMsm.Associating: case Wlan.WlanNotificationCodeMsm.Associated: case Wlan.WlanNotificationCodeMsm.Authenticating: case Wlan.WlanNotificationCodeMsm.Connected: case Wlan.WlanNotificationCodeMsm.RoamingStart: case Wlan.WlanNotificationCodeMsm.RoamingEnd: case Wlan.WlanNotificationCodeMsm.Disassociating: case Wlan.WlanNotificationCodeMsm.Disconnected: case Wlan.WlanNotificationCodeMsm.PeerJoin: case Wlan.WlanNotificationCodeMsm.PeerLeave: case Wlan.WlanNotificationCodeMsm.AdapterRemoval: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; } break; } if (wlanIface != null) { wlanIface.OnWlanNotification(notifyData); } }
void SelectedInterface_WlanReasonNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode) { if (owner != null && owner.IsVisible) { SelectedInterface?.UpdateInformation(); UpdateNetworkSignalQuality(); } }
private void WlanInterface_WlanReasonNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode) { WlanReasonNotification?.Invoke(notifyData, reasonCode); }
private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context) { WlanInterface wlanIface; ifaces.TryGetValue(notifyData.interfaceGuid, out wlanIface); switch (notifyData.notificationSource) { case Wlan.WlanNotificationSource.ACM: switch ((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeAcm.ConnectionStart: case Wlan.WlanNotificationCodeAcm.ConnectionComplete: case Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail: case Wlan.WlanNotificationCodeAcm.Disconnecting: case Wlan.WlanNotificationCodeAcm.Disconnected: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; case Wlan.WlanNotificationCodeAcm.ScanFail: { int expectedSize = Marshal.SizeOf(typeof(int)); if (notifyData.dataSize >= expectedSize) { Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr); if (wlanIface != null) { wlanIface.OnWlanReason(notifyData, reasonCode); } } } break; } break; case Wlan.WlanNotificationSource.MSM: switch ((Wlan.WlanNotificationCodeMsm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeMsm.Associating: case Wlan.WlanNotificationCodeMsm.Associated: case Wlan.WlanNotificationCodeMsm.Authenticating: case Wlan.WlanNotificationCodeMsm.Connected: case Wlan.WlanNotificationCodeMsm.RoamingStart: case Wlan.WlanNotificationCodeMsm.RoamingEnd: case Wlan.WlanNotificationCodeMsm.Disassociating: case Wlan.WlanNotificationCodeMsm.Disconnected: case Wlan.WlanNotificationCodeMsm.PeerJoin: case Wlan.WlanNotificationCodeMsm.PeerLeave: case Wlan.WlanNotificationCodeMsm.AdapterRemoval: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; } break; } if (wlanIface != null) { wlanIface.OnWlanNotification(notifyData); } }
private void WlanService_WlanReasonNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode) { }
void SelectedInterface_WlanReasonNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode) { SelectedInterface.RefreshConnected(); }
private void UsableInterface_WlanReasonNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode) { }
private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context) { WlanInterface wlanIface = ifaces.ContainsKey(notifyData.interfaceGuid) ? ifaces[notifyData.interfaceGuid] : null; switch (notifyData.notificationSource) { case Wlan.WlanNotificationSource.ACM: switch ((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeAcm.AdhocNetworkStateChange: //int expectedSize = Marshal.SizeOf(typeof(Wlan.WlanAdhocNetworkState)); //if (notifyData.dataSize >= expectedSize) //{ Wlan.WlanAdhocNetworkState adhocNetworkState = (Wlan.WlanAdhocNetworkState)Marshal.ReadInt32(notifyData.dataPtr); if (wlanIface != null) { wlanIface.OnWlanAdhocNetwork(notifyData, adhocNetworkState); } //} break; case Wlan.WlanNotificationCodeAcm.ConnectionStart: case Wlan.WlanNotificationCodeAcm.ConnectionComplete: case Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail: case Wlan.WlanNotificationCodeAcm.Disconnecting: case Wlan.WlanNotificationCodeAcm.Disconnected: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; case Wlan.WlanNotificationCodeAcm.ScanFail: try { int expectedSize = Marshal.SizeOf(typeof(Wlan.WlanReasonCode)); if (notifyData.dataSize >= expectedSize) { Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr); if (wlanIface != null) { wlanIface.OnWlanReason(notifyData, reasonCode); } } } catch (Exception) { } break; } break; case Wlan.WlanNotificationSource.MSM: switch ((Wlan.WlanNotificationCodeMsm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeMsm.Associating: case Wlan.WlanNotificationCodeMsm.Associated: case Wlan.WlanNotificationCodeMsm.Authenticating: case Wlan.WlanNotificationCodeMsm.Connected: case Wlan.WlanNotificationCodeMsm.RoamingStart: case Wlan.WlanNotificationCodeMsm.RoamingEnd: case Wlan.WlanNotificationCodeMsm.Disassociating: case Wlan.WlanNotificationCodeMsm.Disconnected: case Wlan.WlanNotificationCodeMsm.PeerJoin: case Wlan.WlanNotificationCodeMsm.PeerLeave: case Wlan.WlanNotificationCodeMsm.AdapterRemoval: Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue) { if (wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } } break; } break; } if (wlanIface != null) { wlanIface.OnWlanNotification(notifyData); } }
public string GetStringForReasonCode(Wlan.WlanReasonCode reasonCode) { return(_wlanClient.GetStringForReasonCode(reasonCode)); }
private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context) { WlanInterface interface2 = _ifaces.ContainsKey(notifyData.interfaceGuid) ? _ifaces[notifyData.interfaceGuid] : null; switch (notifyData.notificationSource) { case Wlan.WlanNotificationSource.Acm: switch (notifyData.notificationCode) { case 8: if (notifyData.dataSize >= Marshal.SizeOf(0)) { Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr); if (interface2 != null) { interface2.OnWlanReason(notifyData, reasonCode); } } goto Label_0194; case 9: case 10: case 11: case 20: case 0x15: { Wlan.WlanConnectionNotificationData?nullable = ParseWlanConnectionNotification(ref notifyData); if (nullable.HasValue && (interface2 != null)) { interface2.OnWlanConnection(notifyData, nullable.Value); } goto Label_0194; } case 12: case 15: case 0x10: case 0x11: case 0x12: case 0x13: goto Label_0194; case 13: InterfaceArrivedEvent.Raise(this, new InterfaceNotificationEventsArgs(notifyData.interfaceGuid)); goto Label_0194; case 14: InterfaceRemovedEvent.Raise(this, new InterfaceNotificationEventsArgs(notifyData.interfaceGuid)); goto Label_0194; } break; case Wlan.WlanNotificationSource.Msm: switch (notifyData.notificationCode) { case 1: case 2: case 3: case 4: case 5: case 6: case 9: case 10: case 11: case 12: case 13: { Wlan.WlanConnectionNotificationData?nullable2 = ParseWlanConnectionNotification(ref notifyData); if (nullable2.HasValue && (interface2 != null)) { interface2.OnWlanConnection(notifyData, nullable2.Value); } goto Label_0194; } case 7: case 8: goto Label_0194; } goto Label_0194; } Label_0194: if (interface2 != null) { interface2.OnWlanNotification(notifyData); } }
private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context) { WlanClient.WlanInterface wlanInterface; this.ifaces.TryGetValue(notifyData.interfaceGuid, out wlanInterface); switch (notifyData.notificationSource) { case Wlan.WlanNotificationSource.ACM: switch ((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode) { case Wlan.WlanNotificationCodeAcm.ScanFail: int num = Marshal.SizeOf(typeof(int)); if (notifyData.dataSize >= num) { Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr); if (wlanInterface != null) { wlanInterface.OnWlanReason(notifyData, reasonCode); break; } break; } break; case Wlan.WlanNotificationCodeAcm.ConnectionStart: case Wlan.WlanNotificationCodeAcm.ConnectionComplete: case Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail: case Wlan.WlanNotificationCodeAcm.Disconnecting: case Wlan.WlanNotificationCodeAcm.Disconnected: Wlan.WlanConnectionNotificationData?connectionNotification1 = WlanClient.ParseWlanConnectionNotification(ref notifyData); if (connectionNotification1.HasValue && wlanInterface != null) { wlanInterface.OnWlanConnection(notifyData, connectionNotification1.Value); break; } break; } break; case Wlan.WlanNotificationSource.MSM: switch (notifyData.notificationCode) { case 1: case 2: case 3: case 4: case 5: case 6: case 9: case 10: case 11: case 12: case 13: Wlan.WlanConnectionNotificationData?connectionNotification2 = WlanClient.ParseWlanConnectionNotification(ref notifyData); if (connectionNotification2.HasValue && wlanInterface != null) { wlanInterface.OnWlanConnection(notifyData, connectionNotification2.Value); break; } break; } break; } if (wlanInterface == null) { return; } wlanInterface.OnWlanNotification(notifyData); }