當前位置: 首頁>>代碼示例>>C#>>正文


C# NativeWifi.Wlan類代碼示例

本文整理匯總了C#中NativeWifi.Wlan的典型用法代碼示例。如果您正苦於以下問題:C# Wlan類的具體用法?C# Wlan怎麽用?C# Wlan使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Wlan類屬於NativeWifi命名空間,在下文中一共展示了Wlan類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: IsSentByCorrectNetworkInterface

        private bool IsSentByCorrectNetworkInterface(Wlan.WlanNotificationData notificationData)
        {
            WlanClient.WlanInterface wifiInterface = GetInterfaceByInterfaceId(notificationData.interfaceGuid);
            if (wifiInterface == currentWifiInterface)
                return true;

            return false;
        }
開發者ID:RogBear,項目名稱:ARDrone-Control-.NET,代碼行數:8,代碼來源:NetworkConnector.cs

示例2: GetStringForSSID

 static string GetStringForSSID(Wlan.Dot11Ssid ssid)
 {
     return Encoding.ASCII.GetString(ssid.SSID, 0, (int)ssid.SSIDLength);
 }
開發者ID:cboseak,項目名稱:GUI,代碼行數:4,代碼來源:WiFi.cs

示例3: OnWlanNotification

        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.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:
                            {
                                //HACK: Prevents exception on WLAN connection: System.ArgumentException: Type 'NativeWifi.Wlan+WlanReasonCode' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
                                int expectedSize = 0;//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);
                                }
                            }
                            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);
        }
開發者ID:maurodx,項目名稱:netprofilesmod,代碼行數:59,代碼來源:WlanApi.cs

示例4: WlanEventHandler

        public void WlanEventHandler(Wlan.WlanNotificationData eventData)
        {
            switch (eventData.notificationSource)
            {
                case Wlan.WlanNotificationSource.ACM:
                    switch ((Wlan.WlanNotificationCodeAcm)eventData.notificationCode)
                    {
                        case Wlan.WlanNotificationCodeAcm.ConnectionAttemptFail:
                            log.Debug("ConnectionAttemptFail");
                            break;
                        case Wlan.WlanNotificationCodeAcm.ConnectionComplete:
                            log.Debug("ConnectionComplete");
                            break;
                        case Wlan.WlanNotificationCodeAcm.ConnectionStart:
                            state = WiFiState.Connecting;
                            updaterNetStatus.Update();
                            log.Debug("ConnectionStart");
                            break;
                        case Wlan.WlanNotificationCodeAcm.Disconnected:
                            state = WiFiState.Disconnected;
                            updaterNetStatus.Update();
                            log.Debug("ACM.Disconnected");
                            break;
                        case Wlan.WlanNotificationCodeAcm.Disconnecting:
                            state = WiFiState.Disconnecting;
                            updaterNetStatus.Update();
                            log.Debug("Disconnecting");
                            break;
                        case Wlan.WlanNotificationCodeAcm.InterfaceRemoval:
                            state = WiFiState.NoWirelessInterface;
                            updaterNetStatus.Update();
                            log.Debug("InterfaceRemoval");
                            break;

                    }
                    break;
                case Wlan.WlanNotificationSource.MSM:
                    switch ((Wlan.WlanNotificationCodeMsm)eventData.notificationCode)
                    {
                        case Wlan.WlanNotificationCodeMsm.AdapterOperationModeChange:
                            log.Debug("AdapterOperationModeChange");
                            break;
                        case Wlan.WlanNotificationCodeMsm.AdapterRemoval:
                           state = WiFiState.NoWirelessInterface;
                            updaterNetStatus.Update();
                            log.Debug("AdapterRemoval");
                            break;
                        case Wlan.WlanNotificationCodeMsm.SignalQualityChange:
                            log.Debug("SignalQualityChange");
                            break;
                        case Wlan.WlanNotificationCodeMsm.Associated:
                            log.Debug("Associated");
                            break;
                        case Wlan.WlanNotificationCodeMsm.Associating:
                            log.Debug("Associating");
                            break;
                        case Wlan.WlanNotificationCodeMsm.Authenticating:
                            log.Debug("Authenticating");
                            break;
                        case Wlan.WlanNotificationCodeMsm.Connected:
                            state = WiFiState.Connected;
                            updaterNetStatus.Update();
                            log.Debug("MSM.Connected");
                            break;
                        case Wlan.WlanNotificationCodeMsm.Disassociating:
                            log.Debug("Disassociating");
                            break;
                        case Wlan.WlanNotificationCodeMsm.Disconnected:
                            state = WiFiState.Disconnected;
                            updaterNetStatus.Update();
                            log.Debug("MSM.Disconnected");
                            break;
                    }
                    break;
            }
        }
