Ejemplo n.º 1
0
		private static void OnWlanNotification(ref WlanInternNotificationData data, IntPtr context)
		{
			var nic = Nic.PerId(data.nicGuid);

			switch (data.notificationSource)
			{
				case NotificationSource.Acm:
					switch ((NotificationCodeAcm) data.notificationCode)
					{
						case NotificationCodeAcm.ConnectionStart:
						case NotificationCodeAcm.ConnectionComplete:
						case NotificationCodeAcm.ConnectionAttemptFail:
						case NotificationCodeAcm.Disconnecting:
						case NotificationCodeAcm.Disconnected:
							WlanInternNotificationConnectionData? connNotifyData = ParseWlanConnectionNotification(ref data);
							if (connNotifyData.HasValue)
								if (nic != null)
									nic.Wlan.OnConnectionNotification(data, connNotifyData.Value);
							break;
						case NotificationCodeAcm.ScanFail:
						{
							int expectedSize = Marshal.SizeOf(typeof (int));
							if (data.dataSize >= expectedSize)
							{
								var reasonCode = (ReasonCode) Marshal.ReadInt32(data.dataPtr);
								if (nic != null)
									nic.Wlan.OnReasonNotification(data, reasonCode);
							}
						}
							break;
					}
					break;
				case NotificationSource.Msm:
					switch ((NotificationCodeMsm) data.notificationCode)
					{
						case NotificationCodeMsm.Associating:
						case NotificationCodeMsm.Associated:
						case NotificationCodeMsm.Authenticating:
						case NotificationCodeMsm.Connected:
						case NotificationCodeMsm.RoamingStart:
						case NotificationCodeMsm.RoamingEnd:
						case NotificationCodeMsm.Disassociating:
						case NotificationCodeMsm.Disconnected:
						case NotificationCodeMsm.PeerJoin:
						case NotificationCodeMsm.PeerLeave:
						case NotificationCodeMsm.AdapterRemoval:
							WlanInternNotificationConnectionData? connNotifyData = ParseWlanConnectionNotification(ref data);
							if (connNotifyData.HasValue)
								if (nic != null)
									nic.Wlan.OnConnectionNotification(data, connNotifyData.Value);
							break;
					}
					break;
			}

			if (nic != null)
				nic.Wlan.OnNotification(data);
		}
		internal WlanConnectionNotificationEventArgs(WlanInternNotificationData data, WlanInternNotificationConnectionData c)
		{
			Source = data.notificationSource;
			Code = data.NotificationCode;
			BssType = c.dot11BssType;
			ProfileName = c.profileName;
			ProfileXml = c.profileXml;
			SecurityEnabled = c.securityEnabled;
			ConnectionMode = c.ConnectionMode;
			ReasonCode = c.wlanReasonCode;
			Ssid = c.Dot11Ssid.GetSsid();
		}
Ejemplo n.º 3
0
		private static WlanInternNotificationConnectionData? ParseWlanConnectionNotification(ref WlanInternNotificationData notifyData)
		{
			int expectedSize = Marshal.SizeOf(typeof (WlanInternNotificationConnectionData));
			if (notifyData.dataSize < expectedSize)
				return null;

			var notifyConnectionData = (WlanInternNotificationConnectionData) Marshal.PtrToStructure(notifyData.dataPtr, typeof (WlanInternNotificationConnectionData));
			if (notifyConnectionData.wlanReasonCode == ReasonCode.Success)
			{
				var profileXmlPtr = new IntPtr(notifyData.dataPtr.ToInt64() + Marshal.OffsetOf(typeof (WlanInternNotificationConnectionData), "profileXml").ToInt64());

				notifyConnectionData.profileXml = Marshal.PtrToStringUni(profileXmlPtr);
			}

			return notifyConnectionData;
		}
		internal WlanReasonNotificationEventArgs(WlanInternNotificationData data, ReasonCode code)
		{
			Source = data.notificationSource;
			Code = data.NotificationCode;
			ReasonCode = code;
		}
Ejemplo n.º 5
0
		internal void OnNotification(WlanInternNotificationData nd)
		{
			if (nd.NotificationCode.Equals(NotificationCodeAcm.ConnectionComplete) || nd.NotificationCode.Equals(NotificationCodeAcm.Disconnected))
			{
				State.Reload();
			}
			else if (nd.NotificationCode.Equals(NotificationCodeAcm.ScanComplete))
			{
				ReloadSsidList();
				ReloadBssList();
				State.SetScanFinished(true);
			}
			else if (nd.NotificationCode.Equals(NotificationCodeAcm.ScanFail))
			{
				State.SetScanFinished(false);
			}
			else if (nd.NotificationCode.Equals(NotificationCodeAcm.Disconnected))
			{
				ConnectedWlan = null;
			}
		}
Ejemplo n.º 6
0
		internal void OnReasonNotification(WlanInternNotificationData notificationdata, ReasonCode reason)
		{
			//var args = new WlanReasonNotificationEventArgs(notificationdata, reason);
		}
Ejemplo n.º 7
0
		internal void OnConnectionNotification(WlanInternNotificationData notificationdata, WlanInternNotificationConnectionData value)
		{
			//var args = new WlanConnectionNotificationEventArgs(notificationdata, value);
		}
Ejemplo n.º 8
0
		/// <summary>
		///     Indicates the reason for an operation failure. This field has a value of <see cref="ReasonCode.Success" />
		///     for all connection-related notifications except <see cref="NotificationCodeAcm.ConnectionComplete" />. If the
		///     connection fails, this field indicates the reason for the failure.
		/// </summary>
		internal WlanNotificationEventArgs(WlanInternNotificationData data)
		{
			Source = data.notificationSource;
			Code = data.NotificationCode;
		}