Exemple #1
0
		private static WlanInternBssEntry[] GetBssList(Nic nic, out int errorCode)
		{
			IntPtr bssListPtr;
			if ((errorCode = WlanInterop.GetBssEntryList(_handle, nic.Hardware.Id, IntPtr.Zero, BssType.Any, false, IntPtr.Zero, out bssListPtr)) != 0)
				return new WlanInternBssEntry[0];
			try
			{
				var bssListHeader = (WlanInternBssEntryListHeader) Marshal.PtrToStructure(bssListPtr, typeof (WlanInternBssEntryListHeader));
				long bssListIt = bssListPtr.ToInt64() + Marshal.SizeOf(typeof (WlanInternBssEntryListHeader));
				var bssEntries = new WlanInternBssEntry[bssListHeader.numberOfItems];
				for (int i = 0; i < bssListHeader.numberOfItems; ++i)
				{
					bssEntries[i] = (WlanInternBssEntry) Marshal.PtrToStructure(new IntPtr(bssListIt), typeof (WlanInternBssEntry));
					bssListIt += Marshal.SizeOf(typeof (WlanInternBssEntry));
				}
				errorCode = 0;
				return bssEntries;
			}
			finally
			{
				WlanInterop.FreeMemory(bssListPtr);
			}
		}
Exemple #2
0
		internal void Reload(WlanInternBssEntry bss)
		{
			Ssid = bss.Dot11Ssid.GetSsid();
			Mac = bss.GetMacAddress();
			Type = bss.dot11BssType;
			PhyType = bss.dot11BssPhyType;
			Rssi = bss.rssi;
			LinkQuality = bss.linkQuality;
			InRegDomain = bss.inRegDomain;
			BeaconPeriod = bss.beaconPeriod;
			Timestamp = bss.timestamp;
			HostTimestamp = bss.hostTimestamp;
			CapabilityInformation = bss.capabilityInformation;
			ChannelCenterFrequency = bss.chCenterFrequency;
			Rates = bss.wlanRateSet.GetRatesInMbps();

			byte ch;
			Channel = ChannelTable.TryGetValue(ChannelCenterFrequency, out ch) ? ch : (byte) 0;

			if (LinkHost == null || LinkHost.Mac != Mac)
				LinkHost = NetDb.LinkLayerHost.GetOrCreate(Mac);
			LinkHost.ApplyName(NsProtocolTypes.Wlan, Ssid);
			LinkHost.Seen();
		}
Exemple #3
0
		internal Bss(Ssid owner, WlanInternBssEntry bss)
		{
			_owner = owner;
			Reload(bss);
		}
Exemple #4
0
		internal void ReloadBssList(WlanInternBssEntry[] lst)
		{
			if (lst == null || lst.Length == 0)
			{
				_bsses.Clear();
				return;
			}
			var itemsToDelete = _bsses.ToList();

			for (int i = 0; i < lst.Length; i++)
			{
				var newBss = lst[i];
				string mac = newBss.GetMacAddress();
				var item = itemsToDelete.FirstOrDefault(x => x.Mac == mac);
				if (item == null)
				{
					item = new Bss(this, newBss);
					_bsses.Add(item);
				}
				else
				{
					item.Reload(newBss);
					itemsToDelete.Remove(item);
				}
				var oldIndex = _bsses.IndexOf(item);
				_bsses.Move(oldIndex, i);
			}

			foreach (var item in itemsToDelete)
			{
				_bsses.Remove(item);
			}
		}