#ifndef LIBIP_WIRELESS_H #define LIBIP_WIRELESS_H #include #include #include "libip_global.h" struct ChannelInfo { int chan; int freq; bool disabled; bool passive; bool radar; int max_txpower; 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() { } }; class LIBIP_EXPORT Wireless : public QObject { Q_OBJECT public: Wireless(QString interface = QString()); ~Wireless(); 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 dir) const; QList allFrequencies() const; QList allowedFrequencies(Direction dir) const; static int ChanToFreq(int in_chan); static QString ChanToFreq(QString in_chan, QString outputFormat = QString()); static int FreqToChan(int in_freq); static QString FreqToChan(QString in_freq, QString outputFormat = QString()); bool isValid() const; bool isNL80211() const; bool channelSupported(int chan) const; bool frequencySupported(int freq) const; private: QString m_interface; QList m_bands; bool m_isValid; bool m_isNL80211; 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