You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
4.3 KiB
139 lines
4.3 KiB
#include <QtCore/QCoreApplication>
|
|
#include <iostream>
|
|
#include <QTimer>
|
|
#include <QStringList>
|
|
#include "interface.h"
|
|
#include "neighbor.h"
|
|
#include "wireless.h"
|
|
|
|
int main(int argc, char *argv[]) {
|
|
QCoreApplication app(argc, argv);
|
|
|
|
QStringList links = Interface::list();
|
|
|
|
Neighbor neighbor;
|
|
|
|
std::cout << "Interfaces:" << std::endl;
|
|
|
|
foreach(QString link, links) {
|
|
Interface interface(link);
|
|
|
|
std::cout << link.toStdString() << std::endl;
|
|
|
|
QStringList addresses = interface.addresses();
|
|
|
|
foreach(QString address, addresses) {
|
|
std::cout << " Address: " << address.toStdString() << std::endl;
|
|
}
|
|
|
|
std::cout << " Link: " << (interface.hasCarrier() ? "up" : "down") << std::endl;
|
|
}
|
|
|
|
std::cout << "-----" << std::endl;
|
|
|
|
std::cout << "Neighbors:" << std::endl;
|
|
|
|
QHash<QString, QString> neighs = Neighbor::list("", 0);
|
|
|
|
foreach(QString neigh, neighs.keys()) {
|
|
std::cout << qPrintable(neigh) << " (" << qPrintable(neighs.value(neigh)) << ")" << std::endl;
|
|
}
|
|
|
|
QStringList wifiInterfaces = Wireless::interfaceList();
|
|
|
|
foreach(QString wifi, wifiInterfaces) {
|
|
std::cout << "----- " << qPrintable(wifi) << std::endl;
|
|
|
|
//interface.deleteAddress("1.1.1.5/29");
|
|
|
|
Wireless wi(wifi);
|
|
|
|
QList<Wireless::BandInfo> bands = wi.bandMap();
|
|
|
|
foreach(Wireless::BandInfo band, bands) {
|
|
std::cout << "found band" <<
|
|
(((band.band & Wireless::BAND_2GHZ) == Wireless::BAND_2GHZ) ? " 2GHz" : "") <<
|
|
(((band.band & Wireless::BAND_5GHZ) == Wireless::BAND_5GHZ) ? " 5GHz" : "") <<
|
|
(((band.protocols & Wireless::PROTOCOL_80211_A) == Wireless::PROTOCOL_80211_A) ? " (802.11a)" : "") <<
|
|
(((band.protocols & Wireless::PROTOCOL_80211_B) == Wireless::PROTOCOL_80211_B) ? " (802.11b)" : "") <<
|
|
(((band.protocols & Wireless::PROTOCOL_80211_G) == Wireless::PROTOCOL_80211_G) ? " (802.11g)" : "") <<
|
|
(((band.protocols & Wireless::PROTOCOL_80211_N) == Wireless::PROTOCOL_80211_N) ? " (802.11n)" : "");
|
|
|
|
if((band.width & Wireless::WIDTH_20MHZ) == Wireless::WIDTH_20MHZ) {
|
|
std::cout << " (20MHz)";
|
|
}
|
|
|
|
if((band.width & Wireless::WIDTH_40MHZ) == Wireless::WIDTH_40MHZ) {
|
|
std::cout << " (40MHz)";
|
|
}
|
|
|
|
std::cout << std::endl;
|
|
|
|
if(band.channels.count() > 0) {
|
|
foreach(Wireless::ChannelInfo info, band.channels) {
|
|
std::cout << " found channel " << info.chan << " (" << info.freq << "): " <<
|
|
"Disabled?: " << (info.disabled ? "yes" : "no") << " " <<
|
|
"Passive?: " << (info.passive ? "yes" : "no") << " " <<
|
|
"Radar?: " << (info.radar ? "yes" : "no") << " " <<
|
|
"Max TX Power: " << info.max_txpower << " " <<
|
|
std::endl;
|
|
}
|
|
|
|
std::cout << "converting channel 1 to freq: " << qPrintable(Wireless::ChanToFreq("Channel: 1")) << std::endl;
|
|
std::cout << "converting freq 5200 to channel: " << qPrintable(Wireless::FreqToChan("Frequency: 5.2GHz")) << std::endl;
|
|
std::cout << "is channel 11 supported? " << (wi.channelSupported(11) ? "yes" : "no") << std::endl;
|
|
std::cout << "is channel 165 supported? " << (wi.channelSupported(165) ? "yes" : "no") << std::endl;
|
|
std::cout << "is frequency 2.437GHz supported? " << (wi.frequencySupported(2437) ? "yes" : "no") << std::endl;
|
|
std::cout << "is frequency 5.825GHz supported? " << (wi.frequencySupported(5825) ? "yes" : "no") << std::endl;
|
|
}else{
|
|
std::cout << "no channels supported" << std::endl;
|
|
}
|
|
}
|
|
|
|
std::cout << "all channels:";
|
|
|
|
foreach(int chan, wi.allChannels()) {
|
|
std::cout << " " << chan;
|
|
}
|
|
|
|
std::cout << std::endl;
|
|
|
|
////
|
|
|
|
std::cout << "allowed TX/RX channels:";
|
|
|
|
foreach(int chan, wi.allowedChannels(Wireless::Direction_Both)) {
|
|
std::cout << " " << chan;
|
|
}
|
|
|
|
std::cout << std::endl;
|
|
|
|
////
|
|
|
|
std::cout << "allowed RX channels:";
|
|
|
|
foreach(int chan, wi.allowedChannels(Wireless::Direction_RX)) {
|
|
std::cout << " " << chan;
|
|
}
|
|
|
|
std::cout << std::endl;
|
|
|
|
////
|
|
|
|
std::cout << "all frequencies:";
|
|
|
|
foreach(int freq, wi.allFrequencies()) {
|
|
std::cout << " " << freq;
|
|
}
|
|
|
|
std::cout << std::endl;
|
|
|
|
std::cout << "wifi interface type: " << qPrintable(wi.getInterfaceType()) << std::endl;
|
|
}
|
|
|
|
QTimer::singleShot(0, qApp, SLOT(quit()));
|
|
|
|
int ret = app.exec();
|
|
|
|
return ret;
|
|
}
|
|
|