Esempio n. 1
0
        private Wlan.WlanConnectionNotificationData?ParseWlanConnectionNotification(ref Wlan.WlanNotificationData notifyData)
        {
            int expectedSize = Marshal.SizeOf(typeof(Wlan.WlanConnectionNotificationData));

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

            Wlan.WlanConnectionNotificationData connNotifyData =
                (Wlan.WlanConnectionNotificationData)
                Marshal.PtrToStructure(notifyData.dataPtr, typeof(Wlan.WlanConnectionNotificationData));
            if (connNotifyData.wlanReasonCode == Wlan.WlanReasonCode.Success)
            {
                IntPtr profileXmlPtr = new IntPtr(
                    notifyData.dataPtr.ToInt64() +
                    Marshal.OffsetOf(typeof(Wlan.WlanConnectionNotificationData), "profileXml").ToInt64());
                connNotifyData.profileXml = Marshal.PtrToStringUni(profileXmlPtr);
            }
            return(connNotifyData);
        }
Esempio n. 2
0
 void WlanIface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
 {
     if (notifyData.notificationSource == NativeWifi.Wlan.WlanNotificationSource.MSM)
     {
         //这里是完成连接
         if ((NativeWifi.Wlan.WlanNotificationCodeMsm)notifyData.NotificationCode == NativeWifi.Wlan.WlanNotificationCodeMsm.Connected)
         {
             Invoke(new Action(() =>
             {
                 labelControl2.Text      = connNotifyData.profileName;
                 labelControl2.ForeColor = Color.Red;
                 ShowToast_InSetup("提示", "网络连接成功", 2);
             }));
         }
     }
     else if (notifyData.notificationSource == NativeWifi.Wlan.WlanNotificationSource.ACM)
     {
         //连接失败
         if ((NativeWifi.Wlan.WlanNotificationCodeAcm)notifyData.NotificationCode == NativeWifi.Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail)
         {
             Invoke(new Action(() =>
             {
                 labelControl2.Text = "未连接";
             }));
             new Toast().ShowInfo(2500, "WIFI连接失败,请检查密码是否正确");
             WlanIface.DeleteProfile(connNotifyData.profileName);
         }
         if ((NativeWifi.Wlan.WlanNotificationCodeAcm)notifyData.NotificationCode == NativeWifi.Wlan.WlanNotificationCodeAcm.Disconnected)
         {
             Invoke(new Action(() =>
             {
                 labelControl2.Text = "未连接";
             }));
         }
         if ((NativeWifi.Wlan.WlanNotificationCodeAcm)notifyData.NotificationCode == NativeWifi.Wlan.WlanNotificationCodeAcm.Disconnecting)
         {
             Invoke(new Action(() =>
             {
                 labelControl2.Text = "未连接";
             }));
         }
         if ((NativeWifi.Wlan.WlanNotificationCodeAcm)notifyData.NotificationCode == NativeWifi.Wlan.WlanNotificationCodeAcm.ConnectionStart)
         {
             Invoke(new Action(() =>
             {
                 labelControl2.Text = "连接中…";
             }));
         }
     }
 }
