Commit 7e011b02 by “liusq”

修改ping命令-04

parent 225f0db7
......@@ -447,11 +447,13 @@ inline bool GetNetworkInfoByQNetworkInterface(QString &mac, QString &subnetMask,
interface.flags().testFlag(QNetworkInterface::IsRunning) &&
!interface.flags().testFlag(QNetworkInterface::IsLoopBack)) {
mac = interface.hardwareAddress();
qInfo() << "mac===>."<<mac;
QList<QNetworkAddressEntry> addressEntries = interface.addressEntries();
foreach (QNetworkAddressEntry entry, addressEntries) {
if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol) {
subnetMask = entry.netmask().toString();
qInfo() << "subnetMask===>."<<subnetMask;
// 获取网关地址
QFile file("/proc/net/route");
......@@ -469,6 +471,7 @@ inline bool GetNetworkInfoByQNetworkInterface(QString &mac, QString &subnetMask,
gateway = gateway.mid(6, 2) + ":" + gateway.mid(4, 2) + ":" + gateway.mid(2, 2) + ":" + gateway.mid(0, 2);
gateway = gateway.replace(":", ".");
gateway = QHostAddress(gateway).toString();
qInfo() << "gateway===>."<<gateway;
return true;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment