--- /dev/null
+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
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;
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;
#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