Exemplo n.º 1
0
 internal void OnWlanReason(WlanNotificationData notifyData, WlanReasonCode reasonCode)
 {
     if (WlanReasonNotification != null)
     {
         WlanReasonNotification(notifyData, reasonCode);
     }
 }
Exemplo n.º 2
0
 public void OnWlanNotification(WlanNotificationData notifyData)
 {
     if (WlanNotification != null)
     {
         WlanNotification(notifyData);
     }
 }
Exemplo n.º 3
0
        private void Inte_WlanNotification(WlanNotificationData notifyData)
        {
            var listofPoints = GetAccessPoints();

            currentState = new WifiState();
            foreach (var network in listofPoints)
            {
                var networkInterface = _client.Interfaces.Where(i => i.CurrentConnection.profileName == network.profileName).FirstOrDefault();
                if (networkInterface != null)
                {
                    currentState.SSID       = Encoding.ASCII.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength);
                    currentState.IsInsecure = !network.securityEnabled;
                    for (int i = 0; i < _client.Interfaces.Length; i++)
                    {
                        var interf = _client.Interfaces[i];
                        if (interf.InterfaceGuid == notifyData.interfaceGuid)
                        {
                            currentState.InterfaceName  = interf.InterfaceName;
                            currentState.InterfaceIndex = i;
                        }
                    }
                }
            }

            WifiStateChanged.Invoke(this.CurrentState);
        }
Exemplo n.º 4
0
 internal void OnWlanConnection(WlanNotificationData notifyData, WlanConnectionNotificationData connNotifyData)
 {
     if (WlanConnectionNotification != null)
     {
         WlanConnectionNotification(notifyData, connNotifyData);
     }
 }
Exemplo n.º 5
0
 internal void OnWlanNotification(WlanNotificationData notifyData)
 {
     if (WlanNotification != null)
     {
         WlanNotification(notifyData);
     }
 }
Exemplo n.º 6
0
 private void inte_WlanNotification(WlanNotificationData notifyData)
 {
     if (notifyData.notificationSource == WlanNotificationSource.ACM && (NotifCodeACM)notifyData.NotificationCode == NotifCodeACM.Disconnected)
     {
         OnConnectionStatusChanged(WifiStatus.Disconnected);
     }
     else if (notifyData.notificationSource == WlanNotificationSource.MSM && (NotifCodeMSM)notifyData.NotificationCode == NotifCodeMSM.Connected)
     {
         OnConnectionStatusChanged(WifiStatus.Connected);
     }
 }
Exemplo n.º 7
0
 public void WlanNotificationChanged(WlanNotificationData e)
 {
     if (e.NotificationCode.Equals(WlanNotificationCodeAcm.ScanComplete))
     {
         ScanSuccessful = true;
     }
     else if (e.NotificationCode.Equals(WlanNotificationCodeAcm.ScanFail))
     {
         LastFailReason = e.NotificationCode.ToString();
         ScanSuccessful = false;
     }
 }
Exemplo n.º 8
0
        internal void OnWlanConnection(WlanNotificationData notifyData, WlanConnectionNotificationData connNotifyData)
        {
            WlanConnectionNotification?.Invoke(notifyData, connNotifyData);

            if (queueEvents)
            {
                var queuedEvent = new WlanConnectionNotificationEventData
                {
                    notifyData     = notifyData,
                    connNotifyData = connNotifyData
                };
                EnqueueEvent(queuedEvent);
            }
        }
Exemplo n.º 9
0
        internal void OnWlanConnection(WlanNotificationData notifyData, WlanConnectionNotificationData connNotifyData)
        {
            WlanConnectionNotification?.Invoke(notifyData, connNotifyData);

            if (!_queueEvents)
            {
                return;
            }
            WlanConnectionNotificationEventData queuedEvent = new WlanConnectionNotificationEventData();

            queuedEvent.NotifyData     = notifyData;
            queuedEvent.ConnNotifyData = connNotifyData;
            EnqueueEvent(queuedEvent);
        }
Exemplo n.º 10
0
        internal void OnWlanReason(WlanNotificationData notifyData, WlanReasonCode reasonCode)
        {
            WlanReasonNotification?.Invoke(notifyData, reasonCode);

            if (queueEvents)
            {
                var queuedEvent = new WlanReasonNotificationData
                {
                    notifyData = notifyData,
                    reasonCode = reasonCode
                };
                EnqueueEvent(queuedEvent);
            }
        }