開發者ID:geexmmo,項目名稱:SmartConnect,代碼行數:76,代碼來源:WiFiConnect.cs

示例5: Connect

 /// <summary>
 /// Requests a connection (association) to the specified wireless network.
 /// </summary>
 /// <remarks>
 /// The method returns immediately. Progress is reported through the <see cref="WlanNotification"/> event.
 /// </remarks>
 public void Connect(Wlan.WlanConnectionMode connectionMode, Wlan.Dot11BssType bssType, string profile)
 {
     Wlan.WlanConnectionParameters connectionParams = new Wlan.WlanConnectionParameters();
     connectionParams.wlanConnectionMode = connectionMode;
     connectionParams.profile = profile;
     connectionParams.dot11BssType = bssType;
     connectionParams.flags = 0;
     Connect(connectionParams);
 }
開發者ID:StabilityofWT,項目名稱:MoSoWT,代碼行數:15,代碼來源:WlanApi.cs

示例6: GetProfileXml

    /// <summary>
    /// Create a valid Profile xml according to: http://msdn.microsoft.com/en-us/library/ms707381(v=VS.85).aspx
    /// </summary>
    /// <param name="ssid"></param>
    /// <param name="key"></param>
    /// <param name="authAlg"></param>
    /// <param name="encAlg"></param>
    /// <returns></returns>
    internal static string GetProfileXml(string ssid, string key, Wlan.Dot11AuthAlgorithm authAlg, Wlan.Dot11CipherAlgorithm encAlg)
    {
      WinProfileAuthenticationEnumeration? auth = null;
      WinProfileEncryptionEnumeration? enc = null;
      switch (authAlg)
      {
        case Wlan.Dot11AuthAlgorithm.IEEE80211_SharedKey:
          auth = WinProfileAuthenticationEnumeration.open;
          enc = WinProfileEncryptionEnumeration.WEP;
          break;
        case Wlan.Dot11AuthAlgorithm.WPA_PSK:
          auth = WinProfileAuthenticationEnumeration.WPAPSK;
          break;
        case Wlan.Dot11AuthAlgorithm.RSNA_PSK:
          auth = WinProfileAuthenticationEnumeration.WPA2PSK;
          break;
      }
      switch (encAlg)
      {
        case Wlan.Dot11CipherAlgorithm.TKIP:
          enc = WinProfileEncryptionEnumeration.TKIP;
          break;
        case Wlan.Dot11CipherAlgorithm.CCMP:
          enc = WinProfileEncryptionEnumeration.AES;
          break;
      }

      if (enc != null && auth != null)
      {
        return string.Format(@"<?xml version=""1.0""?>
<WLANProfile xmlns=""http://www.microsoft.com/networking/WLAN/profile/v1"">
	<name>{0}</name>
	<SSIDConfig>
		<SSID>
			<name>{0}</name>
		</SSID>
	</SSIDConfig>
	<connectionType>ESS</connectionType>
	<connectionMode>auto</connectionMode>
	<MSM>
		<security>
			<authEncryption>
				<authentication>{2}</authentication>
				<encryption>{3}</encryption>
				<useOneX>false</useOneX>
			</authEncryption>
			<sharedKey>
				<keyType>passPhrase</keyType>
				<protected>false</protected>
				<keyMaterial>{1}</keyMaterial>
			</sharedKey>
		</security>
	</MSM>
</WLANProfile>", ssid, key, auth.ToString(), enc.ToString());
      }
      else
      {
        return null;
      }
    }
開發者ID:davinx,項目名稱:MediaPortal-2,代碼行數:68,代碼來源:Helper.cs

示例7: HandleLinkDown

        public static void HandleLinkDown(Wlan.WlanNotificationData notifyData)
        {
            NativeWifi.WlanClient.WlanInterface wlanIface = null;// = GenericInfo.WlanInterface;
            foreach (NativeWifi.WlanClient.WlanInterface wli in Information.GenericInfo.ClientInstance.Interfaces)
                if (wli.InterfaceGuid == notifyData.interfaceGuid)
                    if (wli.NetworkInterface.GetPhysicalAddress().Equals(PhysicalAddress.Parse(Program.MAC.Replace(":", "-").ToUpper()))) //Event filtering
                        wlanIface = wli;

            if (wlanIface != null)
            {
                ConnectionHelper ch = Program.toMihf;
                ID myLinkID = new ID(new OctetString(GenericInfo.myID));
                ID mihfID = new ID(new OctetString(GenericInfo.mihfID));

                if (Subscriptions.List.Link_Down)
                    ch.Send(MessageBuilders.Link_Down_Indication_802_11_MsgBuilder(myLinkID, mihfID,
                        new String(Encoding.ASCII.GetChars(wlanIface.LatestConnection.wlanAssociationAttributes.dot11Ssid.SSID)),
                        wlanIface.LatestConnection.wlanAssociationAttributes.Dot11Bssid,
                        Link_Dn_Reason.ExplicitDisconnect).ByteValue);//TODO get reasons
            }
        }
開發者ID:ATNoG,項目名稱:ODTONE,代碼行數:21,代碼來源:EventHandler.cs

示例8: GetStringForReasonCode

 /// <summary>
 /// Gets a string that describes a specified reason code.
 /// </summary>
 /// <param name="reasonCode">The reason code.</param>
 /// <returns>The string.</returns>
 public string GetStringForReasonCode(Wlan.WlanReasonCode reasonCode)
 {
     StringBuilder sb = new StringBuilder(1024); // the 1024 size here is arbitrary; the WlanReasonCodeToString docs fail to specify a recommended size
     Wlan.ThrowIfError(
         Wlan.WlanReasonCodeToString(reasonCode, sb.Capacity, sb, IntPtr.Zero));
     return sb.ToString();
 }
開發者ID:StabilityofWT,項目名稱:MoSoWT,代碼行數:12,代碼來源:WlanApi.cs

示例9: OnWlanNotification

        private void OnWlanNotification(ref Wlan.WlanNotificationData notifyData, IntPtr context)
        {
            WlanInterface wlanIface;
            ifaces.TryGetValue(notifyData.interfaceGuid, out wlanIface);

            switch (notifyData.notificationSource)
            {
                case Wlan.WlanNotificationSource.ACM:
                    switch ((Wlan.WlanNotificationCodeAcm)notifyData.notificationCode)
                    {
                        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:
                            {
                                int expectedSize = Marshal.SizeOf(typeof(int));
                                if (notifyData.dataSize >= expectedSize)
                                {
                                    Wlan.WlanReasonCode reasonCode = (Wlan.WlanReasonCode)Marshal.ReadInt32(notifyData.dataPtr);
                                    if (wlanIface != null)
                                        wlanIface.OnWlanReason(notifyData, reasonCode);
                                }
                            }
                            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);
        }
開發者ID:StabilityofWT,項目名稱:MoSoWT,代碼行數:59,代碼來源:WlanApi.cs

示例10: OnWlanConnection

            internal void OnWlanConnection(Wlan.WlanNotificationData notifyData, Wlan.WlanConnectionNotificationData connNotifyData)
            {
                if (WlanConnectionNotification != null)
                    WlanConnectionNotification(notifyData, connNotifyData);

                if (queueEvents)
                {
                    WlanConnectionNotificationEventData queuedEvent = new WlanConnectionNotificationEventData();
                    queuedEvent.notifyData = notifyData;
                    queuedEvent.connNotifyData = connNotifyData;
                    EnqueueEvent(queuedEvent);
                }
            }
開發者ID:StabilityofWT,項目名稱:MoSoWT,代碼行數:13,代碼來源:WlanApi.cs

示例11: ProcessWifiNotificatioEvent

        private void ProcessWifiNotificatioEvent(Wlan.WlanNotificationData notificationData)
        {
            if (currentState != DroneNetworkConnectionState.ScanningForNewNetworks)
                return;
            if (!IsSentByCorrectNetworkInterface(notificationData))
                return;

            if (notificationData.notificationCode == notificationCodeScanSuccessful)
            {
                DiscoverNetwork();
            }
            else if (notificationData.notificationCode == notificationCodeScanErroneous)
            {
                ScanCurrentNetworkInterface();
            }
        }
開發者ID:RogBear,項目名稱:ARDrone-Control-.NET,代碼行數:16,代碼來源:NetworkConnector.cs

示例12: GetNetworkBssList

 /// <summary>
 /// Retrieves the basic service sets (BSS) list of the specified network.
 /// </summary>
 /// <param name="ssid">Specifies the SSID of the network from which the BSS list is requested.</param>
 /// <param name="bssType">Indicates the BSS type of the network.</param>
 /// <param name="securityEnabled">Indicates whether security is enabled on the network.</param>
 public Wlan.WlanBssEntry[] GetNetworkBssList(Wlan.Dot11Ssid ssid, Wlan.Dot11BssType bssType, bool securityEnabled)
 {
     IntPtr ssidPtr = Marshal.AllocHGlobal(Marshal.SizeOf(ssid));
     Marshal.StructureToPtr(ssid, ssidPtr, false);
     try
     {
         IntPtr bssListPtr;
         Wlan.ThrowIfError(
             Wlan.WlanGetNetworkBssList(client.clientHandle, info.interfaceGuid, ssidPtr, bssType, securityEnabled, IntPtr.Zero, out bssListPtr));
         try
         {
             return ConvertBssListPtr(bssListPtr);
         }
         finally
         {
             Wlan.WlanFreeMemory(bssListPtr);
         }
     }
     finally
     {
         Marshal.FreeHGlobal(ssidPtr);
     }
 }
開發者ID:StabilityofWT,項目名稱:MoSoWT,代碼行數:29,代碼來源:WlanApi.cs

示例13: ConnectSynchronously

 /// <summary>
 /// Connects (associates) to the specified wireless network, returning either on a success to connect
 /// or a failure.
 /// </summary>
 /// <param name="connectionMode"></param>
 /// <param name="bssType"></param>
 /// <param name="profile"></param>
 /// <param name="connectTimeout"></param>
 /// <returns></returns>
 public bool ConnectSynchronously(Wlan.WlanConnectionMode connectionMode, Wlan.Dot11BssType bssType, string profile, int connectTimeout)
 {
     queueEvents = true;
     try
     {
         Connect(connectionMode, bssType, profile);
         while (queueEvents && eventQueueFilled.WaitOne(connectTimeout, true))
         {
             lock (eventQueue)
             {
                 while (eventQueue.Count != 0)
                 {
                     object e = eventQueue.Dequeue();
                     if (e is WlanConnectionNotificationEventData)
                     {
                         WlanConnectionNotificationEventData wlanConnectionData = (WlanConnectionNotificationEventData)e;
                         // Check if the conditions are good to indicate either success or failure.
                         if (wlanConnectionData.notifyData.notificationSource == Wlan.WlanNotificationSource.ACM)
                         {
                             switch ((Wlan.WlanNotificationCodeAcm)wlanConnectionData.notifyData.notificationCode)
                             {
                                 case Wlan.WlanNotificationCodeAcm.ConnectionComplete:
                                     if (wlanConnectionData.connNotifyData.profileName == profile)
                                         return true;
                                     break;
                             }
                         }
                         break;
                     }
                 }
             }
         }
     }
     finally
     {
         queueEvents = false;
         eventQueue.Clear();
     }
     return false; // timeout expired and no "connection complete"
 }
開發者ID:StabilityofWT,項目名稱:MoSoWT,代碼行數:49,代碼來源:WlanApi.cs

示例14: frmConnectWifiAdaptor_WlanNotification

        void frmConnectWifiAdaptor_WlanNotification(Wlan.WlanNotificationData notifyData)
        {
            System.Diagnostics.Debug.WriteLine(notifyData.NotificationCode);
            int x = Convert.ToInt32(notifyData.NotificationCode);
            if (x == 7)
            {

            }    
        }
開發者ID:antonesterhuyse,項目名稱:GrucoxScrumView,代碼行數:9,代碼來源:frmConnectWifiAdaptor.cs

示例15: Network

 public Network(Wlan.WlanAvailableNetwork network)
 {
     profileName = network.profileName;
     dot11Ssid = Encoding.ASCII.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength);
     dot11BssType = network.dot11BssType.ToString();
     wlanNotConnectableReason = network.wlanNotConnectableReason.ToString();
     defaultAuthAlgorithm= network.dot11DefaultAuthAlgorithm.ToString();
     defaultCipherAlgo= network.dot11DefaultCipherAlgorithm.ToString();
     numberOfBssids = network.numberOfBssids;
     //numberOfPhyTypes = network.Dot11PhyTypes.GetLength(network);
     wlanSignalQuality = network.wlanSignalQuality;
     securityEnabled = network.securityEnabled;
     isConnectable = network.networkConnectable;
 }
開發者ID:sailee,項目名稱:EnergyHub,代碼行數:14,代碼來源:Network.cs


注:本文中的NativeWifi.Wlan類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。