Merge PR #543: NetworkDiscovery: Lookup the mac address vendor also if the cache has stored an empty mac vendor

pull/566/head
jenkins 2022-08-26 12:57:48 +02:00
commit dc18996de9
1 changed files with 9 additions and 2 deletions

View File

@ -538,21 +538,28 @@ void NetworkDeviceDiscoveryImpl::processArpTraffic(const QNetworkInterface &inte
m_currentReply->processArpResponse(interface, address, macAddress); m_currentReply->processArpResponse(interface, address, macAddress);
// Check if we know the mac address manufacturer from the cache // Check if we know the mac address manufacturer from the cache
bool requiresMacAddressLookup = true;
if (m_networkInfoCache.contains(macAddress)) { if (m_networkInfoCache.contains(macAddress)) {
QString cachedManufacturer = m_networkInfoCache[macAddress].macAddressManufacturer(); QString cachedManufacturer = m_networkInfoCache[macAddress].macAddressManufacturer();
if (!cachedManufacturer.isEmpty()) { if (!cachedManufacturer.isEmpty()) {
// Found the mac address manufacturer in the cache, let's use that // Found the mac address manufacturer in the cache, let's use that one...
m_currentReply->processMacManufacturer(macAddress, cachedManufacturer); m_currentReply->processMacManufacturer(macAddress, cachedManufacturer);
requiresMacAddressLookup = false;
} }
} else { }
if (requiresMacAddressLookup) {
// Lookup the mac address vendor if possible // Lookup the mac address vendor if possible
if (m_macAddressDatabase->available()) { if (m_macAddressDatabase->available()) {
// Not found in the cache, and the mac address database is available...let's make a query
MacAddressDatabaseReply *reply = m_macAddressDatabase->lookupMacAddress(macAddress.toString()); MacAddressDatabaseReply *reply = m_macAddressDatabase->lookupMacAddress(macAddress.toString());
connect(reply, &MacAddressDatabaseReply::finished, m_currentReply, [=](){ connect(reply, &MacAddressDatabaseReply::finished, m_currentReply, [=](){
// Note: set the mac manufacturer explicitly to make the info complete (even an empty sring)
qCDebug(dcNetworkDeviceDiscovery()) << "MAC manufacturer lookup finished for" << macAddress << ":" << reply->manufacturer(); qCDebug(dcNetworkDeviceDiscovery()) << "MAC manufacturer lookup finished for" << macAddress << ":" << reply->manufacturer();
m_currentReply->processMacManufacturer(macAddress, reply->manufacturer()); m_currentReply->processMacManufacturer(macAddress, reply->manufacturer());
}); });
} else { } else {
// Not found in the cache, and no mac address database available...we are done with mac vendor
// Note: set the mac manufacturer explicitly to make the info complete // Note: set the mac manufacturer explicitly to make the info complete
m_currentReply->processMacManufacturer(macAddress, QString()); m_currentReply->processMacManufacturer(macAddress, QString());
} }