diff --git a/iptest/iptest.cpp b/iptest/iptest.cpp index 6f84499..906842c 100644 --- a/iptest/iptest.cpp +++ b/iptest/iptest.cpp @@ -8,34 +8,32 @@ int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); - Interface interface("enp0s3"); + + QStringList links = Interface::list(); + Neighbor neighbor; - bool neighOk = false; - std::cout << "MAC: " << qPrintable(neighbor.macOfIP("10.0.4.1")) << std::endl; - QStringList addresses = interface.addresses(); + std::cout << "Interfaces:" << std::endl; - foreach(QString address, addresses) { - std::cout << "Address: " << qPrintable(address) << std::endl; - } + foreach(QString link, links) { + 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 << qPrintable(link) << std::endl; + std::cout << " Link: " << (interface.hasCarrier() ? "up" : "down") << std::endl; } std::cout << "-----" << std::endl; std::cout << "Neighbors:" << std::endl; - QHash neighs = Neighbor::list("", &neighOk); - - std::cout << (neighOk ? "(ok)" : "(not ok)") << std::endl; + QHash neighs = Neighbor::list("", 0); foreach(QString neigh, neighs.keys()) { std::cout << qPrintable(neigh) << " (" << qPrintable(neighs.value(neigh)) << ")" << std::endl; diff --git a/iptest/iptest.pro b/iptest/iptest.pro index 5f773d1..5ff0c19 100644 --- a/iptest/iptest.pro +++ b/iptest/iptest.pro @@ -12,10 +12,6 @@ SOURCES += iptest.cpp INCLUDEPATH += "../" LIBS += -L.. -lip -LIBS += -lnl-route-3 -lnl-3 -lnl-genl-3 -lasan +LIBS += -lnl-route-3 -lnl-3 -lnl-genl-3 -QMAKE_CXXFLAGS += -fsanitize=address -fPIE -QMAKE_CFLAGS += -fsanitize=address -fPIE -QMAKE_LFLAGS += -Wl,-rpath,/home/bp/libip - -# Directories +QMAKE_LFLAGS += -Wl,-rpath,. diff --git a/libip.pro b/libip.pro index 541cfc8..edbcf68 100644 --- a/libip.pro +++ b/libip.pro @@ -9,10 +9,7 @@ INCLUDEPATH += /usr/include/libnl3 DEFINES += LIBIP_LIBRARY -QMAKE_CXXFLAGS += -Wall -Wextra -Werror -fsanitize=address -fPIE -QMAKE_CFLAGS += -Wall -Wextra -Werror -fsanitize=address -fPIE - -LIBS += -lnl-route-3 -lnl-3 -lnl-genl-3 -lasan +LIBS += -lnl-route-3 -lnl-3 -lnl-genl-3 HEADERS += interface.h neighbor.h wireless.h utils.h ieee80211.h SOURCES += interface.cpp neighbor.cpp wireless.cpp utils.cpp