Skip to content

Commit

Permalink
mdns: Allow resolve its own non-strict answers
Browse files Browse the repository at this point in the history
the mDNS responder should not repeat questions when replying, however resolvers
must ignore these questions field if they are present. esp-idf mDNS
library does include questions in answering packets (thus not strictly
following the RFC6762) so the resolver did not correctly resolved
another instance host name.

Closes #6190
  • Loading branch information
david-cermak committed Dec 29, 2020
1 parent 64c2f86 commit 0182a84
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions components/mdns/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -2753,7 +2753,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
}
}

if (header.questions && !parsed_packet->questions && !parsed_packet->discovery) {
if (header.questions && !parsed_packet->questions && !parsed_packet->discovery && !header.answers) {
goto clear_rx_packet;
} else if (header.answers || header.servers || header.additional) {
uint16_t recordIndex = 0;
Expand Down Expand Up @@ -2796,13 +2796,14 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)

if (parsed_packet->discovery && _mdns_name_is_discovery(name, type)) {
discovery = true;
} else if (!name->sub && _mdns_name_is_ours(name)) {
ours = true;
if (name->service && name->service[0] && name->proto && name->proto[0]) {
service = _mdns_get_service_item(name->service, name->proto);
}
} else {
if (header.questions || !parsed_packet->authoritative || record_type == MDNS_NS) {
if (!name->sub && _mdns_name_is_ours(name)) {
ours = true;
if (name->service && name->service[0] && name->proto && name->proto[0]) {
service = _mdns_get_service_item(name->service, name->proto);
}
}
if (!parsed_packet->authoritative || record_type == MDNS_NS) {
//skip this record
continue;
}
Expand Down

0 comments on commit 0182a84

Please sign in to comment.