From 8c6d995eca9212d2072aec123de7bec7ae50b0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juh=C3=A1sz=20B=C3=A1lint?= <juhasz.balint.bebe@gmail.com> Date: Mon, 30 Mar 2015 18:26:48 +0200 Subject: [PATCH] megtobb info --- if_test.cpp | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/if_test.cpp b/if_test.cpp index 384f8e9..b98487c 100644 --- a/if_test.cpp +++ b/if_test.cpp @@ -1,22 +1,36 @@ #include <QCoreApplication> #include <QtNetwork/QNetworkInterface> +#define cout QTextStream(stdout) int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); - QList<QNetworkInterface> ifList = QNetworkInterface::allInterfaces(); // now you have interfaces list - foreach (QNetworkInterface iface, ifList) // this should print all interfaces' names + + QList<QNetworkInterface> ifList = QNetworkInterface::allInterfaces(); + + foreach (QNetworkInterface iface, ifList) { - QTextStream(stdout) << iface.humanReadableName() << '\n'; - QTextStream(stdout) << '\t' << "can broadcast? " << iface.CanBroadcast << '\n'; - QTextStream(stdout) << '\t' << "can multicast? " << iface.CanMulticast << '\n'; - QTextStream(stdout) << '\t' << "HW address: " << iface.hardwareAddress() << '\n'; - QTextStream(stdout) << '\t' << "is loopback? " << iface.IsLoopBack << '\n'; - QTextStream(stdout) << '\t' << "is point-to-point? " << iface.IsPointToPoint << '\n'; - QTextStream(stdout) << '\t' << "is running? " << iface.IsRunning << '\n'; - QTextStream(stdout) << '\t' << "is up? " << iface.IsUp << '\n'; - QTextStream(stdout) << '\t' << "is valid? " << iface.isValid() << '\n'; - QTextStream(stdout) << '\t' << "internal name: " << iface.name() << '\n'; + cout << "[+] " << iface.humanReadableName() << '\n'; + cout << '\t' << "[+] Address entries:" << '\n'; + foreach (QNetworkAddressEntry netAddr, iface.addressEntries()){ + cout << "\t\t- broadcast addr: " << netAddr.broadcast().toString() << '\n'; + cout << "\t\t- ip addr: " << netAddr.ip().toString() << '\n'; + cout << "\t\t- subnetmask: " << netAddr.netmask().toString() << '\n'; + } + cout << "\t- can broadcast? " << iface.CanBroadcast << '\n'; + cout << "\t- can multicast? " << iface.CanMulticast << '\n'; + cout << "\t- HW address: " << iface.hardwareAddress() << '\n'; + cout << "\t- is loopback? " << iface.IsLoopBack << '\n'; + cout << "\t- is point-to-point? " << iface.IsPointToPoint << '\n'; + cout << "\t- is running? " << iface.IsRunning << '\n'; + cout << "\t- is up? " << iface.IsUp << '\n'; + cout << "\t- is valid? " << iface.isValid() << '\n'; + cout << "\t- internal name: " << iface.name() << '\n'; + } + cout << "\n------------------ unnamed addresses -------------------\n\n"; + cout << "[+] Local addresses:"; + foreach (QHostAddress hostAddr, QNetworkInterface::allAddresses()){ + cout << "\t- " << hostAddr.toString() << '\n'; } return a.exec(); } -- GitLab