コード例 #1
0
ファイル: WlanProtocol.cs プロジェクト: cssack/CsGlobals
		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);
			}
		}
コード例 #2
0
ファイル: Bss.cs プロジェクト: cssack/CsGlobals
		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();
		}
コード例 #3
0
ファイル: Bss.cs プロジェクト: cssack/CsGlobals
		internal Bss(Ssid owner, WlanInternBssEntry bss)
		{
			_owner = owner;
			Reload(bss);
		}
コード例 #4
0
ファイル: Ssid.cs プロジェクト: cssack/CsGlobals
		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);
			}
		}