Exemplo n.º 11
0
        internal void OnWlanConnection(WlanNotificationData notifyData, WlanConnectionNotificationData connNotifyData)
        {
            if (WlanConnectionNotification != null)
            {
                WlanConnectionNotification(notifyData, connNotifyData);
            }

            if (queueEvents)
            {
                WlanConnectionNotificationEventData queuedEvent = new WlanConnectionNotificationEventData();
                queuedEvent.notifyData     = notifyData;
                queuedEvent.connNotifyData = connNotifyData;
                EnqueueEvent(queuedEvent);
            }
        }
Exemplo n.º 12
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);
            }
        }
Exemplo n.º 13
0
        private void inte_WlanNotification(WlanNotificationData notifyData)
        {
            // Push this notification out to our listners
            if (WirelessNotification != null)
            {
                WirelessNotification(this, new WlanNotificationEventArgs(notifyData));
            }

            if (notifyData.notificationSource == WlanNotificationSource.ACM && (NotifCodeACM)notifyData.NotificationCode == NotifCodeACM.Disconnected)
            {
                OnConnectionStatusChanged(WifiStatus.Disconnected);
            }
            else if (notifyData.notificationSource == WlanNotificationSource.MSM && (NotifCodeMSM)notifyData.NotificationCode == NotifCodeMSM.Connected)
            {
                OnConnectionStatusChanged(WifiStatus.Connected);
            }
        }
        public static WlanConnectionNotificationData?ParseWlanConnectionNotification(ref WlanNotificationData notifyData)
        {
            int expectedSize = Marshal.SizeOf(typeof(WlanConnectionNotificationData));

            if (notifyData.dataSize < expectedSize)
            {
                return(null);
            }

            WlanConnectionNotificationData connNotifyData = (WlanConnectionNotificationData)Marshal.PtrToStructure(notifyData.dataPtr, typeof(WlanConnectionNotificationData));

            if (connNotifyData.wlanReasonCode == WlanReasonCode.Success)
            {
                long profileXmlPtrValue = notifyData.dataPtr.ToInt64() + Marshal.OffsetOf(typeof(WlanConnectionNotificationData), "profileXml").ToInt64();
                connNotifyData.profileXml = Marshal.PtrToStringUni(new IntPtr(profileXmlPtrValue));
            }

            return(connNotifyData);
        }
Exemplo n.º 15
0
        // EVENTS =============================================================

        private WlanConnectionNotificationData?ParseWlanConnectionNotificationData(ref WlanNotificationData notifyData)
        {
            int expectedSize = Marshal.SizeOf(typeof(WlanConnectionNotificationData));

            if (notifyData.DataSize < expectedSize)
            {
                return(null);
            }

            WlanConnectionNotificationData connNotifyData =
                (WlanConnectionNotificationData)
                Marshal.PtrToStructure(notifyData.Data, typeof(WlanConnectionNotificationData));

            if (connNotifyData.ReasonCode == WlanReasonCode.Success)
            {
                IntPtr profileXmlPtr = new IntPtr(
                    notifyData.Data.ToInt64() +
                    Marshal.OffsetOf(typeof(WlanConnectionNotificationData), "ProfileXml").ToInt64());
                connNotifyData.ProfileXml = Marshal.PtrToStringUni(profileXmlPtr);
            }
            return(connNotifyData);
        }
