Beispiel #1
0
 internal void OnWlanReason(WlanNotificationData notifyData, WlanReasonCode reasonCode)
 {
     if (WlanReasonNotification != null)
     {
         WlanReasonNotification(notifyData, reasonCode);
     }
 }
Beispiel #2
0
        /// <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());
        }
Beispiel #3
0
 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
     );
Beispiel #4
0
 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);
Beispiel #5
0
 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
     );
Beispiel #6
0
		/// <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();
		}
Beispiel #7
0
        /// <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());
        }
Beispiel #8
0
        internal void OnWlanReason(WlanNotificationData notifyData, WlanReasonCode reasonCode)
        {
            WlanReasonNotification?.Invoke(notifyData, reasonCode);

            if (queueEvents)
            {
                var queuedEvent = new WlanReasonNotificationData
                {
                    notifyData = notifyData,
                    reasonCode = reasonCode
                };
                EnqueueEvent(queuedEvent);
            }
        }
Beispiel #9
0
        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);
            }
        }
Beispiel #10
0
 public static extern int WlanReasonCodeToString(
     [In] WlanReasonCode reasonCode,
     [In] int bufferSize,
     [In, Out] StringBuilder stringBuffer,
     IntPtr pReserved
     );
Beispiel #11
0
			public WlanException(WlanReasonCode reasonCode)
			{
				this.reasonCode = reasonCode;
			}
Beispiel #12
0
 WlanException(WlanReasonCode reasonCode)
 {
     _reasonCode = reasonCode;
 }
Beispiel #13
0
 WlanException(WlanReasonCode reasonCode)
 {
     this.reasonCode = reasonCode;
 }
Beispiel #14
0
 internal static extern int WlanReasonCodeToString(
     [In] WlanReasonCode dwReasonCode,
     [In] uint dwBufferSize,
     [In, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pStringBuffer, //ref?
     [In, Out] IntPtr pReserved
     );
Beispiel #15
0
 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);
Beispiel #16
0
 internal void OnWlanReason(WlanNotificationData notifyData, WlanReasonCode reasonCode)
 {
     if (WlanReasonNotification != null)
         WlanReasonNotification(notifyData, reasonCode);
 }
Beispiel #17
0
        // 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);
            }
        }
Beispiel #18
0
		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);
			}
		}