#ifndef LIBIP_WIRELESS_H #define LIBIP_WIRELESS_H #include #include #include "libip_global.h" #include #include class LIBIP_EXPORT Wireless : public QObject { //Q_OBJECT // no Q_OBJECT macro here because clang linker complains about missing vtable, probably because we aren't using any signals/slots public: Wireless(QString interface = QString()); ~Wireless(); struct ChannelInfo { int chan; int freq; // these boolean values may change depending on the current regulatory domain set bool disabled; // both TX/RX disabled bool passive; // RX-only channel bool radar; // DFS (radar detection) required int max_txpower; // in millibels (mBm); 100 mBm = 1 dBm ChannelInfo() : chan(0), freq(0), disabled(false), passive(false), radar(false), max_txpower(0) { } }; struct BandInfo { int band; int width; int protocols; QList channels; BandInfo() : band(0), width(0), protocols(0), channels() { } }; enum Bands { BAND_2GHZ = (1 << 0), BAND_5GHZ = (1 << 1), BAND_60GHZ = (1 << 2) }; enum Protocols { PROTOCOL_80211_A = (1 << 0), PROTOCOL_80211_B = (1 << 1), PROTOCOL_80211_G = (1 << 2), PROTOCOL_80211_N = (1 << 3) }; enum Direction { Direction_RX = (1 << 0), Direction_Both = (1 << 1) }; enum ChannelWidth { WIDTH_20MHZ = (1 << 0), WIDTH_40MHZ = (1 << 1), WIDTH_80MHZ = (1 << 2), WIDTH_160MHZ = (1 << 3) }; const QString& name() const; const QList& bandMap() const; QList allChannels() const; QList allowedChannels(Direction direction) const; QList allFrequencies() const; QList allowedFrequencies(Direction direction) const; static int ChanToFreq(int channel); static QString ChanToFreq(QString channel, QString outputFormat = QString()); static int FreqToChan(int frequency); static QString FreqToChan(QString frequency, QString outputFormat = QString()); static QStringList interfaceList(); bool isValid() const; bool isNL80211() const; bool channelSupported(int channel) const; bool frequencySupported(int frequency) const; nl80211_iftype getInterfaceTypeRaw(); const QString& getInterfaceType() const; private: QString m_interface; QString m_interfaceType; QList m_bands; bool m_isValid; bool m_isNL80211; nl80211_iftype m_iftype; bool parseBands(); bool parseInterface(); static int nl80211_interface_cb(struct nl_msg *msg, void *arg); static int nl80211_freqlist_cb(struct nl_msg *msg, void *arg); static int nl80211_error_cb(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg); static int nl80211_finish_cb(struct nl_msg *msg, void *arg); char* nl80211_find_parent(const char *interface) const; void nl80211_disconnect(void *handle, struct nl_cache *cache, struct genl_family *family) const; int nl80211_connect(const char *interface, void **handle, struct nl_cache **cache, struct genl_family **family) const; }; #endif // LIBIP_WIRELESS_H