internal void OnWlanReason(WlanNotificationData notifyData, WlanReasonCode reasonCode) { if (WlanReasonNotification != null) { WlanReasonNotification(notifyData, reasonCode); } }
/// <summary> /// Gets a string that describes a specified reason code. /// </summary> /// <param name="peerStateChange">The reason code.</param> /// <returns>The string.</returns> internal static string GetStringForReasonCode(WlanReasonCode reasonCode) { StringBuilder sb = new StringBuilder(1024); // the 1024 dataSize here is arbitrary; the WlanReasonCodeToString docs fail to specify a recommended dataSize ThrowIfError( NativeMethods.WlanReasonCodeToString(reasonCode, (uint)sb.Capacity, sb, IntPtr.Zero)); return(sb.ToString()); }
internal static extern int WlanUIEditProfile( [In] uint dwClientVersion, [In, MarshalAs(UnmanagedType.LPWStr)] string wstrProfileName, [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, [In] IntPtr hWnd, [In] WlDisplayPages wlStartPage, [In, Out] IntPtr pReserved, [Out] out WlanReasonCode wlanReasonCode );
public static extern int WlanSetProfile( [In] IntPtr clientHandle, [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, [In] WlanProfileFlags flags, [In, MarshalAs(UnmanagedType.LPWStr)] string profileXml, [In, Optional, MarshalAs(UnmanagedType.LPWStr)] string allUserProfileSecurity, [In] bool overwrite, [In] IntPtr pReserved, [Out] out WlanReasonCode reasonCode);
internal static extern int WlanSetProfile( [In] IntPtr hClientHandle, [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, [In] WlanProfileFlags dwFlags, [In, MarshalAs(UnmanagedType.LPWStr)] string strProfileXml, [In, MarshalAs(UnmanagedType.LPWStr)] string strAllUserProfileSecurity, [In] bool bOverwrite, [In, Out] IntPtr pReserved, [Out] out WlanReasonCode dwReasonCode );
/// <summary> /// Gets a string that describes a specified reason code. NOTE: Not used! /// </summary> /// <param name="reasonCode">The reason code.</param> /// <returns>The string.</returns> public static string GetStringForReasonCode(WlanReasonCode reasonCode) { StringBuilder sb = new StringBuilder(1024); // the 1024 size here is arbitrary; the WlanReasonCodeToString docs fail to specify a recommended size if (WlanInterop.WlanReasonCodeToString(reasonCode, sb.Capacity, sb, IntPtr.Zero) != 0) { sb.Clear(); // Not sure if we get junk in the stringbuilder buffer from WlanReasonCodeToString, clearing it to be sure. sb.Append("Failed to retrieve reason code, probably too small buffer."); } return sb.ToString(); }
/// <summary> /// Gets a string that describes a specified reason code. NOTE: Not used! /// </summary> /// <param name="reasonCode">The reason code.</param> /// <returns>The string.</returns> internal static string GetStringForReasonCode(WlanReasonCode reasonCode) { StringBuilder sb = new StringBuilder(1024); // the 1024 size here is arbitrary; the WlanReasonCodeToString docs fail to specify a recommended size if (WlanInterop.WlanReasonCodeToString(reasonCode, sb.Capacity, sb, IntPtr.Zero) != 0) { sb.Clear(); // Not sure if we get junk in the stringbuilder buffer from WlanReasonCodeToString, clearing it to be sure. sb.Append("Failed to retrieve reason code, probably too small buffer."); } return(sb.ToString()); }
internal void OnWlanReason(WlanNotificationData notifyData, WlanReasonCode reasonCode) { WlanReasonNotification?.Invoke(notifyData, reasonCode); if (queueEvents) { var queuedEvent = new WlanReasonNotificationData { notifyData = notifyData, reasonCode = reasonCode }; EnqueueEvent(queuedEvent); } }
internal void OnWlanReason(WlanNotificationData notifyData, WlanReasonCode reasonCode) { if (WlanReasonNotification != null) { WlanReasonNotification(notifyData, reasonCode); } if (queueEvents) { WlanReasonNotificationData queuedEvent = new WlanReasonNotificationData(); queuedEvent.notifyData = notifyData; queuedEvent.reasonCode = reasonCode; EnqueueEvent(queuedEvent); } }
public static extern int WlanReasonCodeToString( [In] WlanReasonCode reasonCode, [In] int bufferSize, [In, Out] StringBuilder stringBuffer, IntPtr pReserved );
public WlanException(WlanReasonCode reasonCode) { this.reasonCode = reasonCode; }
WlanException(WlanReasonCode reasonCode) { _reasonCode = reasonCode; }
WlanException(WlanReasonCode reasonCode) { this.reasonCode = reasonCode; }
internal static extern int WlanReasonCodeToString( [In] WlanReasonCode dwReasonCode, [In] uint dwBufferSize, [In, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pStringBuffer, //ref? [In, Out] IntPtr pReserved );
public static extern int WlanSetProfile([In] IntPtr clientHandle, [In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceGuid, [In] WlanProfileFlags flags, [In, MarshalAs(UnmanagedType.LPWStr)] string profileXml, [In, Optional, MarshalAs(UnmanagedType.LPWStr)] string allUserProfileSecurity, [In] bool overwrite, [In] IntPtr pReserved, out WlanReasonCode reasonCode);
internal void OnWlanReason(WlanNotificationData notifyData, WlanReasonCode reasonCode) { if (WlanReasonNotification != null) WlanReasonNotification(notifyData, reasonCode); }
// Called from interop private void OnWlanNotification(ref WlanNotificationData notifyData, IntPtr context) { if (NoWifiAvailable) { return; } WlanInterface wlanIface = ifaces.ContainsKey(notifyData.interfaceGuid) ? ifaces[notifyData.interfaceGuid] : null; switch (notifyData.notificationSource) { case WlanNotificationSource.ACM: switch ((WlanNotificationCodeAcm)notifyData.notificationCode) { case WlanNotificationCodeAcm.ConnectionStart: case WlanNotificationCodeAcm.ConnectionComplete: case WlanNotificationCodeAcm.ConnectionAttemptFail: case WlanNotificationCodeAcm.Disconnecting: case WlanNotificationCodeAcm.Disconnected: WlanConnectionNotificationData?connNotifyData = WlanHelpers.ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue && wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } break; case WlanNotificationCodeAcm.ScanFail: int expectedSize = Marshal.SizeOf(typeof(int)); if (notifyData.dataSize >= expectedSize) { int reasonInt = Marshal.ReadInt32(notifyData.dataPtr); // Want to make sure this doesn't crash if windows sends a reasoncode not defined in the enum. if (Enum.IsDefined(typeof(WlanReasonCode), reasonInt)) { WlanReasonCode reasonCode = (WlanReasonCode)reasonInt; if (wlanIface != null) { wlanIface.OnWlanReason(notifyData, reasonCode); } } } break; } break; case WlanNotificationSource.MSM: switch ((WlanNotificationCodeMsm)notifyData.notificationCode) { case WlanNotificationCodeMsm.Associating: case WlanNotificationCodeMsm.Associated: case WlanNotificationCodeMsm.Authenticating: case WlanNotificationCodeMsm.Connected: case WlanNotificationCodeMsm.RoamingStart: case WlanNotificationCodeMsm.RoamingEnd: case WlanNotificationCodeMsm.Disassociating: case WlanNotificationCodeMsm.Disconnected: case WlanNotificationCodeMsm.PeerJoin: case WlanNotificationCodeMsm.PeerLeave: case WlanNotificationCodeMsm.AdapterRemoval: WlanConnectionNotificationData?connNotifyData = WlanHelpers.ParseWlanConnectionNotification(ref notifyData); if (connNotifyData.HasValue && wlanIface != null) { wlanIface.OnWlanConnection(notifyData, connNotifyData.Value); } break; } break; } if (wlanIface != null) { wlanIface.OnWlanNotification(notifyData); } }
internal void OnWlanReason(WlanNotificationData notifyData, WlanReasonCode reasonCode) { if (WlanReasonNotification != null) WlanReasonNotification(notifyData, reasonCode); if (queueEvents) { WlanReasonNotificationData queuedEvent = new WlanReasonNotificationData(); queuedEvent.notifyData = notifyData; queuedEvent.reasonCode = reasonCode; EnqueueEvent(queuedEvent); } }