Esempio n. 3
0
        public void wlanConnectionChangeHandler(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
        {
            string msg     = String.Empty;
            String device1 = String.Empty;
            String device2 = String.Empty;

            switch (notifyData.notificationSource)
            {
            case Wlan.WlanNotificationSource.ACM:

                switch ((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode)
                {
                case Wlan.WlanNotificationCodeAcm.ConnectionStart:
                    msg = "ConnectionStart";
                    break;

                case Wlan.WlanNotificationCodeAcm.ConnectionComplete:
                    msg = "ConnectionComplete";
                    //WlanClient client = new WlanClient();
                    foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
                    {
                        Wlan.WlanAssociationAttributes conAttributes = wlanIface.CurrentConnection.wlanAssociationAttributes;
                        Wlan.Dot11Ssid ssid = conAttributes.dot11Ssid;
                        try
                        {
                            device1 = (String)list2.Items[0];
                            device2 = (String)list2.Items[1];
                        }
                        catch (Exception e)
                        {
                            // If for some reason the device name is not populated then initialize it to NULL .
                            device1 = null;
                            device2 = null;
                        }
                        if (device1 != null && device2 != null)
                        {
                            if (GetStringForSSID(ssid) != device1)
                            {
                                if (GetStringForSSID(ssid) != device2)
                                {
                                    msg = "MainServices (connectionChange Handler): Wireless connection is BROKEN ! Locking the system . ";
                                    log.dispatchLogMessage(msg);
                                    startWireless = 2;
                                    LockWorkStation();
                                    unregisterWlanListener();
                                }
                            }
                        }
                        break;
                    }

                    break;

                case Wlan.WlanNotificationCodeAcm.Disconnecting:
                    msg = "Disconnecting";
                    break;

                case Wlan.WlanNotificationCodeAcm.Disconnected:
                    msg = "Disconnected";
                    break;

                default:
                    msg = "unknown notificationCode =" + notifyData.notificationCode;
                    break;
                }
                //MessageBox.Show(msg + " for profile:" + connNotifyData.profileName);
                break;

            default:
                //MessageBox.Show("irrelevant notification. Ignore");
                break;
            }
        }
 private void wlanInterface_WlanConnectionNotification(Wlan.WlanNotificationData notificationData, Wlan.WlanConnectionNotificationData connectionData)
 {
     ProcessWifiConnectionEvent(notificationData, connectionData);
 }
        private void ProcessWifiConnectionEvent(Wlan.WlanNotificationData notificationData, Wlan.WlanConnectionNotificationData connectionData)
        {
            if (!IsSentByCorrectNetworkInterface(notificationData))
            {
                return;
            }

            String ssid = CurrentDroneNetworkSsid;

            if (ssid == null)
            {
                return;
            }

            if (ssid.StartsWith(droneNetworkIdentifierStart) && IsDroneNetworkConnected)
            {
                ProcessNetworkConnected();
            }
        }
        private void WlanService_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
        {
            var dot11Ssid = connNotifyData.dot11Ssid;
            var wlanNMAE  = WlanService.GetWlanNameBySsid(dot11Ssid);

            Debug.WriteLine(wlanNMAE);
        }
Esempio n. 7
0
 private void wlanInterfaceTmp_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
 {
     if (connNotifyData.profileName != "")
     {
         WlanClient wlanClientTmp = new WlanClient();
         WlanClient.WlanInterface wlanInterfaceTmp = wlanClientTmp.Interfaces[0];
         Dispatcher.Invoke(() =>
         {
             List <Object> dataList = GetAvailableNetworkList1();
             if (dataList == null)
             {
                 return;
             }
             dataGridWlan1.ItemsSource = dataList;
             if (wlanInterfaceTmp.IsWlanConnection())
             {
                 Wlan.WlanConnectionAttributes wlanAttr = wlanInterfaceTmp.CurrentConnection;
                 if (wlanAttr.isState == Wlan.WlanInterfaceState.Connected)
                 {
                     string macAddress = GetMacAddress(wlanAttr.wlanAssociationAttributes.dot11Bssid);
                     tbState.Text      = String.Format("当前设备已连接到Wlan: {0}, Mac地址: {1} IPv4地址: {2}", wlanAttr.profileName, macAddress, PathUtil.GetIPv4());
                 }
             }
         });
     }
 }
Esempio n. 8
0
        //当连接的连接状态进行通知 面是简单的通知事件的实现,根据通知的内容在界面上显示提示信息:
        private void WlanInterface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
        {
            try
            {
                if (notifyData.notificationSource == Wlan.WlanNotificationSource.ACM)
                {
                    int notificationCode = (int)notifyData.NotificationCode;
                    switch (notificationCode)
                    {
                    case (int)Wlan.WlanNotificationCodeAcm.ConnectionStart:

                        Console.WriteLine("开始连接无线网络.......");
                        break;

                    case (int)Wlan.WlanNotificationCodeAcm.ConnectionComplete:

                        break;

                    case (int)Wlan.WlanNotificationCodeAcm.Disconnecting:

                        Console.WriteLine("正在断开无线网络连接.......");
                        break;

                    case (int)Wlan.WlanNotificationCodeAcm.Disconnected:
                        Console.WriteLine("已经断开无线网络连接.......");
                        break;
                    }
                }
                //}));
            }
            catch (Exception e)
            {
                //Loger.WriteLog(e.Message);
            }
        }
Esempio n. 9
0
 static void wlanIface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
 {
     Snarl.SnarlConnector.ShowMessageEx("WiFi disconnected", "Disconnect from WiFi", connNotifyData.profileName, 10, executablePath + wirelessDisconnect, SnarlMsgWndHandle, Snarl.WindowsMessage.WM_USER + 34, "");
     Console.WriteLine(notifyData.NotificationCode);
     //Console.WriteLine("{0} to {1} with quality level {2}",connNotifyData.wlanConnectionMode, connNotifyData.profileName, "-");
 }
Esempio n. 10
0
 private void UsableInterface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
 {
 }
Esempio n. 11
0
 private void WlanInterface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
 {
     WlanConnectionNotification?.Invoke(notifyData, connNotifyData);
 }
        private void m_Interface_WlanConnectionNotification(Wlan.WlanNotificationData i_NotifyData, Wlan.WlanConnectionNotificationData i_ConnNotifyData)
        {
            Debug.log($"Connection status changed to {i_NotifyData.NotificationCode.ToString()}");

            //string[] goodNotificationCodes = { "ConnectionStart", "Associating", "Associated", "Authenticating", "Connected", "ConnectionComplete", "RoamingStart" };
            m_Interface.WlanConnectionNotification -= m_Interface_WlanConnectionNotification;
            if (!checkInternetConnectivity() /*!goodNotificationCodes.Any((i_NotifyData.NotificationCode.ToString()).Contains)*/) // i.e disconnected
            {
                connect(i_ConnNotifyData.profileName);
            }

            m_Interface.WlanConnectionNotification += m_Interface_WlanConnectionNotification;
        }
Esempio n. 13
0
 void WlanIface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
 {
     this.notifyData     = notifyData;
     this.connNotifyData = connNotifyData;
     if (notifyData.notificationSource == NativeWifi.Wlan.WlanNotificationSource.ACM)
     {
         //连接失败
         if ((NativeWifi.Wlan.WlanNotificationCodeAcm)notifyData.NotificationCode == NativeWifi.Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail)
         {
             WlanIface.DeleteProfile(connNotifyData.profileName);
         }
     }
 }
        /// <summary>
        /// Se gatilla para recibir notificaciones de conexión a la red inalambrica (Windows XP, SP3)
        /// Si ocurre un error se informa en informationNetworkingHandler
        /// </summary>
        /// <param name="notifyData">Los datos de notificación</param>
        /// <param name="connNotifyData">Los datos de conección</param>
        private void WlanConnectionAction(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
        {
            lock (syncPoint)
            {
                try
                {
                    if ((notifyData.notificationSource.Equals(Wlan.WlanNotificationSource.ACM) &&
                         notifyData.NotificationCode.Equals(Wlan.WlanNotificationCodeAcm.ConnectionComplete)) ||
                        (notifyData.notificationSource.Equals(Wlan.WlanNotificationSource.MSM) &&
                         notifyData.notificationCode.Equals(Wlan.WlanNotificationCodeMsm.Connected)))
                    {
                        if (connNotifyData.profileName == netData.AdhocNetworkName + "-adhoc")
                        {
                            if (netData.OpSystem.Equals(OpSystemType.WINXPSP3))
                            {
                                wifiInformation("connection");
                                switch (connectionState)
                                {
                                case WifiConnectionState.CONNECTED:
                                {
                                    break;
                                }

                                case WifiConnectionState.DISCONNECTED:
                                {
                                    connectionState = WifiConnectionState.CONNECTED;
                                    break;
                                }
                                }
                            }
                        }
                        else
                        {
                            wifiInformation("unknown connection (" + connNotifyData.profileName + ")");
                            connectionState = WifiConnectionState.DISCONNECTED;
                            closeWLanConnection();
                            openWLanConnection();
                        }
                    }
                    else if ((notifyData.notificationSource.Equals(Wlan.WlanNotificationSource.ACM) &&
                              notifyData.NotificationCode.Equals(Wlan.WlanNotificationCodeAcm.Disconnected)) ||
                             (notifyData.notificationSource.Equals(Wlan.WlanNotificationSource.MSM) &&
                              notifyData.notificationCode.Equals(Wlan.WlanNotificationCodeMsm.Disconnected)))
                    {
                        if (netData.OpSystem.Equals(OpSystemType.WINXPSP3))
                        {
                            wifiInformation("disconnection");
                            switch (connectionState)
                            {
                            case WifiConnectionState.CONNECTED:
                            {
                                connectionState = WifiConnectionState.DISCONNECTED;
                                break;
                            }

                            case WifiConnectionState.DISCONNECTED:
                            {
                                break;
                            }
                            }
                        }
                        else if (netData.OpSystem.Equals(OpSystemType.WIN7))
                        {
                            wifiInformation("disconenction");
                            switch (connectionState)
                            {
                            case WifiConnectionState.CONNECTED:
                            {
                                connectionState = WifiConnectionState.DISCONNECTED;
                                break;
                            }

                            case WifiConnectionState.DISCONNECTED:
                            {
                                break;
                            }

                            case WifiConnectionState.WAINTING:
                            {
                                connectionState = WifiConnectionState.DISCONNECTED;
                                break;
                            }
                            }
                        }
                    }
                }
                catch (ThreadAbortException e)
                {
                    throw e;
                }
                catch (Exception e)
                {
                    wifiInformation("error " + e.Message);
                }
            }
        }
Esempio n. 15
0
        //private void WlanInterface_WlanReasonNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanReasonCode reasonCode)
        //{

        //    Console.WriteLine(notifyData.NotificationCode);
        //    Console.WriteLine(reasonCode.ToString());

        //}

        private void WlanIface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
        {
            //Console.WriteLine(notifyData.NotificationCode);
            //Console.WriteLine(notifyData.notificationSource);

            //if (notifyData.dataSize >= 0)
            //{
            //    Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr);
            //    if (wlanIface != null)
            //        wlanIface.OnWlanReason(notifyData, reasonCode);
            //}
            try
            {
                if (notifyData.dataSize >= 0)
                {
                    //Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr);
                    //if (wlanInterface != null)
                    //    wlanInterface.OnWlanReason(notifyData, reasonCode);

                    if (notifyData.notificationSource == Wlan.WlanNotificationSource.ACM)
                    {
                        int notificationCode = (int)notifyData.NotificationCode;
                        switch (notificationCode)
                        {
                        case (int)Wlan.WlanNotificationCodeAcm.ConnectionStart:

                            Console.WriteLine("开始连接无线网络.......");
                            break;

                        case (int)Wlan.WlanNotificationCodeAcm.ConnectionComplete:

                            break;

                        case (int)Wlan.WlanNotificationCodeAcm.Disconnecting:

                            Console.WriteLine("正在断开无线网络连接.......");
                            break;

                        case (int)Wlan.WlanNotificationCodeAcm.Disconnected:
                            Console.WriteLine("已经断开无线网络连接.......");
                            break;
                        }
                    }
                }
                //}));
            }
            catch (Exception e)
            {
                throw new BaseException(string.Format("WlanConnectionNotification事件出错" + e.ToString()));
                //Loger.WriteLog(e.Message);
            }

            //throw new NotImplementedException();
        }
 void SelectedInterface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
 {
     SelectedInterface.RefreshConnected();
 }
 void SelectedInterface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
 {
     if (owner != null && owner.IsVisible)
     {
         SelectedInterface?.UpdateInformation();
         UpdateNetworkSignalQuality();
     }
 }
Esempio n. 18
0
        private void iface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
        {
            WlanClient.WlanInterface iface = GetInterfaceByGuid(notifyData.interfaceGuid);
            if (iface == null)
            {
                Logging.Info("IVPN Network Status: no interface for GUID: " + notifyData.interfaceGuid);
                return;
            }

            try
            {
                WiFiStateChanged(CurrentState);

                Logging.Info(string.Format("IVPN Network Status Changed: interface {0} ({1}, cipher: {2}, state: {3})",
                                           iface.InterfaceName,
                                           IsInsecureCipherAlgorithm(iface.CurrentConnection.wlanSecurityAttributes.dot11CipherAlgorithm) ? "not secure" : "secure",
                                           iface.CurrentConnection.wlanSecurityAttributes.dot11CipherAlgorithm,
                                           iface.InterfaceState));
            }
            catch (Win32Exception ex)
            {
                Logging.Info(string.Format("IVPN Network Status exception while notifying: {0}", ex));
            }
        }
Esempio n. 19
0
 void WlanIface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
 {
     if (notifyData.notificationSource == NativeWifi.Wlan.WlanNotificationSource.MSM)
     {
         //这里是完成连接
         if ((NativeWifi.Wlan.WlanNotificationCodeMsm)notifyData.NotificationCode == NativeWifi.Wlan.WlanNotificationCodeMsm.Connected)
         {
             Invoke(new Action(() =>
             {
                 label2.Text = connNotifyData.profileName;
             }));
         }
     }
     else if (notifyData.notificationSource == NativeWifi.Wlan.WlanNotificationSource.ACM)
     {
         //连接失败
         if ((NativeWifi.Wlan.WlanNotificationCodeAcm)notifyData.NotificationCode == NativeWifi.Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail)
         {
             Invoke(new Action(() =>
             {
                 label2.Text = "未连接";
             }));
             MessageBox.Show("连接失败,请检查密码是否正确");
             WlanIface.DeleteProfile(connNotifyData.profileName);
         }
         if ((NativeWifi.Wlan.WlanNotificationCodeAcm)notifyData.NotificationCode == NativeWifi.Wlan.WlanNotificationCodeAcm.Disconnected)
         {
             Invoke(new Action(() =>
             {
                 label2.Text = "未连接";
             }));
         }
         if ((NativeWifi.Wlan.WlanNotificationCodeAcm)notifyData.NotificationCode == NativeWifi.Wlan.WlanNotificationCodeAcm.Disconnecting)
         {
             Invoke(new Action(() =>
             {
                 label2.Text = "未连接";
             }));
         }
         if ((NativeWifi.Wlan.WlanNotificationCodeAcm)notifyData.NotificationCode == NativeWifi.Wlan.WlanNotificationCodeAcm.ConnectionStart)
         {
             Invoke(new Action(() =>
             {
                 label2.Text = "连接中…";
             }));
         }
     }
 }
Esempio n. 20
0
 private static void WlanIface_WlanConnectionNotification(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
 {
 }