1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #ifndef ESP_MDNS_H_
15 #define ESP_MDNS_H_
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <esp_netif.h>
22 #include "esp_event.h"
23 
24 #define MDNS_TYPE_A                 0x0001
25 #define MDNS_TYPE_PTR               0x000C
26 #define MDNS_TYPE_TXT               0x0010
27 #define MDNS_TYPE_AAAA              0x001C
28 #define MDNS_TYPE_SRV               0x0021
29 #define MDNS_TYPE_OPT               0x0029
30 #define MDNS_TYPE_NSEC              0x002F
31 #define MDNS_TYPE_ANY               0x00FF
32 
33 /**
34  * @brief   Asynchronous query handle
35  */
36 typedef struct mdns_search_once_s mdns_search_once_t;
37 
38 /**
39  * @brief   mDNS enum to specify the ip_protocol type
40  */
41 typedef enum {
42     MDNS_IP_PROTOCOL_V4,
43     MDNS_IP_PROTOCOL_V6,
44     MDNS_IP_PROTOCOL_MAX
45 } mdns_ip_protocol_t;
46 
47 /**
48  * @brief   mDNS basic text item structure
49  *          Used in mdns_service_add()
50  */
51 typedef struct {
52     const char * key;                       /*!< item key name */
53     const char * value;                     /*!< item value string */
54 } mdns_txt_item_t;
55 
56 /**
57  * @brief   mDNS query linked list IP item
58  */
59 typedef struct mdns_ip_addr_s {
60     esp_ip_addr_t addr;                     /*!< IP address */
61     struct mdns_ip_addr_s * next;           /*!< next IP, or NULL for the last IP in the list */
62 } mdns_ip_addr_t;
63 
64 typedef enum mdns_if_internal {
65     MDNS_IF_STA = 0,
66     MDNS_IF_AP = 1,
67     MDNS_IF_ETH = 2,
68     MDNS_IF_MAX
69 } mdns_if_t;
70 
71 /**
72  * @brief   mDNS query result structure
73  */
74 typedef struct mdns_result_s {
75     struct mdns_result_s * next;            /*!< next result, or NULL for the last result in the list */
76 
77     mdns_if_t tcpip_if;                     /*!< interface index */
78     uint32_t ttl;                           /*!< time to live */
79 
80     mdns_ip_protocol_t ip_protocol;         /*!< ip_protocol type of the interface (v4/v6) */
81     // PTR
82     char * instance_name;                   /*!< instance name */
83     char * service_type;                    /*!< service type */
84     char * proto;                           /*!< srevice protocol */
85     // SRV
86     char * hostname;                        /*!< hostname */
87     uint16_t port;                          /*!< service port */
88     // TXT
89     mdns_txt_item_t * txt;                  /*!< txt record */
90     uint8_t *txt_value_len;                 /*!< array of txt value len of each record */
91     size_t txt_count;                       /*!< number of txt items */
92     // A and AAAA
93     mdns_ip_addr_t * addr;                  /*!< linked list of IP addresses found */
94 } mdns_result_t;
95 
96 typedef void (*mdns_query_notify_t)(mdns_search_once_t *search);
97 
98 /**
99  * @brief  Initialize mDNS on given interface
100  *
101  * @return
102  *     - ESP_OK on success
103  *     - ESP_ERR_INVALID_STATE when failed to register event handler
104  *     - ESP_ERR_NO_MEM on memory error
105  *     - ESP_FAIL when failed to start mdns task
106  */
107 esp_err_t mdns_init(void);
108 
109 /**
110  * @brief  Stop and free mDNS server
111  *
112  */
113 void mdns_free(void);
114 
115 /**
116  * @brief  Set the hostname for mDNS server
117  *         required if you want to advertise services
118  *
119  * @param  hostname     Hostname to set
120  *
121  * @return
122  *     - ESP_OK success
123  *     - ESP_ERR_INVALID_ARG Parameter error
124  *     - ESP_ERR_NO_MEM memory error
125  */
126 esp_err_t mdns_hostname_set(const char * hostname);
127 
128 /**
129  * @brief  Adds a hostname and address to be delegated
130  *         A/AAAA queries will be replied for the hostname and
131  *         services can be added to this host.
132  *
133  * @param  hostname     Hostname to add
134  * @param  address_list The IP address list of the host
135  *
136  * @return
137  *     - ESP_OK success
138  *     - ESP_ERR_INVALID_STATE mDNS is not running
139  *     - ESP_ERR_INVALID_ARG Parameter error
140  *     - ESP_ERR_NO_MEM memory error
141  *
142  */
143 esp_err_t mdns_delegate_hostname_add(const char * hostname, const mdns_ip_addr_t *address_list);
144 
145 /**
146  * @brief  Remove a delegated hostname
147  *         All the services added to this host will also be removed.
148  *
149  * @param  hostname     Hostname to remove
150  *
151  * @return
152  *     - ESP_OK success
153  *     - ESP_ERR_INVALID_STATE mDNS is not running
154  *     - ESP_ERR_INVALID_ARG Parameter error
155  *     - ESP_ERR_NO_MEM memory error
156  *
157  */
158 esp_err_t mdns_delegate_hostname_remove(const char * hostname);
159 
160 /**
161  * @brief  Query whether a hostname has been added
162  *
163  * @param  hostname     Hostname to query
164  *
165  * @return
166  *     - true   The hostname has been added.
167  *     - false  The hostname has not been added.
168  *
169  */
170 bool mdns_hostname_exists(const char * hostname);
171 
172 /**
173  * @brief  Set the default instance name for mDNS server
174  *
175  * @param  instance_name     Instance name to set
176  *
177  * @return
178  *     - ESP_OK success
179  *     - ESP_ERR_INVALID_ARG Parameter error
180  *     - ESP_ERR_NO_MEM memory error
181  */
182 esp_err_t mdns_instance_name_set(const char * instance_name);
183 
184 /**
185  * @brief  Add service to mDNS server
186  *
187  * @note The value length of txt items will be automatically decided by strlen
188  *
189  * @param  instance_name    instance name to set. If NULL,
190  *                          global instance name or hostname will be used.
191  *                          Note that MDNS_MULTIPLE_INSTANCE config option
192  *                          needs to be enabled for adding multiple instances
193  *                          with the same instance type.
194  * @param  service_type     service type (_http, _ftp, etc)
195  * @param  proto            service protocol (_tcp, _udp)
196  * @param  port             service port
197  * @param  txt              string array of TXT data (eg. {{"var","val"},{"other","2"}})
198  * @param  num_items        number of items in TXT data
199  *
200  * @return
201  *     - ESP_OK success
202  *     - ESP_ERR_INVALID_ARG Parameter error
203  *     - ESP_ERR_NO_MEM memory error
204  *     - ESP_FAIL failed to add service
205  */
206 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);
207 
208 /**
209  * @brief  Add service to mDNS server with a delegated hostname
210  *
211  * @note The value length of txt items will be automatically decided by strlen
212  *
213  * @param  instance_name    instance name to set. If NULL,
214  *                          global instance name or hostname will be used
215  *                          Note that MDNS_MULTIPLE_INSTANCE config option
216  *                          needs to be enabled for adding multiple instances
217  *                          with the same instance type.
218  * @param  service_type     service type (_http, _ftp, etc)
219  * @param  proto            service protocol (_tcp, _udp)
220  * @param  hostname         service hostname. If NULL, local hostname will be used.
221  * @param  port             service port
222  * @param  txt              string array of TXT data (eg. {{"var","val"},{"other","2"}})
223  * @param  num_items        number of items in TXT data
224  *
225  * @return
226  *     - ESP_OK success
227  *     - ESP_ERR_INVALID_ARG Parameter error
228  *     - ESP_ERR_NO_MEM memory error
229  *     - ESP_FAIL failed to add service
230  */
231 esp_err_t mdns_service_add_for_host(const char * instance_name, const char * service_type, const char * proto,
232                                     const char * hostname, uint16_t port, mdns_txt_item_t txt[], size_t num_items);
233 
234 /**
235  * @brief  Check whether a service has been added.
236  *
237  * @param  service_type     service type (_http, _ftp, etc)
238  * @param  proto            service protocol (_tcp, _udp)
239  * @param  hostname         service hostname. If NULL, checks for the local hostname.
240  *
241  * @return
242  *     - true   Correspondding service has been added.
243  *     - false  Service not found.
244  */
245 bool mdns_service_exists(const char * service_type, const char * proto, const char * hostname);
246 
247 
248 /**
249  * @brief  Check whether a service has been added.
250  *
251  * @param  instance         instance name
252  * @param  service_type     service type (_http, _ftp, etc)
253  * @param  proto            service protocol (_tcp, _udp)
254  * @param  hostname         service hostname. If NULL, checks for the local hostname.
255  *
256  * @return
257  *     - true   Correspondding service has been added.
258  *     - false  Service not found.
259  */
260 bool mdns_service_exists_with_instance(const char *instance, const char *service_type, const char *proto,
261                                        const char *hostname);
262 
263 /**
264  * @brief  Remove service from mDNS server
265  *
266  * @param  service_type service type (_http, _ftp, etc)
267  * @param  proto        service protocol (_tcp, _udp)
268  *
269  * @return
270  *     - ESP_OK success
271  *     - ESP_ERR_INVALID_ARG Parameter error
272  *     - ESP_ERR_NOT_FOUND Service not found
273  *     - ESP_ERR_NO_MEM memory error
274  */
275 esp_err_t mdns_service_remove(const char * service_type, const char * proto);
276 
277 /**
278  * @brief  Remove service from mDNS server with hostname
279  *
280  * @param  service_type service type (_http, _ftp, etc)
281  * @param  proto        service protocol (_tcp, _udp)
282  * @param  hostname     service hostname. If NULL, local hostname will be used.
283  *
284  * @return
285  *     - ESP_OK success
286  *     - ESP_ERR_INVALID_ARG Parameter error
287  *     - ESP_ERR_NOT_FOUND Service not found
288  *     - ESP_ERR_NO_MEM memory error
289  */
290 esp_err_t mdns_service_remove_for_host(const char * service_type, const char * proto, const char *hostname);
291 
292 /**
293  * @brief  Set instance name for service
294  *
295  * @param  service_type     service type (_http, _ftp, etc)
296  * @param  proto            service protocol (_tcp, _udp)
297  * @param  instance_name    instance name to set
298  *
299  * @return
300  *     - ESP_OK success
301  *     - ESP_ERR_INVALID_ARG Parameter error
302  *     - ESP_ERR_NOT_FOUND Service not found
303  *     - ESP_ERR_NO_MEM memory error
304  */
305 esp_err_t mdns_service_instance_name_set(const char * service_type, const char * proto, const char * instance_name);
306 
307 /**
308  * @brief  Set instance name for service with hostname
309  *
310  * @param  service_type     service type (_http, _ftp, etc)
311  * @param  proto            service protocol (_tcp, _udp)
312  * @param  hostname         service hostname. If NULL, local hostname will be used.
313  * @param  instance_name    instance name to set
314  *
315  * @return
316  *     - ESP_OK success
317  *     - ESP_ERR_INVALID_ARG Parameter error
318  *     - ESP_ERR_NOT_FOUND Service not found
319  *     - ESP_ERR_NO_MEM memory error
320  */
321 esp_err_t mdns_service_instance_name_set_for_host(const char * service_type, const char * proto, const char * hostname,
322                                                   const char * instance_name);
323 
324 /**
325  * @brief  Set service port
326  *
327  * @param  service_type service type (_http, _ftp, etc)
328  * @param  proto        service protocol (_tcp, _udp)
329  * @param  port         service port
330  *
331  * @return
332  *     - ESP_OK success
333  *     - ESP_ERR_INVALID_ARG Parameter error
334  *     - ESP_ERR_NOT_FOUND Service not found
335  *     - ESP_ERR_NO_MEM memory error
336  */
337 esp_err_t mdns_service_port_set(const char * service_type, const char * proto, uint16_t port);
338 
339 
340 /**
341  * @brief  Set service port with hostname
342  *
343  * @param  service_type service type (_http, _ftp, etc)
344  * @param  proto        service protocol (_tcp, _udp)
345  * @param  hostname     service hostname. If NULL, local hostname will be used.
346  * @param  port         service port
347  *
348  * @return
349  *     - ESP_OK success
350  *     - ESP_ERR_INVALID_ARG Parameter error
351  *     - ESP_ERR_NOT_FOUND Service not found
352  *     - ESP_ERR_NO_MEM memory error
353  */
354 esp_err_t mdns_service_port_set_for_host(const char * service_type, const char * proto, const char * hostname,
355                                          uint16_t port);
356 
357 /**
358  * @brief  Replace all TXT items for service
359  *
360  * @note The value length of txt items will be automatically decided by strlen
361  *
362  * @param  service_type service type (_http, _ftp, etc)
363  * @param  proto        service protocol (_tcp, _udp)
364  * @param  txt          array of TXT data (eg. {{"var","val"},{"other","2"}})
365  * @param  num_items    number of items in TXT data
366  *
367  * @return
368  *     - ESP_OK success
369  *     - ESP_ERR_INVALID_ARG Parameter error
370  *     - ESP_ERR_NOT_FOUND Service not found
371  *     - ESP_ERR_NO_MEM memory error
372  */
373 esp_err_t mdns_service_txt_set(const char * service_type, const char * proto, mdns_txt_item_t txt[], uint8_t num_items);
374 
375 /**
376  * @brief  Replace all TXT items for service with hostname
377  *
378  * @note The value length of txt items will be automatically decided by strlen
379  *
380  * @param  service_type service type (_http, _ftp, etc)
381  * @param  proto        service protocol (_tcp, _udp)
382  * @param  hostname     service hostname. If NULL, local hostname will be used.
383  * @param  txt          array of TXT data (eg. {{"var","val"},{"other","2"}})
384  * @param  num_items    number of items in TXT data
385  *
386  * @return
387  *     - ESP_OK success
388  *     - ESP_ERR_INVALID_ARG Parameter error
389  *     - ESP_ERR_NOT_FOUND Service not found
390  *     - ESP_ERR_NO_MEM memory error
391  */
392 esp_err_t mdns_service_txt_set_for_host(const char * service_type, const char * proto, const char * hostname,
393                                         mdns_txt_item_t txt[], uint8_t num_items);
394 
395 /**
396  * @brief  Set/Add TXT item for service TXT record
397  *
398  * @note The value length will be automatically decided by strlen
399  *
400  * @param  service_type service type (_http, _ftp, etc)
401  * @param  proto        service protocol (_tcp, _udp)
402  * @param  key          the key that you want to add/update
403  * @param  value        the new value of the key
404  *
405  * @return
406  *     - ESP_OK success
407  *     - ESP_ERR_INVALID_ARG Parameter error
408  *     - ESP_ERR_NOT_FOUND Service not found
409  *     - ESP_ERR_NO_MEM memory error
410  */
411 esp_err_t mdns_service_txt_item_set(const char * service_type, const char * proto, const char * key, const char * value);
412 
413 /**
414  * @brief  Set/Add TXT item for service TXT record
415  *
416  * @param  service_type service type (_http, _ftp, etc)
417  * @param  proto        service protocol (_tcp, _udp)
418  * @param  key          the key that you want to add/update
419  * @param  value        the new value of the key
420  * @param  value_len    the length of the value
421  *
422  * @return
423  *     - ESP_OK success
424  *     - ESP_ERR_INVALID_ARG Parameter error
425  *     - ESP_ERR_NOT_FOUND Service not found
426  *     - ESP_ERR_NO_MEM memory error
427  */
428 esp_err_t mdns_service_txt_item_set_with_explicit_value_len(const char *service_type, const char *proto,
429                                                             const char *key, const char *value, uint8_t value_len);
430 
431 /**
432  * @brief  Set/Add TXT item for service TXT record with hostname
433  *
434  * @note The value length will be automatically decided by strlen
435  *
436  * @param  service_type service type (_http, _ftp, etc)
437  * @param  proto        service protocol (_tcp, _udp)
438  * @param  hostname     service hostname. If NULL, local hostname will be used.
439  * @param  key          the key that you want to add/update
440  * @param  value        the new value of the key
441  *
442  * @return
443  *     - ESP_OK success
444  *     - ESP_ERR_INVALID_ARG Parameter error
445  *     - ESP_ERR_NOT_FOUND Service not found
446  *     - ESP_ERR_NO_MEM memory error
447  */
448 esp_err_t mdns_service_txt_item_set_for_host(const char * service_type, const char * proto, const char * hostname,
449                                              const char * key, const char * value);
450 
451 /**
452  * @brief  Set/Add TXT item for service TXT record with hostname and txt value length
453  *
454  * @param  service_type service type (_http, _ftp, etc)
455  * @param  proto        service protocol (_tcp, _udp)
456  * @param  hostname     service hostname. If NULL, local hostname will be used.
457  * @param  key          the key that you want to add/update
458  * @param  value        the new value of the key
459  * @param  value_len    the length of the value
460  *
461  * @return
462  *     - ESP_OK success
463  *     - ESP_ERR_INVALID_ARG Parameter error
464  *     - ESP_ERR_NOT_FOUND Service not found
465  *     - ESP_ERR_NO_MEM memory error
466  */
467 esp_err_t mdns_service_txt_item_set_for_host_with_explicit_value_len(const char *service_type, const char *proto,
468                                                                      const char *hostname, const char *key,
469                                                                      const char *value, uint8_t value_len);
470 
471 /**
472  * @brief  Remove TXT item for service TXT record
473  *
474  * @param  service_type service type (_http, _ftp, etc)
475  * @param  proto        service protocol (_tcp, _udp)
476  * @param  key          the key that you want to remove
477  *
478  * @return
479  *     - ESP_OK success
480  *     - ESP_ERR_INVALID_ARG Parameter error
481  *     - ESP_ERR_NOT_FOUND Service not found
482  *     - ESP_ERR_NO_MEM memory error
483  */
484 esp_err_t mdns_service_txt_item_remove(const char * service_type, const char * proto, const char * key);
485 
486 /**
487  * @brief  Remove TXT item for service TXT record with hostname
488  *
489  * @param  service_type service type (_http, _ftp, etc)
490  * @param  proto        service protocol (_tcp, _udp)
491  * @param  hostname     service hostname. If NULL, local hostname will be used.
492  * @param  key          the key that you want to remove
493  *
494  * @return
495  *     - ESP_OK success
496  *     - ESP_ERR_INVALID_ARG Parameter error
497  *     - ESP_ERR_NOT_FOUND Service not found
498  *     - ESP_ERR_NO_MEM memory error
499  */
500 esp_err_t mdns_service_txt_item_remove_for_host(const char * service_type, const char * proto, const char * hostname,
501                                                 const char * key);
502 
503 /**
504  * @brief  Remove and free all services from mDNS server
505  *
506  * @return
507  *     - ESP_OK success
508  *     - ESP_ERR_INVALID_ARG Parameter error
509  */
510 esp_err_t mdns_service_remove_all(void);
511 
512 /**
513  * @brief Deletes the finished query. Call this only after the search has ended!
514  *
515  * @param search pointer to search object
516  *
517  * @return
518  *     - ESP_OK success
519  *     - ESP_ERR_INVALID_STATE  search has not finished
520  *     - ESP_ERR_INVALID_ARG    pointer to search object is NULL
521  */
522 esp_err_t mdns_query_async_delete(mdns_search_once_t* search);
523 
524 /**
525  * @brief Get results from search pointer. Results available as a pointer to the output parameter.
526  *        Pointer to search object has to be deleted via `mdns_query_async_delete` once the query has finished.
527  *        The results although have to be freed manually.
528  *
529  * @param search pointer to search object
530  * @param timeout time in milliseconds to wait for answers
531  * @param results pointer to the results of the query
532  *
533  * @return
534  *      True if search has finished before or at timeout
535  *      False if search timeout is over
536  */
537 bool mdns_query_async_get_results(mdns_search_once_t* search, uint32_t timeout, mdns_result_t ** results);
538 
539 /**
540  * @brief  Query mDNS for host or service asynchronousely.
541  *         Search has to be tested for progress and deleted manually!
542  *
543  * @param  name         service instance or host name (NULL for PTR queries)
544  * @param  service_type service type (_http, _arduino, _ftp etc.) (NULL for host queries)
545  * @param  proto        service protocol (_tcp, _udp, etc.) (NULL for host queries)
546  * @param  type         type of query (MDNS_TYPE_*)
547  * @param  timeout      time in milliseconds during which mDNS query is active
548  * @param  max_results  maximum results to be collected
549  * @param  notifier     Notification function to be called when the result is ready, can be NULL
550  *
551  * @return mdns_search_once_s pointer to new search object if query initiated successfully.
552  *         NULL otherwise.
553  */
554 mdns_search_once_t *mdns_query_async_new(const char *name, const char *service_type, const char *proto, uint16_t type,
555                                          uint32_t timeout, size_t max_results, mdns_query_notify_t notifier);
556 
557 /**
558  * @brief  Query mDNS for host or service
559  *         All following query methods are derived from this one
560  *
561  * @param  name         service instance or host name (NULL for PTR queries)
562  * @param  service_type service type (_http, _arduino, _ftp etc.) (NULL for host queries)
563  * @param  proto        service protocol (_tcp, _udp, etc.) (NULL for host queries)
564  * @param  type         type of query (MDNS_TYPE_*)
565  * @param  timeout      time in milliseconds to wait for answers.
566  * @param  max_results  maximum results to be collected
567  * @param  results      pointer to the results of the query
568  *                      results must be freed using mdns_query_results_free below
569  *
570  * @return
571  *     - ESP_OK success
572  *     - ESP_ERR_INVALID_STATE  mDNS is not running
573  *     - ESP_ERR_NO_MEM         memory error
574  *     - ESP_ERR_INVALID_ARG    timeout was not given
575  */
576 esp_err_t mdns_query(const char * name, const char * service_type, const char * proto, uint16_t type, uint32_t timeout, size_t max_results, mdns_result_t ** results);
577 
578 /**
579  * @brief  Free query results
580  *
581  * @param  results      linked list of results to be freed
582  */
583 void mdns_query_results_free(mdns_result_t * results);
584 
585 /**
586  * @brief  Query mDNS for service
587  *
588  * @param  service_type service type (_http, _arduino, _ftp etc.)
589  * @param  proto        service protocol (_tcp, _udp, etc.)
590  * @param  timeout      time in milliseconds to wait for answer.
591  * @param  max_results  maximum results to be collected
592  * @param  results      pointer to the results of the query
593  *
594  * @return
595  *     - ESP_OK success
596  *     - ESP_ERR_INVALID_STATE  mDNS is not running
597  *     - ESP_ERR_NO_MEM         memory error
598  *     - ESP_ERR_INVALID_ARG    parameter error
599  */
600 esp_err_t mdns_query_ptr(const char * service_type, const char * proto, uint32_t timeout, size_t max_results, mdns_result_t ** results);
601 
602 /**
603  * @brief  Query mDNS for SRV record
604  *
605  * @param  instance_name    service instance name
606  * @param  service_type     service type (_http, _arduino, _ftp etc.)
607  * @param  proto            service protocol (_tcp, _udp, etc.)
608  * @param  timeout          time in milliseconds to wait for answer.
609  * @param  result           pointer to the result of the query
610  *
611  * @return
612  *     - ESP_OK success
613  *     - ESP_ERR_INVALID_STATE  mDNS is not running
614  *     - ESP_ERR_NO_MEM         memory error
615  *     - ESP_ERR_INVALID_ARG    parameter error
616  */
617 esp_err_t mdns_query_srv(const char * instance_name, const char * service_type, const char * proto, uint32_t timeout, mdns_result_t ** result);
618 
619 /**
620  * @brief  Query mDNS for TXT record
621  *
622  * @param  instance_name    service instance name
623  * @param  service_type     service type (_http, _arduino, _ftp etc.)
624  * @param  proto            service protocol (_tcp, _udp, etc.)
625  * @param  timeout          time in milliseconds to wait for answer.
626  * @param  result           pointer to the result of the query
627  *
628  * @return
629  *     - ESP_OK success
630  *     - ESP_ERR_INVALID_STATE  mDNS is not running
631  *     - ESP_ERR_NO_MEM         memory error
632  *     - ESP_ERR_INVALID_ARG    parameter error
633  */
634 esp_err_t mdns_query_txt(const char * instance_name, const char * service_type, const char * proto, uint32_t timeout, mdns_result_t ** result);
635 
636 /**
637  * @brief  Query mDNS for A record
638  *
639  * @param  host_name    host name to look for
640  * @param  timeout      time in milliseconds to wait for answer.
641  * @param  addr         pointer to the resulting IP4 address
642  *
643  * @return
644  *     - ESP_OK success
645  *     - ESP_ERR_INVALID_STATE  mDNS is not running
646  *     - ESP_ERR_NO_MEM         memory error
647  *     - ESP_ERR_INVALID_ARG    parameter error
648  */
649 esp_err_t mdns_query_a(const char * host_name, uint32_t timeout, esp_ip4_addr_t * addr);
650 
651 #if CONFIG_LWIP_IPV6
652 /**
653  * @brief  Query mDNS for A record
654  *
655  * Please note that hostname must not contain domain name, as mDNS uses '.local' domain.
656  *
657  * @param  host_name    host name to look for
658  * @param  timeout      time in milliseconds to wait for answer. If 0, max_results needs to be defined
659  * @param  addr         pointer to the resulting IP6 address
660  *
661  * @return
662  *     - ESP_OK success
663  *     - ESP_ERR_INVALID_STATE  mDNS is not running
664  *     - ESP_ERR_NO_MEM         memory error
665  *     - ESP_ERR_INVALID_ARG    parameter error
666  */
667 esp_err_t mdns_query_aaaa(const char * host_name, uint32_t timeout, esp_ip6_addr_t * addr);
668 #endif
669 
670 /**
671  * @brief   System event handler
672  *          This method controls the service state on all active interfaces and applications are required
673  *          to call it from the system event handler for normal operation of mDNS service.
674  *
675  * Please note that hostname must not contain domain name, as mDNS uses '.local' domain.
676  *
677  * @param  ctx          The system event context
678  * @param  event        The system event
679  */
680 esp_err_t mdns_handle_system_event(void *ctx, system_event_t *event) __attribute__((deprecated));
681 
682 #ifdef __cplusplus
683 }
684 #endif
685 
686 #endif /* ESP_MDNS_H_ */
687