Skip to content

Commit 2ddaee2

Browse files
gjc13suren-gabrielyan-espressif
authored andcommitted
mdns: allow explicit txt value length
* Original commit: espressif/esp-idf@b4e0088
1 parent 73b1763 commit 2ddaee2

File tree

4 files changed

+140
-31
lines changed

4 files changed

+140
-31
lines changed

components/mdns/include/mdns.h

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ typedef struct mdns_result_s {
7979
uint16_t port; /*!< service port */
8080
// TXT
8181
mdns_txt_item_t * txt; /*!< txt record */
82+
uint8_t *txt_value_len; /*!< array of txt value len of each record */
8283
size_t txt_count; /*!< number of txt items */
8384
// A and AAAA
8485
mdns_ip_addr_t * addr; /*!< linked list of IP addresses found */
@@ -173,6 +174,8 @@ esp_err_t mdns_instance_name_set(const char * instance_name);
173174
/**
174175
* @brief Add service to mDNS server
175176
*
177+
* @note The value length of txt items will be automatically decided by strlen
178+
*
176179
* @param instance_name instance name to set. If NULL,
177180
* global instance name or hostname will be used
178181
* @param service_type service type (_http, _ftp, etc)
@@ -189,10 +192,11 @@ esp_err_t mdns_instance_name_set(const char * instance_name);
189192
*/
190193
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);
191194

192-
193195
/**
194196
* @brief Add service to mDNS server with a delegated hostname
195197
*
198+
* @note The value length of txt items will be automatically decided by strlen
199+
*
196200
* @param instance_name instance name to set. If NULL,
197201
* global instance name or hostname will be used
198202
* @param service_type service type (_http, _ftp, etc)
@@ -321,6 +325,8 @@ esp_err_t mdns_service_port_set_for_host(const char * service_type, const char *
321325
/**
322326
* @brief Replace all TXT items for service
323327
*
328+
* @note The value length of txt items will be automatically decided by strlen
329+
*
324330
* @param service_type service type (_http, _ftp, etc)
325331
* @param proto service protocol (_tcp, _udp)
326332
* @param txt array of TXT data (eg. {{"var","val"},{"other","2"}})
@@ -337,6 +343,8 @@ esp_err_t mdns_service_txt_set(const char * service_type, const char * proto, md
337343
/**
338344
* @brief Replace all TXT items for service with hostname
339345
*
346+
* @note The value length of txt items will be automatically decided by strlen
347+
*
340348
* @param service_type service type (_http, _ftp, etc)
341349
* @param proto service protocol (_tcp, _udp)
342350
* @param hostname service hostname. If NULL, local hostname will be used.
@@ -355,6 +363,8 @@ esp_err_t mdns_service_txt_set_for_host(const char * service_type, const char *
355363
/**
356364
* @brief Set/Add TXT item for service TXT record
357365
*
366+
* @note The value length will be automatically decided by strlen
367+
*
358368
* @param service_type service type (_http, _ftp, etc)
359369
* @param proto service protocol (_tcp, _udp)
360370
* @param key the key that you want to add/update
@@ -368,10 +378,29 @@ esp_err_t mdns_service_txt_set_for_host(const char * service_type, const char *
368378
*/
369379
esp_err_t mdns_service_txt_item_set(const char * service_type, const char * proto, const char * key, const char * value);
370380

381+
/**
382+
* @brief Set/Add TXT item for service TXT record
383+
*
384+
* @param service_type service type (_http, _ftp, etc)
385+
* @param proto service protocol (_tcp, _udp)
386+
* @param key the key that you want to add/update
387+
* @param value the new value of the key
388+
* @param value_len the length of the value
389+
*
390+
* @return
391+
* - ESP_OK success
392+
* - ESP_ERR_INVALID_ARG Parameter error
393+
* - ESP_ERR_NOT_FOUND Service not found
394+
* - ESP_ERR_NO_MEM memory error
395+
*/
396+
esp_err_t mdns_service_txt_item_set_with_explicit_value_len(const char *service_type, const char *proto,
397+
const char *key, const char *value, uint8_t value_len);
371398

372399
/**
373400
* @brief Set/Add TXT item for service TXT record with hostname
374401
*
402+
* @note The value length will be automatically decided by strlen
403+
*
375404
* @param service_type service type (_http, _ftp, etc)
376405
* @param proto service protocol (_tcp, _udp)
377406
* @param hostname service hostname. If NULL, local hostname will be used.
@@ -387,6 +416,26 @@ esp_err_t mdns_service_txt_item_set(const char * service_type, const char * prot
387416
esp_err_t mdns_service_txt_item_set_for_host(const char * service_type, const char * proto, const char * hostname,
388417
const char * key, const char * value);
389418

419+
/**
420+
* @brief Set/Add TXT item for service TXT record with hostname and txt value length
421+
*
422+
* @param service_type service type (_http, _ftp, etc)
423+
* @param proto service protocol (_tcp, _udp)
424+
* @param hostname service hostname. If NULL, local hostname will be used.
425+
* @param key the key that you want to add/update
426+
* @param value the new value of the key
427+
* @param value_len the length of the value
428+
*
429+
* @return
430+
* - ESP_OK success
431+
* - ESP_ERR_INVALID_ARG Parameter error
432+
* - ESP_ERR_NOT_FOUND Service not found
433+
* - ESP_ERR_NO_MEM memory error
434+
*/
435+
esp_err_t mdns_service_txt_item_set_for_host_with_explicit_value_len(const char *service_type, const char *proto,
436+
const char *hostname, const char *key,
437+
const char *value, uint8_t value_len);
438+
390439
/**
391440
* @brief Remove TXT item for service TXT record
392441
*

0 commit comments

Comments
 (0)