feat(mdns): Add APIs for looking up self hosted services and getting the self hostname

This commit is contained in:
WanqQixiang
2023-05-18 12:22:21 +08:00
parent 441f79022e
commit f0df12dad3
3 changed files with 93 additions and 7 deletions

View File

@ -128,6 +128,19 @@ void mdns_free(void);
*/
esp_err_t mdns_hostname_set(const char *hostname);
/**
* @brief Get the hostname for mDNS server
*
* @param hostname pointer to the hostname, it should be allocated
* and hold at least MDNS_NAME_BUF_LEN chars
*
* @return
* - ESP_OK success
* - ESP_ERR_INVALID_ARG Parameter error
* - ESP_ERR_INVALID_STATE when mdns is not initialized
*/
esp_err_t mdns_hostname_get(char *hostname);
/**
* @brief Adds a hostname and address to be delegated
* A/AAAA queries will be replied for the hostname and
@ -703,6 +716,24 @@ esp_err_t mdns_query_txt(const char *instance_name, const char *service_type, co
esp_err_t mdns_lookup_delegated_service(const char *instance, const char *service_type, const char *proto, size_t max_results,
mdns_result_t **result);
/**
* @brief Look up self hosted services.
*
* @param instance instance name (NULL for uncertain instance)
* @param service_type service type (_http, _ftp, etc)
* @param proto service protocol (_tcp, _udp)
* @param max_results maximum results to be collected
* @param result pointer to the result of the search
*
* @return
* - ESP_OK success
* - ESP_ERR_INVALID_STATE mDNS is not running
* - ESP_ERR_NO_MEM memory error
* - ESP_ERR_INVALID_ARG parameter error
*/
esp_err_t mdns_lookup_selfhosted_service(const char *instance, const char *service_type, const char *proto, size_t max_results,
mdns_result_t **result);
/**
* @brief Query mDNS for A record
*