|
@ -8,34 +8,32 @@ |
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) { |
|
|
int main(int argc, char *argv[]) { |
|
|
QCoreApplication app(argc, argv); |
|
|
QCoreApplication app(argc, argv); |
|
|
Interface interface("enp0s3"); |
|
|
|
|
|
|
|
|
QStringList links = Interface::list(); |
|
|
|
|
|
|
|
|
Neighbor neighbor; |
|
|
Neighbor neighbor; |
|
|
bool neighOk = false; |
|
|
|
|
|
|
|
|
|
|
|
std::cout << "MAC: " << qPrintable(neighbor.macOfIP("10.0.4.1")) << std::endl; |
|
|
std::cout << "Interfaces:" << std::endl; |
|
|
QStringList addresses = interface.addresses(); |
|
|
|
|
|
|
|
|
|
|
|
foreach(QString address, addresses) { |
|
|
foreach(QString link, links) { |
|
|
std::cout << "Address: " << qPrintable(address) << std::endl; |
|
|
Interface interface(link); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::cout << "Link of " << qPrintable(interface.name()) << " is: " << interface.hasCarrier() << std::endl; |
|
|
std::cout << link.toStdString() << std::endl; |
|
|
|
|
|
|
|
|
std::cout << "Interfaces:" << std::endl; |
|
|
QStringList addresses = interface.addresses(); |
|
|
|
|
|
|
|
|
QStringList links = Interface::list(); |
|
|
foreach(QString address, addresses) { |
|
|
|
|
|
std::cout << " Address: " << address.toStdString() << std::endl; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
foreach(QString link, links) { |
|
|
std::cout << " Link: " << (interface.hasCarrier() ? "up" : "down") << std::endl; |
|
|
std::cout << qPrintable(link) << std::endl; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
std::cout << "-----" << std::endl; |
|
|
std::cout << "-----" << std::endl; |
|
|
|
|
|
|
|
|
std::cout << "Neighbors:" << std::endl; |
|
|
std::cout << "Neighbors:" << std::endl; |
|
|
|
|
|
|
|
|
QHash<QString, QString> neighs = Neighbor::list("", &neighOk); |
|
|
QHash<QString, QString> neighs = Neighbor::list("", 0); |
|
|
|
|
|
|
|
|
std::cout << (neighOk ? "(ok)" : "(not ok)") << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
foreach(QString neigh, neighs.keys()) { |
|
|
foreach(QString neigh, neighs.keys()) { |
|
|
std::cout << qPrintable(neigh) << " (" << qPrintable(neighs.value(neigh)) << ")" << std::endl; |
|
|
std::cout << qPrintable(neigh) << " (" << qPrintable(neighs.value(neigh)) << ")" << std::endl; |
|
|