1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
// License: BSD/LGPL
// Copyright (C) 2011-2018 Thomas d'Otreppe
using System;
using System.Collections.Generic;
using System.Text;
namespace WirelessPanda
{
public class Station : WirelessDevice, IEquatable<Station>
{
private AccessPoint _ap = null;
/// <summary>
/// Access point
/// </summary>
public AccessPoint AP
{
get
{
return this._ap;
}
// Only allow to do it inside the lib
internal set
{
this._ap = value;
}
}
/// <summary>
/// Station MAC
/// </summary>
public string StationMAC
{
get
{
return (string)this.getDictValue("Station MAC");
}
set
{
if (value != null)
{
this.setDictValue("Station MAC", value.Trim());
}
else
{
this.setDictValue("Station MAC", value);
}
}
}
/// <summary>
/// # Packets
/// </summary>
public ulong NbPackets
{
get
{
return (ulong)this.getDictValue("# Packets");
}
set
{
this.setDictValue("# Packets", value);
}
}
/// <summary>
/// Probed ESSIDs (comma separated)
/// </summary>
public string ProbedESSIDs
{
get
{
return (string)this.getDictValue("Probed ESSIDs");
}
set
{
this.setDictValue("Probed ESSIDs", value);
// Update probe ESSID list
this._probedESSIDsList.Clear();
if (string.IsNullOrEmpty(value))
{
foreach (string s in value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{
if (string.IsNullOrEmpty(s.Trim()))
{
continue;
}
// Add ESSID
this._probedESSIDsList.Add(s);
}
}
}
}
private List<string> _probedESSIDsList = new List<string>();
/// <summary>
/// Probed ESSIDs List
/// </summary>
public string[] ProbedESSIDsList
{
get
{
return _probedESSIDsList.ToArray().Clone() as string[];
}
set
{
this._probedESSIDsList.Clear();
this.setDictValue("Probed ESSIDs", string.Empty);
if (value != null && value.Length > 0)
{
this._probedESSIDsList.AddRange(value);
// Generate the string list of SSID
StringBuilder sb = new StringBuilder(string.Empty);
foreach (string s in value)
{
sb.AppendFormat("{0}, ", s);
}
string res = sb.ToString();
if (res.Length > 0)
{
res = res.Substring(0, res.Length - 2);
}
// And put it in the Probed ESSIDs dictionary item
this.setDictValue("Probed ESSIDs", res);
}
}
}
/// <summary>
/// Implements IEquatable
/// </summary>
/// <param name="other">Other Station to compare to</param>
/// <returns>true if equals, false if not</returns>
public bool Equals(Station other)
{
try
{
if (this.StationMAC == other.StationMAC)
{
return true;
}
}
catch { }
return false;
}
}
}
|