17 #ifndef HH_SENF_Ext_NetEmu_WLAN_WirelessNLController_ 18 #define HH_SENF_Ext_NetEmu_WLAN_WirelessNLController_ 1 22 #include <boost/enable_shared_from_this.hpp> 23 #include <boost/shared_ptr.hpp> 24 #include <boost/signals2.hpp> 25 #include <boost/optional.hpp> 52 class HardwareWLANInterface;
53 class WirelessNLController;
98 SupportedChannelWidth_160_8080MHz };
117 enum Enum { Config, Scan, Regulatory, Mlme, Vendor };
152 COMPLETED = 0, ABORTED = 1 };
191 enum Enum { Unspecified, AdHoc, Station, AP, APVLan,
WDS, Monitor, MeshPoint, Unknown };
219 static std::string
str(
Enum state);
238 frequency(0),
noise(0), channelTime(0), channelTimeBusy(0), channelTimeExtBusy(0),
239 channelTimeRx(0), channelTimeTx(0), inUse(inuse) {
259 frequency(0),
tsf (0), bssId(bssid), beaconInterval(0), capability(0),
signal(0),
260 signalUnspec(0), status(0), seenMsAgo(0), informationElementsLength(0), beaconInformationElementsLength(0) {
261 memset(informationElements, 0,
sizeof(informationElements));
262 memset(beaconInformationElements, 0,
sizeof(beaconInformationElements));
276 std::uint8_t informationElements[4096];
277 std::uint8_t beaconInformationElements[4096];
280 return bssId < other.
bssId;
285 typedef std::multimap<Band_t, frequency_type> Frequencies;
286 typedef boost::transform_iterator< ::__gnu_cxx::select2nd<Frequencies::value_type>,
287 Frequencies::const_iterator> Frequencies_iterator;
288 typedef std::vector<bitrate_type> BitrateList;
290 class JoinParameters : boost::noncopyable,
291 public boost::enable_shared_from_this<JoinParameters>
293 typedef boost::function<void (JoinParameters const &)> Callback;
294 typedef boost::shared_ptr<JoinParameters> ptr;
298 void initHTCapabilities();
302 frequency_type freq_;
305 std::vector<unsigned char> ies_;
306 boost::optional<ieee80211_ht_cap> htCapabilities_;
307 boost::optional<ieee80211_ht_cap> htCapabilitiesMask_;
308 boost::optional<boost::uint32_t> beaconInterval_;
316 template <
typename ForwardReadableRange>
317 JoinParameters::ptr informationElements(ForwardReadableRange
const & ies);
318 JoinParameters::ptr ampduFactor(
unsigned factor);
319 JoinParameters::ptr beaconInterval(boost::optional<boost::uint32_t> interval);
320 JoinParameters::ptr handleDFS(
bool flag);
323 class IbssJoinParameters :
public JoinParameters
325 typedef boost::shared_ptr<IbssJoinParameters> ptrI;
326 IbssJoinParameters(Callback cb, std::string
const &
ssid, frequency_type
freq,
ChannelMode::Enum channelMode,
bool & success);
338 class MeshJoinParameters :
public JoinParameters
340 typedef boost::shared_ptr<MeshJoinParameters> ptrM;
341 MeshJoinParameters(Callback cb, std::string
const & meshId, frequency_type
freq,
ChannelMode::Enum channelMode,
bool & success);
344 boost::optional<boost::uint8_t> vendorMetric_;
345 boost::optional<boost::uint8_t> vendorPathSelection_;
346 boost::optional<boost::uint8_t> vendorSynchronization_;
353 MeshJoinParameters::ptrM vendorMetric(
bool enable);
354 MeshJoinParameters::ptrM vendorPathSelection(
bool enable);
355 MeshJoinParameters::ptrM vendorSynchronization(
bool enable);
365 JoinParameters::ptr ibss_join(std::string
const &
ssid, frequency_type
freq,
ChannelMode::Enum channelMode,
bool & success);
368 JoinParameters::ptr mesh_join(std::string
const & meshId, frequency_type
freq,
ChannelMode::Enum channelMode,
bool & success);
374 void add_monInterface(std::string
const & name,
int flags = MonitorFlags::None);
375 void add_adhocInterface(std::string
const & name);
376 void add_apInterface(std::string
const & name);
377 void add_meshInterface(std::string
const & name, std::string
const & meshId =
"");
379 void del_interface(std::string
const & name);
381 void set_retryLimit(boost::uint8_t shortLimit, boost::uint8_t longLimit);
383 void set_txQueueParameters(boost::uint8_t queue, boost::uint16_t cwMin, boost::uint16_t cwMax, boost::uint8_t aifs, boost::uint16_t txop);
385 std::pair<DFSState::Enum,std::uint32_t> dfsState(frequency_type
freq);
388 template <
typename ForwardReadableRange>
389 void trigger_scan(ForwardReadableRange
const & frequencies);
390 void do_trigger_scan(std::set<frequency_type>
const & frequencies, std::set<std::string>
const & ssids = {});
392 void set_regulatory_request(std::string
const & alpha2Country);
396 static unsigned distanceToCoverageClass(
unsigned distance);
397 void coverageClass(
unsigned coverage);
398 unsigned coverageClass();
400 bool hasHTCapabilities();
403 bool hasVHTCapabilities();
407 IfaceNameSet all_interfaces()
const;
409 std::string
const & phyName()
const;
410 int phyIndex()
const;
412 static int if_nameto_phy_index(std::string
const & ifname);
413 static std::string if_nameto_phy_name(std::string
const & ifname);
414 static int phy_nametoindex(std::string
const & phyname);
421 std::multiset<ScanResults>
const & getScan();
422 std::set<Survey>
const & survey();
423 frequency_type frequency();
424 FrequencyRange frequencies();
433 std::set<Band_t>
const & supportedBands();
435 template <
typename EventType>
439 boost::signals2::signal<void (EventType)>
signal;
454 typedef boost::shared_ptr<nl_msg> nl_msg_ptr;
455 typedef std::unique_ptr<nl_sock, void(*)(nl_sock *)> nl_sock_ptr;
456 typedef std::unique_ptr<nl_cb, void(*)(nl_cb *)> nl_cb_ptr;
457 typedef std::unique_ptr<nl_cache, void(*)(nl_cache *)> nl_cache_ptr;
459 enum CmdIdBy { CIB_NONE, CIB_PHY, CIB_IF };
461 void init(
bool disableSeqNoCheck =
true);
462 void initNlSock(nl_sock_ptr & sock,
bool disableSeqNoCheck =
true);
463 void initNlCache(nl_sock_ptr & sock, nl_cache_ptr & cache);
464 void initNlCb(nl_sock_ptr & sock, nl_cb_ptr & cb, NetlinkMsgCallback & msgcb);
466 static nl_msg_ptr nlMsg();
468 nl_msg_ptr nlMsgHeader(uint8_t cmd, CmdIdBy idBy,
int flags=0)
const;
469 void send_and_wait4response(nl_msg_ptr
const & msg, CallbackMemPtr cb =
nullptr);
470 void send(nl_msg_ptr
const & msg);
472 void do_ibss_join(JoinParameters
const & parameters);
473 void do_mesh_join(JoinParameters
const & parameters);
475 int processScanResponse(std::uint8_t cmd, nlattr ** msgAttr);
476 int getScan_cb(nl_msg * msg);
481 int netlink_cb(nl_msg * msg);
482 int netlink_event_cb(nl_msg * msg);
484 int getWiphy_cb(nl_msg * msg);
485 int getSurvey_cb(nl_msg * msg);
486 int getIface_cb(nl_msg * msg);
487 int getMCGroups_cb(nl_msg * msg);
488 int getRegDomain_cb(nl_msg * msg);
493 void get_multicastGroups();
494 void initEventHandling();
495 void deinitEventHandling();
496 void processReadEvent(
int eventMask);
498 int processRadarEvent(nlattr ** msgAttr);
499 int processRegDomainEvent(nlattr ** msgAttr);
501 Frequencies frequencies_;
503 bool firstMutlipartMsg_;
504 std::set<Survey> survey_;
505 std::multiset<ScanResults> scanResults_;
507 unsigned coverageClass_;
508 bool hasHTCapabilities_;
510 bool hasVHTCapabilities_;
512 std::set<Band_t> supportedBands_;
516 std::string phyName_;
517 nl_sock_ptr nl_sock_;
518 nl_cache_ptr nl_cache_;
521 CallbackMemPtr callback_;
522 NetlinkMsgCallback netlinkMsgCb_;
523 NetlinkMsgCallback netlinkEventCb_;
525 typedef std::map<frequency_type, std::pair<DFSState::Enum,std::uint32_t>> DFSStateMap;
526 DFSStateMap dfsStates_;
528 boost::optional<std::set<BitrateParameters::MCSIndex> > tmpMCSRates_;
529 boost::optional<std::set<BitrateParameters::LegacyBitrate> > tmpLegacyRates_;
531 nl_sock_ptr nl_event_sock_;
532 nl_cb_ptr nl_event_cb_;
533 std::set<NetlinkMulticastGroup::Enum> joinedMCGroups_;
534 std::map<std::string, int> multicastGroups_;
535 boost::scoped_ptr<scheduler::FdEvent> nlEvent_;
546 int errorNumber()
const;
547 char const * errorString()
const;
bool lSIG_TXOP_Protection
std::uint64_t channelTimeExtBusy
std::set< MCSIndex > MCSIndexSet
std::uint64_t channelTimeBusy
std::string str(T const &t)
#define SENF_LOG_CLASS_AREA()
bool operator<(Survey const &other) const
ChannelWidth channelWidth
boost::function< int(nl_msg *)> NetlinkMsgCallback
boost::optional< MCSIndexSet > mcs_24
std::set< LegacyBitrate > LegacyBitrateSet
std::uint64_t channelTimeRx
std::uint64_t channelTimeTx
bool shortGIfor160_8080MHz
boost::optional< LegacyBitrateSet > legacy_5
std::array< VHT_MCSBitmap, NL80211_VHT_NSS_MAX > VHT_MCSBitmapTable
NetlinkEvent< ScanEvent > scanEvent
StatsDataCollectorKernel signal
boost::optional< VHT_MCSBitmapTable > vht_mcs_table_24
std::uint16_t beaconInterval
boost::signals2::signal< void(EventType)> signal
ScanResults(senf::MACAddress const &bssid)
std::uint64_t channelTime
NetlinkEvent< RadarEvent > radarEvent
boost::optional< MCSIndexSet > mcs_5
bool operator<(ScanResults const &other) const
std::set< std::string > IfaceNameSet
MaxAMSDULength maxAMSDULength
boost::optional< VHT_MCSBitmapTable > vht_mcs_table_5
std::bitset< 10 > VHT_MCSBitmap
boost::optional< GICfg > gi_5
bool rxAntennaPatternConsistency
bool txAntennaPatternConsistency
boost::optional< GICfg > gi_24
NetlinkEvent< RegulatoryDomainChangeEvent > regulatoryDomainChangeEvent
boost::optional< LegacyBitrateSet > legacy_24
int beaconInformationElementsLength
std::uint8_t signalUnspec
int informationElementsLength
boost::iterator_range< Frequencies_iterator > FrequencyRange