HardwareWLANInterface.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Ext_NetEmu_WLAN_HardwareWLANInterface_
18 #define HH_SENF_Ext_NetEmu_WLAN_HardwareWLANInterface_ 1
19 
20 // Custom includes
22 #include <senf/Utils/Logger/Log.hh>
23 #include "WLANInterface.hh"
24 #include "WirelessNLController.hh"
25 #include "AthSpectralScan.hh"
26 #include "WifiStatistics.hh"
27 
28 #include "HardwareWLANInterface.ih"
29 
30 //-/////////////////////////////////////////////////////////////////////////////////////////////////
31 
32 namespace senf {
33 namespace emu {
34 
43  : private detail::HardwareWLANInterfaceNet,
44  public WLANInterface,
45  public HardwareInterface
46  {
48 
49  public:
52 
53  explicit HardwareWLANInterface(std::pair<std::string,std::string> interfaces);
54 
55  virtual ~HardwareWLANInterface();
56 
57  std::string const & v_device() const override;
59  std::string const & monitorDevice() const;
61 
62  void setREDFilterCallbackRx(senf::ppi::REDFilterCallback const & cb);
63  void setREDFilterCallbackTx(senf::ppi::REDFilterCallback const & cb);
64  void setREDFilterCallbackRxMonitor(senf::ppi::REDFilterCallback const & cb);
65 
67  void monitorDropUnknownMCS(bool q);
68 
69  WirelessNLController::IbssJoinParameters::ptrI joinAdhoc(std::string const & ssid, unsigned int freq, unsigned int bandwidth, bool & success);
70  WirelessNLController::MeshJoinParameters::ptrM joinMesh(std::string const & meshId, unsigned int freq, unsigned int bandwidth, bool & success);
71  void leaveCell();
72  bool cellJoined() const;
73  void setCellJoined(unsigned bandwidth); // bw==0 => cell left (close data socket)
74 
75  int frequencyOffset() const;
76  void frequencyOffset(int offset);
77 
79  void restrictBand();
80 
81  void refreshProperties();
82 
83  struct HTMode {
85  };
86  void htMode(HTMode::Enum mode);
87  HTMode::Enum htMode() const;
88 
89  unsigned sndBuf();
90  void sndBuf(unsigned sndbuf);
91  unsigned rcvBuf();
92  void rcvBuf(unsigned rcvbuf);
93 
94  // Changing these parameters while the interface is enabled
95  // will temporarily disable the interface !!
96 
97  unsigned qlen() const;
98  void qlen(unsigned qlen);
99 
100  std::pair<unsigned,unsigned> rxDropped();
101  std::tuple<unsigned,unsigned,unsigned> txDropped();
102 
103  unsigned maxBurst() const;
104  void maxBurst(unsigned maxBurst);
105 
106  VLanId const & pvid() const;
107  bool pvid(VLanId const & p, bool accessMode);
108  std::uint32_t vlanMismatchRx();
109  std::uint32_t vlanMismatchTx();
110 
111  std::pair<senf::emu::WirelessNLController::DFSState::Enum,std::uint32_t> dfsState(unsigned freq, unsigned bw);
112  void startCAC(unsigned int freq, unsigned int bandwidth);
113  void cacAborted();
114 
115  void dumpMmapStats(std::ostream & os);
116  void dumpFilterStats(std::ostream & os);
117  bool isDead() const;
118 
119  void airTime(bool a);
120  WifiStatisticsMap const & statisticsMap(std::uint32_t tag, senf::ClockService::clock_type const & maxAge);
121  void dumpWifiStatistics(std::ostream & os);
122 
123  void frequencyHint(unsigned bandwidth);
124 
126  void spectralScanCallback();
127  void spectralScanStats(std::ostream & os);
128 
131 
132  void triggerScan(std::ostream & os, std::set<WirelessNLController::frequency_type> const & frequencies);
133  void getScan(std::ostream & os);
134  void dumpSurvey(std::ostream & os);
135 
137 
138  // temporary member to allow testing MCS ranges
139  void modulationSet(std::set<ModulationParameter::id_t> const & ids = {});
140 
141  protected:
144 
145  private:
146  void registerFrequencies();
147  void registerModulations();
148  void registerModulations_vht(BitrateParameters::VHT_MCSBitmapTable const & vht_mcs_table);
149  void registerVHTModulation(unsigned vhtMcsIndex, unsigned nss, unsigned bw, bool shortGI);
150  void registerTxPowers();
151 
152  void init();
153  void init_sockets();
154  void close_sockets();
155 
156  void openMonitorSocket();
157  void closeMonitorSocket();
158  void openDataSocket();
159  void closeDataSocket();
160 
161  // interface
162  virtual void v_enable() override;
163  virtual void v_disable() override;
164  virtual bool v_enabled() const override;
165  virtual void v_id(MACAddress const & id) override;
166  virtual MACAddress v_id() const override;
167  virtual bool v_annotationMode() const override;
168  virtual void v_annotationMode(bool a) override;
169  virtual bool v_promisc() const override;
170  virtual void v_promisc(bool v) override;
171  virtual void v_mcAdd(MACAddress const & address) override;
172  virtual void v_mcDrop(MACAddress const & address) override;
173  virtual unsigned v_mtu() const override;
174  virtual void v_mtu(unsigned v) override;
175  virtual void v_flushRxQueues() override;
176  virtual void v_flushTxQueues() override;
177  virtual void v_coverageRange(unsigned distance) override;
178 
179  void do_ibss_join(WirelessNLController::JoinParameters const & parameters);
180  void do_mesh_join(WirelessNLController::JoinParameters const & parameters);
181 
182  // modulation
183  virtual ModulationParameter::id_t v_modulationId() const override;
184  virtual void v_modulationId(ModulationParameter::id_t) override;
185  // channel frequency
186  virtual unsigned v_frequency() const override;
187  virtual unsigned v_bandwidth() const override;
188  virtual void v_frequency(unsigned freq, unsigned bw) override;
189 
190  // txpower
191  virtual int v_txPower() const override;
192  virtual void v_txPower(int power) override;
193 
194  std::string dev_;
195  std::string monitorDev_;
196  AthSpectralScan spectralScanner_;
197  WifiStatistics wifiStatistics_;
198  int frequencyOffset_;
199  int restrictedBand_;
200  HTMode::Enum htMode_;
202  unsigned bw_;
203  int txPower_;
204  unsigned rcvBufSize_;
205  unsigned sndBufSize_;
206  unsigned qlen_;
207  VLanId pvid_;
208  bool accessMode_;
209 
210  friend struct detail::HardwareWLANInterfaceNet;
211  friend class WLANMonitorDataFilter;
212  };
213 
214 }}
215 
216 //-/////////////////////////////////////////////////////////////////////////////////////////////////
217 #include "HardwareWLANInterface.cci"
218 //#include "HardwareWLANInterface.ct"
219 //#include "HardwareWLANInterface.cti"
220 #endif
221 
222 
223 // Local Variables:
224 // mode: c++
225 // fill-column: 100
226 // comment-column: 40
227 // c-file-style: "senf"
228 // indent-tabs-mode: nil
229 // ispell-local-dictionary: "american"
230 // compile-command: "scons -u test"
231 // End:
WirelessNLController::MeshJoinParameters::ptrM joinMesh(std::string const &meshId, unsigned int freq, unsigned int bandwidth, bool &success)
config::time_type clock_type
std::pair< senf::emu::WirelessNLController::DFSState::Enum, std::uint32_t > dfsState(unsigned freq, unsigned bw)
void init()
senf::emu::WirelessNLController::NetlinkEvent< ScanEvent > & scanEvent()
VLanId const & pvid() const
void setREDFilterCallbackRxMonitor(senf::ppi::REDFilterCallback const &cb)
void startCAC(unsigned int freq, unsigned int bandwidth)
std::tuple< unsigned, unsigned, unsigned > txDropped()
#define SENF_LOG_CLASS_AREA()
std::string const & monitorDevice() const
Get current monitor interface.
WifiStatisticsMap const & statisticsMap(std::uint32_t tag, senf::ClockService::clock_type const &maxAge)
std::string const & v_device() const override
Get name of physical device.
char ssid[36]
__u8 band
Definition: nl80211-new.h:128
MonitorDataFilterStatistics filterStats()
std::array< VHT_MCSBitmap, NL80211_VHT_NSS_MAX > VHT_MCSBitmapTable
std::function< void(std::uint64_t tsft, std::uint16_t frequency, unsigned numBins, void *spectralSample)> AthSpectralScanCallback
WirelessNLController & wirelessNLController()
WirelessNLController::IbssJoinParameters::ptrI joinAdhoc(std::string const &ssid, unsigned int freq, unsigned int bandwidth, bool &success)
void triggerScan(std::ostream &os, std::set< WirelessNLController::frequency_type > const &frequencies)
std::pair< unsigned, unsigned > rxDropped()
boost::unordered_map< senf::MACAddress, WifiStatisticsData > WifiStatisticsMap
senf::emu::WirelessNLController::NetlinkEvent< RadarEvent > & radarEvent()
unsigned bandwidth() const
Get current bandwidth.
Hardware interface base class.
void setREDFilterCallbackRx(senf::ppi::REDFilterCallback const &cb)
void setREDFilterCallbackTx(senf::ppi::REDFilterCallback const &cb)
WLANInterface public header.
WirelessNLController public header.
Specialized Interface decorator base-class.
HardwareWLANInterface(std::pair< std::string, std::string > interfaces)
TypedInterfaceDecorator< HardwareWLANInterface, WirelessInterface::Decorator > Decorator
void modulationSet(std::set< ModulationParameter::id_t > const &ids={})
FrequenciesRange frequencies() const
Get valid frequency intervals.
__be16 freq