From eddd5c4f2c686d9a1d6d3258569cc33752e78880 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 15 Mar 2019 16:02:13 +0100 Subject: [PATCH 1/4] mdns: update mdns_out_question_s to be in line with mdns_parsed_question_s struct Closes https://github.com/espressif/esp-idf/issues/1568 --- components/mdns/private_include/mdns_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mdns/private_include/mdns_private.h b/components/mdns/private_include/mdns_private.h index a5b0747aa0..e3becf28ff 100644 --- a/components/mdns/private_include/mdns_private.h +++ b/components/mdns/private_include/mdns_private.h @@ -260,7 +260,7 @@ typedef struct mdns_srv_item_s { typedef struct mdns_out_question_s { struct mdns_out_question_s * next; uint16_t type; - uint8_t unicast; + bool unicast; const char * host; const char * service; const char * proto; From a851aac255311124529f504486ca55bad15c1951 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 22 Mar 2019 08:49:12 +0100 Subject: [PATCH 2/4] mdns: updated doxygen comments documenting mdns api Closes https://github.com/espressif/esp-idf/issues/1718 --- components/mdns/include/mdns.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/mdns/include/mdns.h b/components/mdns/include/mdns.h index a5ebb809f6..751535b964 100644 --- a/components/mdns/include/mdns.h +++ b/components/mdns/include/mdns.h @@ -81,10 +81,9 @@ typedef struct mdns_result_s { * * @return * - ESP_OK on success - * - ESP_ERR_INVALID_ARG when bad tcpip_if is given - * - ESP_ERR_INVALID_STATE when the network returned error + * - ESP_ERR_INVALID_STATE when failed to register event handler * - ESP_ERR_NO_MEM on memory error - * - ESP_ERR_WIFI_NOT_INIT when WiFi is not initialized by eps_wifi_init + * - ESP_FAIL when failed to start mdns task */ esp_err_t mdns_init(); @@ -127,13 +126,14 @@ esp_err_t mdns_instance_name_set(const char * instance_name); * @param service_type service type (_http, _ftp, etc) * @param proto service protocol (_tcp, _udp) * @param port service port - * @param num_items number of items in TXT data * @param txt string array of TXT data (eg. {{"var","val"},{"other","2"}}) + * @param num_items number of items in TXT data * * @return * - ESP_OK success * - ESP_ERR_INVALID_ARG Parameter error * - ESP_ERR_NO_MEM memory error + * - ESP_FAIL failed to add serivce */ esp_err_t mdns_service_add(const char * instance_name, const char * service_type, const char * proto, uint16_t port, mdns_txt_item_t txt[], size_t num_items); @@ -147,7 +147,7 @@ esp_err_t mdns_service_add(const char * instance_name, const char * service_type * - ESP_OK success * - ESP_ERR_INVALID_ARG Parameter error * - ESP_ERR_NOT_FOUND Service not found - * - ESP_FAIL unknown error + * - ESP_ERR_NO_MEM memory error */ esp_err_t mdns_service_remove(const char * service_type, const char * proto); @@ -177,6 +177,7 @@ esp_err_t mdns_service_instance_name_set(const char * service_type, const char * * - ESP_OK success * - ESP_ERR_INVALID_ARG Parameter error * - ESP_ERR_NOT_FOUND Service not found + * - ESP_ERR_NO_MEM memory error */ esp_err_t mdns_service_port_set(const char * service_type, const char * proto, uint16_t port); @@ -185,8 +186,8 @@ esp_err_t mdns_service_port_set(const char * service_type, const char * proto, u * * @param service_type service type (_http, _ftp, etc) * @param proto service protocol (_tcp, _udp) - * @param num_items number of items in TXT data * @param txt array of TXT data (eg. {{"var","val"},{"other","2"}}) + * @param num_items number of items in TXT data * * @return * - ESP_OK success From c050a75616803c7871ef11c060e440fae09000d9 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 3 May 2019 16:31:11 +0200 Subject: [PATCH 3/4] mdns: use const char* for mdns txt items types to remove warning when assigning --- components/mdns/include/mdns.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/mdns/include/mdns.h b/components/mdns/include/mdns.h index 751535b964..4370969d70 100644 --- a/components/mdns/include/mdns.h +++ b/components/mdns/include/mdns.h @@ -44,8 +44,8 @@ typedef enum { * Used in mdns_service_add() */ typedef struct { - char * key; /*!< item key name */ - char * value; /*!< item value string */ + const char * key; /*!< item key name */ + const char * value; /*!< item value string */ } mdns_txt_item_t; /** From af48977f21cea6b18dae10b2c8b64a78acfc647f Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 3 May 2019 16:37:43 +0200 Subject: [PATCH 4/4] mdns: fixed mdns crashing on reception of txt packet without a corresponding service closes #2866 --- components/mdns/mdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 8c9767942a..e88672f82b 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -2886,7 +2886,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet) col = 1; } else if (!clas) { col = -1; - } else { + } else if (service) { // only detect txt collision if service existed col = _mdns_check_txt_collision(service->service, data_ptr, data_len); } if (col && !_mdns_server->interfaces[packet->tcpip_if].pcbs[packet->ip_protocol].probe_running) {