Exemplo n.º 1
0
        private IEnumerable <NetworkData> GetNetworkData()
        {
            List <NetworkData> list = new List <NetworkData>();
            IEnumerable <Wlan.WlanBssEntryN>        networkBssList       = MyWlanInterface.GetNetworkBssList();
            IEnumerable <Wlan.WlanAvailableNetwork> availableNetworkList =
                MyWlanInterface.GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags.IncludeAllManualHiddenProfiles);

            if ((networkBssList != null) && (availableNetworkList != null))
            {
                Wlan.WlanAvailableNetwork foundNetwork = new Wlan.WlanAvailableNetwork();
                foreach (Wlan.WlanBssEntryN entry in networkBssList)
                {
                    string ssid = Encoding.ASCII.GetString(entry.BaseEntry.dot11Ssid.SSID, 0,
                                                           (int)entry.BaseEntry.dot11Ssid.SSIDLength);
                    if (FindNetwork(ssid, availableNetworkList, ref foundNetwork))
                    {
                        NetworkData item = new NetworkData(entry.BaseEntry.dot11Bssid);

                        Utilities.ConvertToMbs(entry.BaseEntry.wlanRateSet.Rates, item.Rates);
                        if (entry.NSettings != null)
                        {
                            item.NSettings = new IeParser.TypeNSettings(entry.NSettings);

                            //Add the extended 802.11N rates
                            item.Rates.AddRange(item.NSettings.Rates.Where(f => !item.Rates.Contains(f)));
                            item.Rates.Sort();
                        }

                        item.IsTypeN = entry.BaseEntry.dot11BssPhyType == Wlan.Dot11PhyType.Ht;
                        int num = Utilities.ComputeRssi(entry.BaseEntry.linkQuality);
                        item.Rssi        = (entry.BaseEntry.rssi > num) ? entry.BaseEntry.rssi : num;
                        item.Ssid        = ssid;
                        item.Channel     = Utilities.ConvertToChannel(entry.BaseEntry.chCenterFrequency);
                        item.NetworkType = Utilities.ConvertToString(entry.BaseEntry.dot11BssType);
                        item.Privacy     = Utilities.CreatePrivacyString(foundNetwork.dot11DefaultAuthAlgorithm,
                                                                         foundNetwork.dot11DefaultCipherAlgorithm);
                        item.SignalQuality = foundNetwork.wlanSignalQuality;
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Exemplo n.º 2
0
 private void ScanNetworks()
 {
     MyWlanInterface.Scan();
 }