mdns: Allow resolve its own non-strict answers

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 https://github.com/espressif/esp-idf/issues/6190
This commit is contained in:
David Cermak 2020-12-11 14:00:26 +01:00 committed by bot
parent 286f06b274
commit 0693e172de

View File

@ -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;
@ -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;
}