Exemplo n.º 16
0
        private void inte_WlanNotification(WlanNotificationData notifyData)
        {
            if (notifyData.notificationSource == WlanNotificationSource.ACM)
            {
                switch ((NotifCodeACM)notifyData.NotificationCode)
                {
                case NotifCodeACM.ScanComplete:
                    OnConnectionStatusChanged(WifiStatus.ScanCompleted);
                    break;

                case NotifCodeACM.ScanFail:
                    OnConnectionStatusChanged(WifiStatus.ScanFailed);
                    break;

                case NotifCodeACM.Disconnected:
                    OnConnectionStatusChanged(WifiStatus.Disconnected);
                    break;
                }
            }
            else if (notifyData.notificationSource == WlanNotificationSource.MSM && (NotifCodeMSM)notifyData.NotificationCode == NotifCodeMSM.Connected)
            {
                OnConnectionStatusChanged(WifiStatus.Connected);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 18
0
 internal void OnWlanNotification(WlanNotificationData notifyData)
 {
     WlanNotification?.Invoke(notifyData);
 }
Exemplo n.º 19
0
        private void OnNotification(WlanNotificationData notificationData, IntPtr context)
        {
            if (notificationData.NotificationSource == WlanNotificationSource.HostedNetwork)
            {
                switch (notificationData.NotificationCode)
                {
                    case WlanHostedNetworkNotificationCode.StateChange:
                        if (Marshal.SizeOf(typeof(WlanHostedNetworkStateChange)) == notificationData.DataSize
                            && notificationData.Data != IntPtr.Zero)
                        {
                            var stateChange =
                                (WlanHostedNetworkStateChange)Marshal.PtrToStructure(notificationData.Data,
                                    typeof(WlanHostedNetworkStateChange));

                            switch (stateChange.NewState)
                            {
                                case WlanHostedNetworkState.Active:
                                    Logger.Info("OnNotification: Hosted network started");
                                    OnHostedNetworkStarted();
                                    break;
                                case WlanHostedNetworkState.Idle:
                                    if (stateChange.OldState == WlanHostedNetworkState.Active)
                                    {
                                        Logger.Info("OnNotification: Hosted network stopped");
                                        OnHostedNetworkStopped();
                                    }
                                    else
                                    {
                                        Logger.Info("OnNotification: Hosted network enabled");
                                        OnHostedNetworkEnabled();
                                    }
                                    break;
                                case WlanHostedNetworkState.Unavailable:
                                    if (stateChange.OldState == WlanHostedNetworkState.Active)
                                    {
                                        Logger.Info("OnNotification: Hosted network stopped");
                                        OnHostedNetworkStopped();
                                    }
                                    Logger.Info("OnNotification: Hosted network disabled");
                                    OnHostedNetworkDisabled();
                                    break;
                            }
                        }
                        break;
                    case WlanHostedNetworkNotificationCode.PeerStateChange:
                        if (Marshal.SizeOf(typeof(WlanHostedNetworkDataPeerStateChange)) == notificationData.DataSize
                            && notificationData.Data != IntPtr.Zero)
                        {
                            var peerStateChange =
                                (WlanHostedNetworkDataPeerStateChange)
                                    Marshal.PtrToStructure(notificationData.Data,
                                        typeof(WlanHostedNetworkDataPeerStateChange));

                            if (peerStateChange.NewState.PeerAuthState == WlanHostedNetworkPeerAuthState.Authenticated)
                            {
                                Logger.Info("OnNotification: New device {0} connected", BitConverter.ToString(peerStateChange.NewState.PeerMacAddress));
                                OnDeviceConnected(peerStateChange.NewState);
                            }
                            if (peerStateChange.NewState.PeerAuthState == WlanHostedNetworkPeerAuthState.Invalid)
                            {
                                Logger.Info("OnNotification: New device {0} disconnected", BitConverter.ToString(peerStateChange.NewState.PeerMacAddress));
                                OnDeviceDisconnected(peerStateChange.NewState.PeerMacAddress);
                            }
                        }
                        break;
                }
            }
        }
Exemplo n.º 20
0
 internal void OnWlanConnection(WlanNotificationData notifyData, WlanConnectionNotificationData connNotifyData)
 {
     if (WlanConnectionNotification != null)
         WlanConnectionNotification(notifyData, connNotifyData);
 }
Exemplo n.º 21
0
 internal void OnWlanReason(WlanNotificationData notifyData, WlanReasonCode reasonCode)
 {
     if (WlanReasonNotification != null)
         WlanReasonNotification(notifyData, reasonCode);
 }
Exemplo n.º 22
0
 internal WlanNotificationEventArgs(WlanNotificationData status) : base()
 {
     this.eventData = status;
 }
Exemplo n.º 23
0
        internal void OnWlanNotification(ref WlanNotificationData data, IntPtr context)
        {
            WlanInterface wlanIface = null;
            WlanEventArgs wlanEvent = WlanEventArgs.Empty;

            if (interfaceMap.ContainsKey(data.InterfaceGuid))
            {
                wlanIface = interfaceMap[data.InterfaceGuid];
                wlanEvent.InterfaceGuid = wlanIface.Guid;
            }
            wlanEvent.NotificationSource = data.NotificationSource;
            wlanEvent.NotificationCode   = data.NotificationCode;

            switch (data.NotificationSource)
            {
            case WlanNotificationSource.Acm:
                switch ((WlanAcmNotificationCode)data.NotificationCode)
                {
                case WlanAcmNotificationCode.ConnectionStart:
                case WlanAcmNotificationCode.ConnectionAttemptFail:
                case WlanAcmNotificationCode.Disconnecting:
                case WlanAcmNotificationCode.Disconnected:
                    break;

                case WlanAcmNotificationCode.ConnectionComplete:
                    WlanConnectionNotificationData?conNotif = ParseWlanConnectionNotificationData(ref data);
                    if (conNotif.HasValue && wlanIface != null)
                    {
                        AcmConnectionEventArgs conArgs = new AcmConnectionEventArgs();
                        conArgs.ConnectionData   = conNotif.Value;
                        conArgs.NotificationCode = WlanAcmNotificationCode.ConnectionComplete;
                        wlanIface.OnAcmConnectionCompleted(conArgs);
                    }
                    break;

                case WlanAcmNotificationCode.ScanFail:
                    //TODO parse WLAN_REASON_CODE in field Data
                    break;

                case WlanAcmNotificationCode.BssTypeChange:
                    //TODO parse DOT11_BSS_TYPE in field Data
                    break;

                case WlanAcmNotificationCode.PowerSettingChange:
                    //TODO parse WLAN_POWER_SETTING in field Data
                    break;

                case WlanAcmNotificationCode.ProfileNameChange:
                    //TODO parse two null-terminated WCHAR strings in field Data
                    break;

                case WlanAcmNotificationCode.AdhocNetworkStateChange:
                    //TODO parse WLAN_ADHOC_NETWORK_STATE in field Data
                    break;

                case WlanAcmNotificationCode.ScreenPowerChange:
                    //TODO parse BOOL in field Data
                    break;
                }
                OnAcmNotification(new AcmEventArgs());
                break;

            case WlanNotificationSource.Msm:
                switch ((WlanMsmNotificationCode)data.NotificationCode)
                {
                case WlanMsmNotificationCode.Associating:
                case WlanMsmNotificationCode.Associated:
                case WlanMsmNotificationCode.Authenticating:
                case WlanMsmNotificationCode.Connected:
                case WlanMsmNotificationCode.RoamingStart:
                case WlanMsmNotificationCode.RoamingEnd:
                case WlanMsmNotificationCode.Disassociating:
                case WlanMsmNotificationCode.Disconnected:
                case WlanMsmNotificationCode.PeerJoin:
                case WlanMsmNotificationCode.PeerLeave:
                case WlanMsmNotificationCode.AdapterRemoval:
                    //TODO parse WLAN_MSM_NOTIFICATION_DATA in field Data
                    break;

                case WlanMsmNotificationCode.AdapterOperationModeChange:
                    //TODO parse ULONG in field Data
                    break;

                case WlanMsmNotificationCode.SignalQualityChange:
                    //TODO parse ULONG for WLAN_SIGNAL_QUALITY in field Data
                    break;

                case WlanMsmNotificationCode.RadioStateChange: {
                    WlanPhyRadioState            radioState = Util.ParseStruct <WlanPhyRadioState>(data.Data, data.DataSize);
                    MsmRadioStateChangeEventArgs eventArgs  = new MsmRadioStateChangeEventArgs();
                    eventArgs.RadioState = radioState;
                    wlanIface.OnMsmRadioStateChange(eventArgs);
                }
                break;
                }
                OnMsmNotification(new MsmEventArgs());
                break;

            case WlanNotificationSource.OneX:
                OnOneXNotification(new OneXEventArgs());
                break;     //TODO

            case WlanNotificationSource.Security:
                OnSecurityNotification(new SecurityEventArgs());
                break;     //TODO

            case WlanNotificationSource.Ihv: {
                IhvEventArgs eventArgs = new IhvEventArgs();
                eventArgs.Data     = data.Data;
                eventArgs.DataSize = data.DataSize;
                OnIhvNotification(eventArgs);
            }
            break;         //TODO

            case WlanNotificationSource.HostedNetwork:
                if (HostedNetwork != null)
                {
                    switch ((WlanHostedNetworkNotificationCode)data.NotificationCode)
                    {
                    case WlanHostedNetworkNotificationCode.PeerStateChange: {
                        WlanHostedNetworkDataPeerStateChange peerStateChange = Util.ParseStruct <WlanHostedNetworkDataPeerStateChange>(data.Data, data.DataSize);
                        HnwkPeerStateChangeEventArgs         eventArgs       = new HnwkPeerStateChangeEventArgs();
                        eventArgs.PeerState = peerStateChange;
                        HostedNetwork.OnHnwkPeerStateChange(eventArgs);
                    }
                    break;

                    case WlanHostedNetworkNotificationCode.RadioStateChange: {
                        WlanHostedNetworkRadioState   radioState = Util.ParseStruct <WlanHostedNetworkRadioState>(data.Data, data.DataSize);
                        HnwkRadioStateChangeEventArgs eventArgs  = new HnwkRadioStateChangeEventArgs();
                        eventArgs.RadioState = radioState;
                        HostedNetwork.OnHnwkRadioStateChange(eventArgs);
                    }
                    break;

                    case WlanHostedNetworkNotificationCode.StateChange: {
                        WlanHostedNetworkStateChange stateChange = Util.ParseStruct <WlanHostedNetworkStateChange>(data.Data, data.DataSize);
                        HnwkStateChangeEventArgs     eventArgs   = new HnwkStateChangeEventArgs();
                        eventArgs.State = stateChange;
                        HostedNetwork.OnHnwkStateChange(eventArgs);
                    }
                    break;
                    }
                    wlanEvent.InterfaceGuid = HostedNetwork.Guid;
                    OnHwnkNotification(new HnwkEventArgs());
                }
                break;
            }
            OnWlanNotification(wlanEvent);
        }
Exemplo n.º 24
0
		internal void OnWlanNotification(WlanNotificationData notifyData)
		{
			if (WlanNotification != null)
				WlanNotification(notifyData);
		}
Exemplo n.º 25
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);
			}
		}
