Fix host lookup after successfull ping

This commit is contained in:
Simon Stürz 2021-06-06 14:20:36 +02:00
parent caed213cb7
commit 4065a471b7
5 changed files with 6 additions and 9 deletions

View File

@ -100,13 +100,13 @@ QDebug operator<<(QDebug dbg, const NetworkDevice &networkDevice)
{ {
dbg.nospace() << "NetworkDevice("; dbg.nospace() << "NetworkDevice(";
dbg.nospace() << networkDevice.address().toString() << ", "; dbg.nospace() << networkDevice.address().toString() << ", ";
if (!networkDevice.hostName().isEmpty())
dbg.nospace() << ", " << networkDevice.hostName();
dbg.nospace() << networkDevice.macAddress(); dbg.nospace() << networkDevice.macAddress();
if (!networkDevice.macAddressManufacturer().isEmpty()) if (!networkDevice.macAddressManufacturer().isEmpty())
dbg.nospace() << "(" << networkDevice.macAddressManufacturer() << ")"; dbg.nospace() << "(" << networkDevice.macAddressManufacturer() << ")";
if (!networkDevice.hostName().isEmpty())
dbg.nospace() << ", " << networkDevice.hostName();
if (networkDevice.networkInterface().isValid()) if (networkDevice.networkInterface().isValid())
dbg.nospace() << ", " << networkDevice.networkInterface().name(); dbg.nospace() << ", " << networkDevice.networkInterface().name();

View File

@ -32,6 +32,7 @@
#include "loggingcategories.h" #include "loggingcategories.h"
#include "networkutils.h" #include "networkutils.h"
#include "macaddressdatabase.h" #include "macaddressdatabase.h"
#include "arpsocket.h"
#include <QDateTime> #include <QDateTime>
@ -79,7 +80,6 @@ NetworkDeviceDiscoveryReply *NetworkDeviceDiscovery::discover()
} }
qCDebug(dcNetworkDeviceDiscovery()) << "Starting network device discovery ..."; qCDebug(dcNetworkDeviceDiscovery()) << "Starting network device discovery ...";
NetworkDeviceDiscoveryReply *reply = new NetworkDeviceDiscoveryReply(this); NetworkDeviceDiscoveryReply *reply = new NetworkDeviceDiscoveryReply(this);
m_currentReply = reply; m_currentReply = reply;
m_currentReply->m_startTimestamp = QDateTime::currentMSecsSinceEpoch(); m_currentReply->m_startTimestamp = QDateTime::currentMSecsSinceEpoch();

View File

@ -37,9 +37,9 @@
#include "ping.h" #include "ping.h"
#include "libnymea.h" #include "libnymea.h"
#include "arpsocket.h"
#include "networkdevicediscoveryreply.h" #include "networkdevicediscoveryreply.h"
class ArpSocket;
class MacAddressDatabase; class MacAddressDatabase;
class MacAddressDatabaseReply; class MacAddressDatabaseReply;

View File

@ -350,7 +350,7 @@ void Ping::onSocketReadyRead(int socketDescriptor)
reply->m_duration = qRound((receiveTimeValue.tv_sec * 1000 + (double)receiveTimeValue.tv_usec / 1000) * 100) / 100.0; reply->m_duration = qRound((receiveTimeValue.tv_sec * 1000 + (double)receiveTimeValue.tv_usec / 1000) * 100) / 100.0;
// Note: due to a Qt bug < 5.9 we need to use old SLOT style and cannot make use of lambda here // Note: due to a Qt bug < 5.9 we need to use old SLOT style and cannot make use of lambda here
int lookupId = QHostInfo::lookupHost(senderAddress.toString(), this, SLOT(onHostLookupFinished(const QHostInfo &info))); int lookupId = QHostInfo::lookupHost(senderAddress.toString(), this, SLOT(onHostLookupFinished(QHostInfo)));
m_pendingHostLookups.insert(lookupId, reply); m_pendingHostLookups.insert(lookupId, reply);
qCDebug(dcPingTraffic()) << "Received ICMP response" << reply->targetHostAddress().toString() << ICMP_PACKET_SIZE << "[Bytes]" qCDebug(dcPingTraffic()) << "Received ICMP response" << reply->targetHostAddress().toString() << ICMP_PACKET_SIZE << "[Bytes]"

View File

@ -40,10 +40,7 @@
#include <QSocketNotifier> #include <QSocketNotifier>
#include <QLoggingCategory> #include <QLoggingCategory>
#include <netinet/ip_icmp.h>
#include "libnymea.h" #include "libnymea.h"
#include "pingreply.h" #include "pingreply.h"
#include <netinet/ip_icmp.h> #include <netinet/ip_icmp.h>