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.
 
 
 

67 lines
2.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);
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");
QMap<int, int> channels = wi.channelMap();
foreach(int chan, channels.keys()) {
std::cout << "found channel " << chan << " (" << channels.value(chan) << ")" << 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;
QTimer::singleShot(0, qApp, SLOT(quit()));
int ret = app.exec();
return ret;
}