forked from espressif/esp-protocols
fix(mdns): remove the the range of MDNS_MAX_SERVICES and fix issues of string functions
This commit is contained in:
@ -10,13 +10,11 @@ menu "mDNS"
|
|||||||
|
|
||||||
config MDNS_MAX_SERVICES
|
config MDNS_MAX_SERVICES
|
||||||
int "Max number of services"
|
int "Max number of services"
|
||||||
range 1 64
|
|
||||||
default 10
|
default 10
|
||||||
help
|
help
|
||||||
Services take up a certain amount of memory, and allowing fewer
|
Services take up a certain amount of memory, and allowing fewer
|
||||||
services to be open at the same time conserves memory. Specify
|
services to be open at the same time conserves memory. Specify
|
||||||
the maximum amount of services here. The valid value is from 1
|
the maximum amount of services here.
|
||||||
to 64.
|
|
||||||
|
|
||||||
config MDNS_TASK_PRIORITY
|
config MDNS_TASK_PRIORITY
|
||||||
int "mDNS task priority"
|
int "mDNS task priority"
|
||||||
|
@ -5595,9 +5595,14 @@ esp_err_t mdns_hostname_set(const char *hostname)
|
|||||||
|
|
||||||
esp_err_t mdns_hostname_get(char *hostname)
|
esp_err_t mdns_hostname_get(char *hostname)
|
||||||
{
|
{
|
||||||
if (!_mdns_server || !hostname) {
|
if (!hostname) {
|
||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_mdns_server || !_mdns_server->hostname) {
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
MDNS_SERVICE_LOCK();
|
MDNS_SERVICE_LOCK();
|
||||||
strncpy(hostname, _mdns_server->hostname, strnlen(_mdns_server->hostname, MDNS_NAME_BUF_LEN));
|
strncpy(hostname, _mdns_server->hostname, strnlen(_mdns_server->hostname, MDNS_NAME_BUF_LEN));
|
||||||
MDNS_SERVICE_UNLOCK();
|
MDNS_SERVICE_UNLOCK();
|
||||||
@ -5900,10 +5905,14 @@ static mdns_result_t *_mdns_lookup_service(const char *instance, const char *ser
|
|||||||
item->esp_netif = NULL;
|
item->esp_netif = NULL;
|
||||||
item->ttl = _str_null_or_empty(instance) ? MDNS_ANSWER_PTR_TTL : MDNS_ANSWER_SRV_TTL;
|
item->ttl = _str_null_or_empty(instance) ? MDNS_ANSWER_PTR_TTL : MDNS_ANSWER_SRV_TTL;
|
||||||
item->ip_protocol = MDNS_IP_PROTOCOL_MAX;
|
item->ip_protocol = MDNS_IP_PROTOCOL_MAX;
|
||||||
item->instance_name = strndup(srv->instance, MDNS_NAME_BUF_LEN - 1);
|
if (srv->instance) {
|
||||||
if (!item->instance_name) {
|
item->instance_name = strndup(srv->instance, MDNS_NAME_BUF_LEN - 1);
|
||||||
HOOK_MALLOC_FAILED;
|
if (!item->instance_name) {
|
||||||
goto handle_error;
|
HOOK_MALLOC_FAILED;
|
||||||
|
goto handle_error;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
item->instance_name = NULL;
|
||||||
}
|
}
|
||||||
item->service_type = strndup(srv->service, MDNS_NAME_BUF_LEN - 1);
|
item->service_type = strndup(srv->service, MDNS_NAME_BUF_LEN - 1);
|
||||||
if (!item->service_type) {
|
if (!item->service_type) {
|
||||||
|
Reference in New Issue
Block a user