kopia lustrzana https://github.com/espressif/esp-idf
fix(mdns): add the maximum number of services
rodzic
41095f8466
commit
ba458c69cf
|
@ -0,0 +1,13 @@
|
|||
menu "mDNS"
|
||||
|
||||
config MDNS_MAX_SERVICES
|
||||
int "Max number of services"
|
||||
range 1 64
|
||||
default 10
|
||||
help
|
||||
Services take up a certain amount of memory, and allowing fewer
|
||||
services to be open at the same time conserves memory. Specify
|
||||
the maximum amount of services here. The valid value is from 1
|
||||
to 64.
|
||||
|
||||
endmenu
|
|
@ -96,6 +96,21 @@ static mdns_srv_item_t * _mdns_get_service_item(const char * service, const char
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static bool _mdns_can_add_more_services(void)
|
||||
{
|
||||
mdns_srv_item_t * s = _mdns_server->services;
|
||||
uint16_t service_num = 0;
|
||||
while (s) {
|
||||
service_num ++;
|
||||
s = s->next;
|
||||
if (service_num >= MDNS_MAX_SERVICES) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
esp_err_t _mdns_send_rx_action(mdns_rx_packet_t * packet)
|
||||
{
|
||||
mdns_action_t * action = NULL;
|
||||
|
@ -4124,6 +4139,11 @@ esp_err_t mdns_service_add(const char * instance, const char * service, const ch
|
|||
if (!_mdns_server || _str_null_or_empty(service) || _str_null_or_empty(proto) || !port) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!_mdns_can_add_more_services()) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
mdns_srv_item_t * item = _mdns_get_service_item(service, proto);
|
||||
if (item) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#define _mdns_dbg_printf(...) printf(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
/** The maximum number of services */
|
||||
#define MDNS_MAX_SERVICES CONFIG_MDNS_MAX_SERVICES
|
||||
|
||||
#define MDNS_ANSWER_PTR_TTL 4500
|
||||
#define MDNS_ANSWER_TXT_TTL 4500
|
||||
#define MDNS_ANSWER_SRV_TTL 120
|
||||
|
|
Ładowanie…
Reference in New Issue