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.
 
 
 

109 lines
3.2 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);
Interface interface("enp0s3");
Neighbor neighbor;
std::cout << "MAC: " << qPrintable(neighbor.macOfIP("10.0.4.1")) << std::endl;
QStringList addresses = interface.addresses();
foreach(QString address, addresses) {
std::cout << "Address: " << qPrintable(address) << std::endl;
}
std::cout << "Link of " << qPrintable(interface.name()) << " is: " << interface.hasCarrier() << std::endl;
std::cout << "Interfaces:" << std::endl;
QStringList links = Interface::list();
foreach(QString link, links) {
std::cout << qPrintable(link) << std::endl;
}
std::cout << "-----" << std::endl;
std::cout << "Neighbors:" << std::endl;
QStringList neighs = Neighbor::list();
foreach(QString neigh, neighs) {
std::cout << qPrintable(neigh) << std::endl;
}
std::cout << "-----" << std::endl;
//interface.deleteAddress("1.1.1.5/29");
Wireless wi("wlp0s11u1");
QList<ChannelInfo> channels = wi.channelMap();
foreach(ChannelInfo info, 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;
std::cout << "is 802.11a supported? " << (((wi.supportedBands() & Wireless::BAND_80211_A) == Wireless::BAND_80211_A) ? "yes" : "no") << std::endl;
std::cout << "is 802.11b supported? " << (((wi.supportedBands() & Wireless::BAND_80211_B) == Wireless::BAND_80211_B) ? "yes" : "no") << 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;
QTimer::singleShot(0, qApp, SLOT(quit()));
int ret = app.exec();
return ret;
}