private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context)
        {
            WlanInterface wlanIface = ifaces.ContainsKey(notifyData.interfaceGuid) ? ifaces[notifyData.interfaceGuid] : null;

            switch (notifyData.notificationSource)
            {
            case Wlan.WlanNotificationSource.ACM:
                switch ((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode)
                {
                case Wlan.WlanNotificationCodeAcm.AdhocNetworkStateChange:
                    //int expectedSize = Marshal.SizeOf(typeof(Wlan.WlanAdhocNetworkState));
                    //if (notifyData.dataSize >= expectedSize)
                    //{
                    Wlan.WlanAdhocNetworkState adhocNetworkState = (Wlan.WlanAdhocNetworkState)Marshal.ReadInt32(notifyData.dataPtr);
                    if (wlanIface != null)
                    {
                        wlanIface.OnWlanAdhocNetwork(notifyData, adhocNetworkState);
                    }
                    //}
                    break;

                case Wlan.WlanNotificationCodeAcm.ConnectionStart:
                case Wlan.WlanNotificationCodeAcm.ConnectionComplete:
                case Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail:
                case Wlan.WlanNotificationCodeAcm.Disconnecting:
                case Wlan.WlanNotificationCodeAcm.Disconnected:
                    Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData);
                    if (connNotifyData.HasValue)
                    {
                        if (wlanIface != null)
                        {
                            wlanIface.OnWlanConnection(notifyData, connNotifyData.Value);
                        }
                    }
                    break;

                case Wlan.WlanNotificationCodeAcm.ScanFail:
                    try
                    {
                        int expectedSize = Marshal.SizeOf(typeof(Wlan.WlanReasonCode));
                        if (notifyData.dataSize >= expectedSize)
                        {
                            Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr);
                            if (wlanIface != null)
                            {
                                wlanIface.OnWlanReason(notifyData, reasonCode);
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }

                    break;
                }
                break;

            case Wlan.WlanNotificationSource.MSM:
                switch ((Wlan.WlanNotificationCodeMsm)notifyData.notificationCode)
                {
                case Wlan.WlanNotificationCodeMsm.Associating:
                case Wlan.WlanNotificationCodeMsm.Associated:
                case Wlan.WlanNotificationCodeMsm.Authenticating:
                case Wlan.WlanNotificationCodeMsm.Connected:
                case Wlan.WlanNotificationCodeMsm.RoamingStart:
                case Wlan.WlanNotificationCodeMsm.RoamingEnd:
                case Wlan.WlanNotificationCodeMsm.Disassociating:
                case Wlan.WlanNotificationCodeMsm.Disconnected:
                case Wlan.WlanNotificationCodeMsm.PeerJoin:
                case Wlan.WlanNotificationCodeMsm.PeerLeave:
                case Wlan.WlanNotificationCodeMsm.AdapterRemoval:
                    Wlan.WlanConnectionNotificationData?connNotifyData = ParseWlanConnectionNotification(ref notifyData);
                    if (connNotifyData.HasValue)
                    {
                        if (wlanIface != null)
                        {
                            wlanIface.OnWlanConnection(notifyData, connNotifyData.Value);
                        }
                    }
                    break;
                }
                break;
            }

            if (wlanIface != null)
            {
                wlanIface.OnWlanNotification(notifyData);
            }
        }