internal void OnWlanNotification(WlanNotificationData notifyData)
 {
     if (WlanNotification != null)
     {
         WlanNotification(notifyData);
     }
 }
Exemple #2
0
 /// <summary>
 /// Receives the event from the Wlan interface when ever there is a change in the connection status
 /// </summary>
 /// <param name="notifyData">Wireless status notification</param>
 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);
     }
 }
        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);
            }
        }
        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);
            }
        }
 private void _wlanInterface_WlanConnectionNotification(WlanNotificationData notifyData, WlanConnectionNotificationData connNotifyData)
 {
     System.Diagnostics.Debug.WriteLine(notifyData.NotificationCode);
 }
Exemple #6
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);
            }
        }
Exemple #7
0
        internal 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);
        }