diff --git a/src/ippdiscovery.cpp b/src/ippdiscovery.cpp index 440f48b..34f8557 100644 --- a/src/ippdiscovery.cpp +++ b/src/ippdiscovery.cpp @@ -150,7 +150,8 @@ void IppDiscovery::readPendingDatagrams() QHostAddress sender; quint16 senderPort; - QStringList ipp_ptrs; + QStringList new_ipp_ptrs; + QStringList new_targets; socket->readDatagram((char*)(resp.raw()), size, &sender, &senderPort); sender = QHostAddress(sender.toIPv4Address()); @@ -182,7 +183,7 @@ void IppDiscovery::readPendingDatagrams() QString tmpname = get_addr(resp).join("."); if(aaddr.endsWith("_ipp._tcp.local")) { - ipp_ptrs.append(tmpname); + new_ipp_ptrs.append(tmpname); } } else if(atype == TXT) @@ -206,6 +207,7 @@ void IppDiscovery::readPendingDatagrams() QString target = get_addr(resp).join("."); _ports[aaddr] = port; _targets[aaddr] = target; + new_targets.append(target); } else if(atype == A) { @@ -227,25 +229,35 @@ void IppDiscovery::readPendingDatagrams() qDebug() << e.what(); return; } - qDebug() << "new ipp ptrs" << ipp_ptrs; + qDebug() << "new ipp ptrs" << new_ipp_ptrs; qDebug() << "ipp ptrs" << _ipp; qDebug() << "rps" << _rps; qDebug() << "ports" << _ports; + qDebug() << "new targets" << new_targets; qDebug() << "targets" << _targets; qDebug() << "AAs" << _AAs; qDebug() << "AAAAs" << _AAAAs; - for(QStringList::Iterator it = ipp_ptrs.begin(); it != ipp_ptrs.end(); it++) + for(QStringList::Iterator it = new_ipp_ptrs.begin(); it != new_ipp_ptrs.end(); it++) { if(!_ipp.contains(*it)) { _ipp.append(*it); } - if(!_ports.contains(*it) || !_targets.contains(*it) || !_rps.contains(*it)) + // If pointer does not resolve to a target or is missing information, query about it + if( !_targets.contains(*it) || !_ports.contains(*it) || !_rps.contains(*it)) { // if the PTR doesn't already resolve, ask for everything about it sendQuery(ALL, it->split('.')); } } + for(QStringList::Iterator it = new_targets.begin(); it != new_targets.end(); it++) + { + // If target does not resolve to an address, query about it + if(!_AAs.contains(*it)) + { + sendQuery(ALL, it->split('.')); + } + } } this->update();