Merge branch 'bugfix/mdns_configure_strict_mode' into 'master'

mdns: Fix mdns to correctly answer non-strict queries (+ additional fixes)

Closes IDF-2928, WIFI-3107, and IDFGH-4797

See merge request espressif/esp-idf!12645
pull/6882/head
David Čermák 2021-04-13 08:04:43 +00:00
commit c2bab4be95
4 zmienionych plików z 22 dodań i 8 usunięć

Wyświetl plik

@ -56,6 +56,17 @@ menu "mDNS"
Configures timeout for adding a new mDNS service. Adding a service
fails if could not be completed within this time.
config MDNS_STRICT_MODE
bool "mDNS strict mode"
default "n"
help
Configures strict mode. Set this to 1 for the mDNS library to strictly follow the RFC6762:
Currently the only strict feature: Do not repeat original questions in response packets
(defined in RFC6762 sec. 6).
Default configuration is 0, i.e. non-strict mode, since some implementations,
such as lwIP mdns resolver (used by standard POSIX API like getaddrinfo, gethostbyname)
could not correctly resolve advertised names.
config MDNS_TIMER_PERIOD_MS
int "mDNS timer period (ms)"
range 10 10000

Wyświetl plik

@ -2679,7 +2679,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
}
//if we have not set the hostname, we can not answer questions
if (header.questions && _str_null_or_empty(_mdns_server->hostname)) {
if (header.questions && !header.answers && _str_null_or_empty(_mdns_server->hostname)) {
free(parsed_packet);
return;
}
@ -2815,13 +2815,12 @@ 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 (!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 (!parsed_packet->authoritative || record_type == MDNS_NS) {
//skip this record
continue;

Wyświetl plik

@ -38,7 +38,7 @@ static esp_err_t _udp_pcb_main_init(void)
_pcb_main = NULL;
return ESP_ERR_INVALID_STATE;
}
_pcb_main->mcast_ttl = 1;
_pcb_main->mcast_ttl = 255;
_pcb_main->remote_port = MDNS_SERVICE_PORT;
ip_addr_copy(_pcb_main->remote_ip, *(IP_ANY_TYPE));
udp_recv(_pcb_main, &_udp_recv, _mdns_server);

Wyświetl plik

@ -32,7 +32,11 @@
* such as lwIP mdns resolver (used by standard POSIX API like getaddrinfo, gethostbyname)
* could not correctly resolve advertised names.
*/
#ifndef CONFIG_MDNS_STRICT_MODE
#define MDNS_STRICT_MODE 0
#else
#define MDNS_STRICT_MODE 1
#endif
#if !MDNS_STRICT_MODE
/* mDNS responders sometimes repeat queries in responses