1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00

Merge pull request #2135 from zonque/resolved-mdns-3

resolved: more mDNS specific bits (3)
This commit is contained in:
Lennart Poettering 2015-12-10 16:49:31 +01:00
commit 4d3f0f66e6
3 changed files with 13 additions and 6 deletions

View File

@ -822,7 +822,11 @@ static int dns_scope_make_conflict_packet(
0 /* (ad) */,
0 /* (cd) */,
0));
random_bytes(&DNS_PACKET_HEADER(p)->id, sizeof(uint16_t));
/* For mDNS, the transaction ID should always be 0 */
if (s->protocol != DNS_PROTOCOL_MDNS)
random_bytes(&DNS_PACKET_HEADER(p)->id, sizeof(uint16_t));
DNS_PACKET_HEADER(p)->qdcount = htobe16(1);
DNS_PACKET_HEADER(p)->arcount = htobe16(1);

View File

@ -919,7 +919,6 @@ static int dns_transaction_make_packet_mdns(DnsTransaction *t) {
}
DNS_PACKET_HEADER(p)->qdcount = htobe16(qdcount);
DNS_PACKET_HEADER(p)->id = t->id;
/* Append known answer section if we're asking for any shared record */
if (add_known_answers) {

View File

@ -86,7 +86,7 @@ static int on_mdns_packet(sd_event_source *s, int fd, uint32_t revents, void *us
}
if (dns_packet_validate_reply(p) > 0) {
unsigned i;
DnsResourceRecord *rr;
log_debug("Got mDNS reply packet");
@ -107,11 +107,15 @@ static int on_mdns_packet(sd_event_source *s, int fd, uint32_t revents, void *us
dns_scope_check_conflicts(scope, p);
for (i = 0; i < p->answer->n_rrs; i++) {
DnsResourceRecord *rr;
DNS_ANSWER_FOREACH(rr, p->answer) {
const char *name = DNS_RESOURCE_KEY_NAME(rr->key);
DnsTransaction *t;
rr = p->answer->items[i].rr;
/* If the received reply packet contains ANY record that is not .local or .in-addr.arpa,
* we assume someone's playing tricks on us and discard the packet completely. */
if (!(dns_name_endswith(name, "in-addr.arpa") > 0 ||
dns_name_endswith(name, "local") > 0))
return 0;
t = dns_scope_find_transaction(scope, rr->key, false);
if (t)