Exemplo n.º 26
0
		public void OnWlanNotification(WlanNotificationData notifyData)
		{
			if (WlanNotification != null)
				WlanNotification(notifyData);
		}
Exemplo n.º 27
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);
		}
Exemplo n.º 28
0
		internal void OnWlanConnection(WlanNotificationData notifyData, WlanConnectionNotificationData connNotifyData)
		{
			if (WlanConnectionNotification != null)
				WlanConnectionNotification(notifyData, connNotifyData);

			if (queueEvents)
			{
				WlanConnectionNotificationEventData queuedEvent = new WlanConnectionNotificationEventData();
				queuedEvent.notifyData = notifyData;
				queuedEvent.connNotifyData = connNotifyData;
				EnqueueEvent(queuedEvent);
			}
		}
Exemplo n.º 29
0
        private void OnNotification(WlanNotificationData notificationData, IntPtr context)
        {
            if (notificationData.NotificationSource == WlanNotificationSource.HostedNetwork)
            {
                switch (notificationData.NotificationCode)
                {
                case WlanHostedNetworkNotificationCode.StateChange:
                    if (Marshal.SizeOf(typeof(WlanHostedNetworkStateChange)) == notificationData.DataSize &&
                        notificationData.Data != IntPtr.Zero)
                    {
                        var stateChange =
                            (WlanHostedNetworkStateChange)Marshal.PtrToStructure(notificationData.Data,
                                                                                 typeof(WlanHostedNetworkStateChange));

                        switch (stateChange.NewState)
                        {
                        case WlanHostedNetworkState.Active:
                            Logger.Info("OnNotification: Hosted network started");
                            OnHostedNetworkStarted();
                            break;

                        case WlanHostedNetworkState.Idle:
                            if (stateChange.OldState == WlanHostedNetworkState.Active)
                            {
                                Logger.Info("OnNotification: Hosted network stopped");
                                OnHostedNetworkStopped();
                            }
                            else
                            {
                                Logger.Info("OnNotification: Hosted network enabled");
                                OnHostedNetworkEnabled();
                            }
                            break;

                        case WlanHostedNetworkState.Unavailable:
                            if (stateChange.OldState == WlanHostedNetworkState.Active)
                            {
                                Logger.Info("OnNotification: Hosted network stopped");
                                OnHostedNetworkStopped();
                            }
                            Logger.Info("OnNotification: Hosted network disabled");
                            OnHostedNetworkDisabled();
                            break;
                        }
                    }
                    break;

                case WlanHostedNetworkNotificationCode.PeerStateChange:
                    if (Marshal.SizeOf(typeof(WlanHostedNetworkDataPeerStateChange)) == notificationData.DataSize &&
                        notificationData.Data != IntPtr.Zero)
                    {
                        var peerStateChange =
                            (WlanHostedNetworkDataPeerStateChange)
                            Marshal.PtrToStructure(notificationData.Data,
                                                   typeof(WlanHostedNetworkDataPeerStateChange));

                        if (peerStateChange.NewState.PeerAuthState == WlanHostedNetworkPeerAuthState.Authenticated)
                        {
                            Logger.Info("OnNotification: New device {0} connected", BitConverter.ToString(peerStateChange.NewState.PeerMacAddress));
                            OnDeviceConnected(peerStateChange.NewState);
                        }
                        if (peerStateChange.NewState.PeerAuthState == WlanHostedNetworkPeerAuthState.Invalid)
                        {
                            Logger.Info("OnNotification: New device {0} disconnected", BitConverter.ToString(peerStateChange.NewState.PeerMacAddress));
                            OnDeviceDisconnected(peerStateChange.NewState.PeerMacAddress);
                        }
                    }
                    break;
                }
            }
        }