Formatting fixes
This commit is contained in:
parent
28bbe69b7e
commit
af01f066ed
2 changed files with 35 additions and 21 deletions
|
@ -22,24 +22,36 @@ namespace MdnsWrapper
|
||||||
const char *recordTypeToStr(int rtype)
|
const char *recordTypeToStr(int rtype)
|
||||||
{
|
{
|
||||||
switch (rtype) {
|
switch (rtype) {
|
||||||
case MDNS_RECORDTYPE_PTR: return "PTR";
|
case MDNS_RECORDTYPE_PTR:
|
||||||
case MDNS_RECORDTYPE_SRV: return "SRV";
|
return "PTR";
|
||||||
case MDNS_RECORDTYPE_TXT: return "TXT";
|
case MDNS_RECORDTYPE_SRV:
|
||||||
case MDNS_RECORDTYPE_A: return "A";
|
return "SRV";
|
||||||
case MDNS_RECORDTYPE_AAAA: return "AAAA";
|
case MDNS_RECORDTYPE_TXT:
|
||||||
case MDNS_RECORDTYPE_ANY: return "ANY";
|
return "TXT";
|
||||||
default: return "UNKNOWN";
|
case MDNS_RECORDTYPE_A:
|
||||||
|
return "A";
|
||||||
|
case MDNS_RECORDTYPE_AAAA:
|
||||||
|
return "AAAA";
|
||||||
|
case MDNS_RECORDTYPE_ANY:
|
||||||
|
return "ANY";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *entryTypeToStr(int entry)
|
const char *entryTypeToStr(int entry)
|
||||||
{
|
{
|
||||||
switch (entry) {
|
switch (entry) {
|
||||||
case MDNS_ENTRYTYPE_QUESTION: return "QUESTION";
|
case MDNS_ENTRYTYPE_QUESTION:
|
||||||
case MDNS_ENTRYTYPE_ANSWER: return "ANSWER";
|
return "QUESTION";
|
||||||
case MDNS_ENTRYTYPE_AUTHORITY: return "AUTHORITY";
|
case MDNS_ENTRYTYPE_ANSWER:
|
||||||
case MDNS_ENTRYTYPE_ADDITIONAL: return "ADDITIONAL";
|
return "ANSWER";
|
||||||
default: return "UNKNOWN";
|
case MDNS_ENTRYTYPE_AUTHORITY:
|
||||||
|
return "AUTHORITY";
|
||||||
|
case MDNS_ENTRYTYPE_ADDITIONAL:
|
||||||
|
return "ADDITIONAL";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +269,8 @@ static mdns_record_t createMdnsRecord(const Announcer::AnnouncedInfo &self,
|
||||||
case MDNS_RECORDTYPE_SRV: // maps "<service-name>.<_service-type>._tcp.local." to "<hostname>.local." and port
|
case MDNS_RECORDTYPE_SRV: // maps "<service-name>.<_service-type>._tcp.local." to "<hostname>.local." and port
|
||||||
answer.name = createMdnsString(self.serviceInstance);
|
answer.name = createMdnsString(self.serviceInstance);
|
||||||
answer.data.srv.name = createMdnsString(self.hostname);
|
answer.data.srv.name = createMdnsString(self.hostname);
|
||||||
answer.data.srv.port = self.port, answer.data.srv.priority = 0;
|
answer.data.srv.port = self.port;
|
||||||
|
answer.data.srv.priority = 0;
|
||||||
answer.data.srv.weight = 0;
|
answer.data.srv.weight = 0;
|
||||||
break;
|
break;
|
||||||
case MDNS_RECORDTYPE_A: // maps "<hostname>.local." to IPv4
|
case MDNS_RECORDTYPE_A: // maps "<hostname>.local." to IPv4
|
||||||
|
@ -451,8 +464,6 @@ static int service_callback(int sock, const struct sockaddr* from, size_t addrle
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Open sockets to listen to incoming mDNS queries on port 5353
|
// Open sockets to listen to incoming mDNS queries on port 5353
|
||||||
// When recieving, each socket can recieve data from all network interfaces
|
// When recieving, each socket can recieve data from all network interfaces
|
||||||
// Thus we only need to open one socket for each address family
|
// Thus we only need to open one socket for each address family
|
||||||
|
@ -590,14 +601,17 @@ void Announcer::sendMulticastAnnounce(bool isGoodbye)
|
||||||
static char buffer[2048];
|
static char buffer[2048];
|
||||||
if (isGoodbye) {
|
if (isGoodbye) {
|
||||||
qCDebug(KDECONNECT_CORE) << "Sending goodbye";
|
qCDebug(KDECONNECT_CORE) << "Sending goodbye";
|
||||||
if (socketNotifier) mdns_goodbye_multicast(socketNotifier->socket(), buffer, sizeof(buffer), ptr_record, 0, 0, additional.constData(), additional.length());
|
if (socketNotifier)
|
||||||
if (socketNotifierV6) mdns_goodbye_multicast(socketNotifierV6->socket(), buffer, sizeof(buffer), ptr_record, 0, 0, additional.constData(), additional.length());
|
mdns_goodbye_multicast(socketNotifier->socket(), buffer, sizeof(buffer), ptr_record, 0, 0, additional.constData(), additional.length());
|
||||||
|
if (socketNotifierV6)
|
||||||
|
mdns_goodbye_multicast(socketNotifierV6->socket(), buffer, sizeof(buffer), ptr_record, 0, 0, additional.constData(), additional.length());
|
||||||
} else {
|
} else {
|
||||||
qCDebug(KDECONNECT_CORE) << "Sending announce";
|
qCDebug(KDECONNECT_CORE) << "Sending announce";
|
||||||
if (socketNotifier) mdns_announce_multicast(socketNotifier->socket(), buffer, sizeof(buffer), ptr_record, 0, 0, additional.constData(), additional.length());
|
if (socketNotifier)
|
||||||
if (socketNotifierV6) mdns_announce_multicast(socketNotifierV6->socket(), buffer, sizeof(buffer), ptr_record, 0, 0, additional.constData(), additional.length());
|
mdns_announce_multicast(socketNotifier->socket(), buffer, sizeof(buffer), ptr_record, 0, 0, additional.constData(), additional.length());
|
||||||
|
if (socketNotifierV6)
|
||||||
|
mdns_announce_multicast(socketNotifierV6->socket(), buffer, sizeof(buffer), ptr_record, 0, 0, additional.constData(), additional.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace MdnsWrapper
|
} // namespace MdnsWrapper
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#include "mdns_wrapper.h"
|
#include "mdns_wrapper.h"
|
||||||
|
|
||||||
QString kServiceType = QStringLiteral("_kdeconnect._udp.local");
|
const QString kServiceType = QStringLiteral("_kdeconnect._udp.local");
|
||||||
|
|
||||||
MdnsDiscovery::MdnsDiscovery(LanLinkProvider *lanLinkProvider)
|
MdnsDiscovery::MdnsDiscovery(LanLinkProvider *lanLinkProvider)
|
||||||
: lanLinkProvider(lanLinkProvider)
|
: lanLinkProvider(lanLinkProvider)
|
||||||
|
|
Loading…
Reference in a new issue