mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-04 06:06:45 +02:00
Compare commits
28 Commits
sock_utils
...
mdns-v1.5.
Author | SHA1 | Date | |
---|---|---|---|
a83f1b6787 | |||
84caca465d | |||
8f81478fff | |||
ae5a8ceeda | |||
774bab22ea | |||
265e38d684 | |||
93f772171c | |||
4ad88e297f | |||
196198ecc9 | |||
e838bf03f4 | |||
99b54ac384 | |||
f5be2f4115 | |||
9b74256b51 | |||
3d8835cfb9 | |||
24f55ce9b4 | |||
8f8516cc3f | |||
75a8e8640a | |||
907087c09b | |||
68a9e14898 | |||
827ea65fd5 | |||
9537721600 | |||
4394f845fc | |||
9b0ba6060f | |||
7c6a3098af | |||
f3f3e23bec | |||
9ed835ba3f | |||
f12a205657 | |||
5bd82c01a5 |
1
.github/workflows/mosq__build.yml
vendored
1
.github/workflows/mosq__build.yml
vendored
@ -75,6 +75,7 @@ jobs:
|
||||
done
|
||||
|
||||
check_consistency:
|
||||
if: contains(github.event.pull_request.labels.*.name, 'mosquitto') || github.event_name == 'push'
|
||||
name: Checks that API docs and versions are consistent
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -3,6 +3,6 @@ commitizen:
|
||||
bump_message: 'bump(mdns): $current_version -> $new_version'
|
||||
pre_bump_hooks: python ../../ci/changelog.py mdns
|
||||
tag_format: mdns-v$version
|
||||
version: 1.4.2
|
||||
version: 1.5.0
|
||||
version_files:
|
||||
- idf_component.yml
|
||||
|
@ -1,5 +1,32 @@
|
||||
# Changelog
|
||||
|
||||
## [1.5.0](https://github.com/espressif/esp-protocols/commits/mdns-v1.5.0)
|
||||
|
||||
### Features
|
||||
|
||||
- supported removal of subtype when updating service ([4ad88e29](https://github.com/espressif/esp-protocols/commit/4ad88e29))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fix zero-sized VLA clang-tidy warnings ([196198ec](https://github.com/espressif/esp-protocols/commit/196198ec))
|
||||
- Remove dead store to arg variable shared ([e838bf03](https://github.com/espressif/esp-protocols/commit/e838bf03))
|
||||
- Fix name mangling not to use strcpy() ([99b54ac3](https://github.com/espressif/esp-protocols/commit/99b54ac3))
|
||||
- Fix potential null derefernce in _mdns_execute_action() ([f5be2f41](https://github.com/espressif/esp-protocols/commit/f5be2f41))
|
||||
- Fix AFL test mock per espressif/esp-idf@a5bc08fb55c ([3d8835cf](https://github.com/espressif/esp-protocols/commit/3d8835cf))
|
||||
- Fixed potential out-of-bound interface error ([24f55ce9](https://github.com/espressif/esp-protocols/commit/24f55ce9))
|
||||
- Fixed incorrect error conversion ([8f8516cc](https://github.com/espressif/esp-protocols/commit/8f8516cc))
|
||||
- Fixed potential overflow when allocating txt data ([75a8e864](https://github.com/espressif/esp-protocols/commit/75a8e864))
|
||||
- Move MDNS_NAME_BUF_LEN to public headers ([907087c0](https://github.com/espressif/esp-protocols/commit/907087c0), [#724](https://github.com/espressif/esp-protocols/issues/724))
|
||||
- Cleanup includes in mdns.c ([68a9e148](https://github.com/espressif/esp-protocols/commit/68a9e148), [#725](https://github.com/espressif/esp-protocols/issues/725))
|
||||
- Allow advertizing service with port==0 ([827ea65f](https://github.com/espressif/esp-protocols/commit/827ea65f))
|
||||
- Fixed complier warning if MDNS_MAX_SERVICES==0 ([95377216](https://github.com/espressif/esp-protocols/commit/95377216), [#611](https://github.com/espressif/esp-protocols/issues/611))
|
||||
|
||||
## [1.4.3](https://github.com/espressif/esp-protocols/commits/mdns-v1.4.3)
|
||||
|
||||
### Features
|
||||
|
||||
- support zero item when update subtype ([5bd82c01](https://github.com/espressif/esp-protocols/commit/5bd82c01))
|
||||
|
||||
## [1.4.2](https://github.com/espressif/esp-protocols/commits/mdns-v1.4.2)
|
||||
|
||||
### Features
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: "1.4.2"
|
||||
version: "1.5.0"
|
||||
description: "Multicast UDP service used to provide local network service and host discovery."
|
||||
url: "https://github.com/espressif/esp-protocols/tree/master/components/mdns"
|
||||
issues: "https://github.com/espressif/esp-protocols/issues"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -10,6 +10,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include <esp_netif.h>
|
||||
|
||||
#define MDNS_TYPE_A 0x0001
|
||||
@ -21,6 +22,13 @@ extern "C" {
|
||||
#define MDNS_TYPE_NSEC 0x002F
|
||||
#define MDNS_TYPE_ANY 0x00FF
|
||||
|
||||
#if defined(CONFIG_LWIP_IPV6) && defined(CONFIG_MDNS_RESPOND_REVERSE_QUERIES)
|
||||
#define MDNS_NAME_MAX_LEN (64+4) // Need to account for IPv6 reverse queries (64 char address + ".ip6" )
|
||||
#else
|
||||
#define MDNS_NAME_MAX_LEN 64 // Maximum string length of hostname, instance, service and proto
|
||||
#endif
|
||||
#define MDNS_NAME_BUF_LEN (MDNS_NAME_MAX_LEN+1) // Maximum char buffer size to hold hostname, instance, service or proto
|
||||
|
||||
/**
|
||||
* @brief Asynchronous query handle
|
||||
*/
|
||||
@ -615,6 +623,8 @@ esp_err_t mdns_service_subtype_add_multiple_items_for_host(const char *instance_
|
||||
* @param subtype the pointer of subtype array to add.
|
||||
* @param num_items number of items in subtype array
|
||||
*
|
||||
* @note If `num_items` is 0, then remove all subtypes.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_random.h"
|
||||
#include "esp_check.h"
|
||||
#include "mdns.h"
|
||||
#include "mdns_private.h"
|
||||
#include "mdns_networking.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_random.h"
|
||||
#include "esp_check.h"
|
||||
|
||||
static void _mdns_browse_item_free(mdns_browse_t *browse);
|
||||
static esp_err_t _mdns_send_browse_action(mdns_action_type_t type, mdns_browse_t *browse);
|
||||
@ -255,12 +253,13 @@ static char *_mdns_mangle_name(char *in)
|
||||
}
|
||||
sprintf(ret, "%s-2", in);
|
||||
} else {
|
||||
ret = malloc(strlen(in) + 2); //one extra byte in case 9-10 or 99-100 etc
|
||||
size_t in_len = strlen(in);
|
||||
ret = malloc(in_len + 2); //one extra byte in case 9-10 or 99-100 etc
|
||||
if (ret == NULL) {
|
||||
HOOK_MALLOC_FAILED;
|
||||
return NULL;
|
||||
}
|
||||
strcpy(ret, in);
|
||||
memcpy(ret, in, in_len);
|
||||
int baseLen = p - in; //length of 'bla' in 'bla-123'
|
||||
//overwrite suffix with new suffix
|
||||
sprintf(ret + baseLen, "-%d", suffix + 1);
|
||||
@ -334,6 +333,9 @@ static mdns_host_item_t *mdns_get_host_item(const char *hostname)
|
||||
|
||||
static bool _mdns_can_add_more_services(void)
|
||||
{
|
||||
#if MDNS_MAX_SERVICES == 0
|
||||
return false;
|
||||
#else
|
||||
mdns_srv_item_t *s = _mdns_server->services;
|
||||
uint16_t service_num = 0;
|
||||
while (s) {
|
||||
@ -343,8 +345,8 @@ static bool _mdns_can_add_more_services(void)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_err_t _mdns_send_rx_action(mdns_rx_packet_t *packet)
|
||||
@ -1810,7 +1812,6 @@ static bool _mdns_create_answer_from_service(mdns_tx_packet_t *packet, mdns_serv
|
||||
return false;
|
||||
}
|
||||
} else if (question->type == MDNS_TYPE_SDPTR) {
|
||||
shared = true;
|
||||
if (!_mdns_alloc_answer(&packet->answers, MDNS_TYPE_SDPTR, service, NULL, false, false)) {
|
||||
return false;
|
||||
}
|
||||
@ -2354,6 +2355,11 @@ static void _mdns_restart_pcb(mdns_if_t tcpip_if, mdns_ip_protocol_t ip_protocol
|
||||
srv_count++;
|
||||
a = a->next;
|
||||
}
|
||||
if (srv_count == 0) {
|
||||
// proble only IP
|
||||
_mdns_init_pcb_probe(tcpip_if, ip_protocol, NULL, 0, true);
|
||||
return;
|
||||
}
|
||||
mdns_srv_item_t *services[srv_count];
|
||||
size_t i = 0;
|
||||
a = _mdns_server->services;
|
||||
@ -2383,6 +2389,53 @@ static void _mdns_send_bye(mdns_srv_item_t **services, size_t len, bool include_
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Send bye for particular subtypes
|
||||
*/
|
||||
static void _mdns_send_bye_subtype(mdns_srv_item_t *service, const char *instance_name, mdns_subtype_t *remove_subtypes)
|
||||
{
|
||||
uint8_t i, j;
|
||||
for (i = 0; i < MDNS_MAX_INTERFACES; i++) {
|
||||
for (j = 0; j < MDNS_IP_PROTOCOL_MAX; j++) {
|
||||
if (mdns_is_netif_ready(i, j)) {
|
||||
mdns_tx_packet_t *packet = _mdns_alloc_packet_default((mdns_if_t)i, (mdns_ip_protocol_t)j);
|
||||
packet->flags = MDNS_FLAGS_QR_AUTHORITATIVE;
|
||||
if (!_mdns_alloc_answer(&packet->answers, MDNS_TYPE_PTR, service->service, NULL, true, true)) {
|
||||
_mdns_free_tx_packet(packet);
|
||||
return;
|
||||
}
|
||||
|
||||
static uint8_t pkt[MDNS_MAX_PACKET_SIZE];
|
||||
uint16_t index = MDNS_HEAD_LEN;
|
||||
memset(pkt, 0, MDNS_HEAD_LEN);
|
||||
mdns_out_answer_t *a;
|
||||
uint8_t count;
|
||||
|
||||
_mdns_set_u16(pkt, MDNS_HEAD_FLAGS_OFFSET, packet->flags);
|
||||
_mdns_set_u16(pkt, MDNS_HEAD_ID_OFFSET, packet->id);
|
||||
|
||||
count = 0;
|
||||
a = packet->answers;
|
||||
while (a) {
|
||||
if (a->type == MDNS_TYPE_PTR && a->service) {
|
||||
const mdns_subtype_t *current_subtype = remove_subtypes;
|
||||
while (current_subtype) {
|
||||
count += (_mdns_append_subtype_ptr_record(pkt, &index, instance_name, current_subtype->subtype, a->service->service, a->service->proto, a->flush, a->bye) > 0);
|
||||
current_subtype = current_subtype->next;
|
||||
}
|
||||
}
|
||||
a = a->next;
|
||||
}
|
||||
_mdns_set_u16(pkt, MDNS_HEAD_ANSWERS_OFFSET, count);
|
||||
|
||||
_mdns_udp_pcb_write(packet->tcpip_if, packet->ip_protocol, &packet->dst, packet->port, pkt, index);
|
||||
|
||||
_mdns_free_tx_packet(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Send announcement on particular PCB
|
||||
*/
|
||||
@ -2554,6 +2607,10 @@ static void _mdns_restart_all_pcbs(void)
|
||||
srv_count++;
|
||||
a = a->next;
|
||||
}
|
||||
if (srv_count == 0) {
|
||||
_mdns_probe_all_pcbs(NULL, 0, true, true);
|
||||
return;
|
||||
}
|
||||
mdns_srv_item_t *services[srv_count];
|
||||
size_t l = 0;
|
||||
a = _mdns_server->services;
|
||||
@ -2794,14 +2851,20 @@ static void _mdns_remove_scheduled_service_packets(mdns_service_t *service)
|
||||
}
|
||||
}
|
||||
|
||||
static void _mdns_free_subtype(mdns_subtype_t *subtype)
|
||||
{
|
||||
while (subtype) {
|
||||
mdns_subtype_t *next = subtype->next;
|
||||
free((char *)subtype->subtype);
|
||||
free(subtype);
|
||||
subtype = next;
|
||||
}
|
||||
}
|
||||
|
||||
static void _mdns_free_service_subtype(mdns_service_t *service)
|
||||
{
|
||||
while (service->subtype) {
|
||||
mdns_subtype_t *next = service->subtype->next;
|
||||
free((char *)service->subtype->subtype);
|
||||
free(service->subtype);
|
||||
service->subtype = next;
|
||||
}
|
||||
_mdns_free_subtype(service->subtype);
|
||||
service->subtype = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2897,11 +2960,12 @@ static int _mdns_check_srv_collision(mdns_service_t *service, uint16_t priority,
|
||||
static int _mdns_check_txt_collision(mdns_service_t *service, const uint8_t *data, size_t len)
|
||||
{
|
||||
size_t data_len = 0;
|
||||
if (len == 1 && service->txt) {
|
||||
if (len <= 1 && service->txt) { // len==0 means incorrect packet (and handled by the packet parser)
|
||||
// but handled here again to fix clang-tidy warning on VLA "uint8_t our[0];"
|
||||
return -1;//we win
|
||||
} else if (len > 1 && !service->txt) {
|
||||
return 1;//they win
|
||||
} else if (len == 1 && !service->txt) {
|
||||
} else if (len <= 1 && !service->txt) {
|
||||
return 0;//same
|
||||
}
|
||||
|
||||
@ -3485,8 +3549,9 @@ static void _mdns_result_txt_create(const uint8_t *data, size_t len, mdns_txt_it
|
||||
uint16_t i = 0, y;
|
||||
size_t partLen = 0;
|
||||
int num_items = _mdns_txt_items_count_get(data, len);
|
||||
if (num_items < 0) {
|
||||
return;//error
|
||||
if (num_items < 0 || num_items > SIZE_MAX / sizeof(mdns_txt_item_t)) {
|
||||
// Error: num_items is incorrect (or too large to allocate)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!num_items) {
|
||||
@ -3786,7 +3851,7 @@ void mdns_parse_packet(mdns_rx_packet_t *packet)
|
||||
mdns_class &= 0x7FFF;
|
||||
|
||||
content = data_ptr + data_len;
|
||||
if (content > (data + len)) {
|
||||
if (content > (data + len) || data_len == 0) {
|
||||
goto clear_rx_packet;
|
||||
}
|
||||
|
||||
@ -4269,15 +4334,10 @@ clear_rx_packet:
|
||||
free(record);
|
||||
}
|
||||
free(parsed_packet);
|
||||
if (browse_result_instance) {
|
||||
free(browse_result_instance);
|
||||
}
|
||||
if (browse_result_service) {
|
||||
free(browse_result_service);
|
||||
}
|
||||
if (browse_result_proto) {
|
||||
free(browse_result_proto);
|
||||
}
|
||||
free(browse_result_instance);
|
||||
free(browse_result_service);
|
||||
free(browse_result_proto);
|
||||
free(out_sync_browse);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4477,10 +4537,11 @@ void mdns_preset_if_handle_system_event(void *arg, esp_event_base_t event_base,
|
||||
case IP_EVENT_GOT_IP6: {
|
||||
ip_event_got_ip6_t *event = (ip_event_got_ip6_t *) event_data;
|
||||
mdns_if_t mdns_if = _mdns_get_if_from_esp_netif(event->esp_netif);
|
||||
if (mdns_if < MDNS_MAX_INTERFACES) {
|
||||
post_mdns_enable_pcb(mdns_if, MDNS_IP_PROTOCOL_V6);
|
||||
post_mdns_announce_pcb(mdns_if, MDNS_IP_PROTOCOL_V4);
|
||||
if (mdns_if >= MDNS_MAX_INTERFACES) {
|
||||
return;
|
||||
}
|
||||
post_mdns_enable_pcb(mdns_if, MDNS_IP_PROTOCOL_V6);
|
||||
post_mdns_announce_pcb(mdns_if, MDNS_IP_PROTOCOL_V4);
|
||||
mdns_browse_t *browse = _mdns_server->browse;
|
||||
while (browse) {
|
||||
_mdns_browse_send(browse, mdns_if);
|
||||
@ -5343,7 +5404,8 @@ static void _mdns_service_task(void *pvParameters)
|
||||
for (;;) {
|
||||
if (_mdns_server && _mdns_server->action_queue) {
|
||||
if (xQueueReceive(_mdns_server->action_queue, &a, portMAX_DELAY) == pdTRUE) {
|
||||
if (a && a->type == ACTION_TASK_STOP) {
|
||||
assert(a);
|
||||
if (a->type == ACTION_TASK_STOP) {
|
||||
break;
|
||||
}
|
||||
MDNS_SERVICE_LOCK();
|
||||
@ -5892,7 +5954,7 @@ esp_err_t mdns_instance_name_set(const char *instance)
|
||||
esp_err_t mdns_service_add_for_host(const char *instance, const char *service, const char *proto, const char *host,
|
||||
uint16_t port, mdns_txt_item_t txt[], size_t num_items)
|
||||
{
|
||||
if (!_mdns_server || _str_null_or_empty(service) || _str_null_or_empty(proto) || !port || !_mdns_server->hostname) {
|
||||
if (!_mdns_server || _str_null_or_empty(service) || _str_null_or_empty(proto) || !_mdns_server->hostname) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@ -5901,7 +5963,8 @@ esp_err_t mdns_service_add_for_host(const char *instance, const char *service, c
|
||||
const char *hostname = host ? host : _mdns_server->hostname;
|
||||
mdns_service_t *s = NULL;
|
||||
|
||||
ESP_GOTO_ON_FALSE(_mdns_can_add_more_services(), ESP_ERR_NO_MEM, err, TAG, "Cannot add more services");
|
||||
ESP_GOTO_ON_FALSE(_mdns_can_add_more_services(), ESP_ERR_NO_MEM, err, TAG,
|
||||
"Cannot add more services, please increase CONFIG_MDNS_MAX_SERVICES (%d)", CONFIG_MDNS_MAX_SERVICES);
|
||||
|
||||
mdns_srv_item_t *item = _mdns_get_service_item_instance(instance, service, proto, hostname);
|
||||
ESP_GOTO_ON_FALSE(!item, ESP_ERR_INVALID_ARG, err, TAG, "Service already exists");
|
||||
@ -6347,11 +6410,23 @@ esp_err_t mdns_service_subtype_remove_for_host(const char *instance_name, const
|
||||
ret = _mdns_service_subtype_remove_for_host(s, subtype);
|
||||
ESP_GOTO_ON_ERROR(ret, err, TAG, "Failed to remove the subtype: %s", subtype);
|
||||
|
||||
// TODO: Need to transmit a sendbye message for the removed subtype.
|
||||
// TODO: Need to remove this subtype answer from the scheduled answer list.
|
||||
// Transmit a sendbye message for the removed subtype.
|
||||
mdns_subtype_t *remove_subtypes = (mdns_subtype_t *)malloc(sizeof(mdns_subtype_t));
|
||||
ESP_GOTO_ON_FALSE(remove_subtypes, ESP_ERR_NO_MEM, out_of_mem, TAG, "Out of memory");
|
||||
remove_subtypes->subtype = strdup(subtype);
|
||||
ESP_GOTO_ON_FALSE(remove_subtypes->subtype, ESP_ERR_NO_MEM, out_of_mem, TAG, "Out of memory");
|
||||
remove_subtypes->next = NULL;
|
||||
|
||||
_mdns_send_bye_subtype(s, instance_name, remove_subtypes);
|
||||
_mdns_free_subtype(remove_subtypes);
|
||||
err:
|
||||
MDNS_SERVICE_UNLOCK();
|
||||
return ret;
|
||||
out_of_mem:
|
||||
HOOK_MALLOC_FAILED;
|
||||
free(remove_subtypes);
|
||||
MDNS_SERVICE_UNLOCK();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t _mdns_service_subtype_add_for_host(mdns_srv_item_t *service, const char *subtype)
|
||||
@ -6423,19 +6498,75 @@ esp_err_t mdns_service_subtype_add_for_host(const char *instance_name, const cha
|
||||
return mdns_service_subtype_add_multiple_items_for_host(instance_name, service_type, proto, hostname, _subtype, 1);
|
||||
}
|
||||
|
||||
static mdns_subtype_t *_mdns_service_find_subtype_needed_sendbye(mdns_service_t *service, mdns_subtype_item_t subtype[],
|
||||
uint8_t num_items)
|
||||
{
|
||||
if (!service) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mdns_subtype_t *current = service->subtype;
|
||||
mdns_subtype_t *prev = NULL;
|
||||
mdns_subtype_t *prev_goodbye = NULL;
|
||||
mdns_subtype_t *out_goodbye_subtype = NULL;
|
||||
|
||||
while (current) {
|
||||
bool subtype_in_update = false;
|
||||
|
||||
for (int i = 0; i < num_items; i++) {
|
||||
if (strcmp(subtype[i].subtype, current->subtype) == 0) {
|
||||
subtype_in_update = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!subtype_in_update) {
|
||||
// Remove from original list
|
||||
if (prev) {
|
||||
prev->next = current->next;
|
||||
} else {
|
||||
service->subtype = current->next;
|
||||
}
|
||||
|
||||
mdns_subtype_t *to_move = current;
|
||||
current = current->next;
|
||||
|
||||
// Add to goodbye list
|
||||
to_move->next = NULL;
|
||||
if (prev_goodbye) {
|
||||
prev_goodbye->next = to_move;
|
||||
} else {
|
||||
out_goodbye_subtype = to_move;
|
||||
}
|
||||
prev_goodbye = to_move;
|
||||
} else {
|
||||
prev = current;
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
|
||||
return out_goodbye_subtype;
|
||||
}
|
||||
|
||||
esp_err_t mdns_service_subtype_update_multiple_items_for_host(const char *instance_name, const char *service_type, const char *proto,
|
||||
const char *hostname, mdns_subtype_item_t subtype[], uint8_t num_items)
|
||||
{
|
||||
MDNS_SERVICE_LOCK();
|
||||
esp_err_t ret = ESP_OK;
|
||||
int cur_index = 0;
|
||||
ESP_GOTO_ON_FALSE(_mdns_server && _mdns_server->services && !_str_null_or_empty(service_type) && !_str_null_or_empty(proto) &&
|
||||
(num_items > 0), ESP_ERR_INVALID_ARG, err, TAG, "Invalid state or arguments");
|
||||
ESP_GOTO_ON_FALSE(_mdns_server && _mdns_server->services && !_str_null_or_empty(service_type) && !_str_null_or_empty(proto),
|
||||
ESP_ERR_INVALID_ARG, err, TAG, "Invalid state or arguments");
|
||||
|
||||
mdns_srv_item_t *s = _mdns_get_service_item_instance(instance_name, service_type, proto, hostname);
|
||||
ESP_GOTO_ON_FALSE(s, ESP_ERR_NOT_FOUND, err, TAG, "Service doesn't exist");
|
||||
|
||||
// TODO: find subtype needs to say sendbye
|
||||
mdns_subtype_t *goodbye_subtype = _mdns_service_find_subtype_needed_sendbye(s->service, subtype, num_items);
|
||||
|
||||
if (goodbye_subtype) {
|
||||
_mdns_send_bye_subtype(s, instance_name, goodbye_subtype);
|
||||
}
|
||||
|
||||
_mdns_free_subtype(goodbye_subtype);
|
||||
_mdns_free_service_subtype(s->service);
|
||||
|
||||
for (; cur_index < num_items; cur_index++) {
|
||||
@ -6450,8 +6581,9 @@ esp_err_t mdns_service_subtype_update_multiple_items_for_host(const char *instan
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
_mdns_announce_all_pcbs(&s, 1, false);
|
||||
if (num_items) {
|
||||
_mdns_announce_all_pcbs(&s, 1, false);
|
||||
}
|
||||
err:
|
||||
if (ret == ESP_ERR_NO_MEM) {
|
||||
for (int idx = 0; idx < cur_index; idx++) {
|
||||
|
@ -288,7 +288,7 @@ typedef struct {
|
||||
static err_t _mdns_pcb_init_api(struct tcpip_api_call_data *api_call_msg)
|
||||
{
|
||||
mdns_api_call_t *msg = (mdns_api_call_t *)api_call_msg;
|
||||
msg->err = _udp_pcb_init(msg->tcpip_if, msg->ip_protocol);
|
||||
msg->err = _udp_pcb_init(msg->tcpip_if, msg->ip_protocol) == ESP_OK ? ERR_OK : ERR_IF;
|
||||
return msg->err;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -103,12 +103,6 @@
|
||||
#define MDNS_PACKET_QUEUE_LEN 16 // Maximum packets that can be queued for parsing
|
||||
#define MDNS_ACTION_QUEUE_LEN CONFIG_MDNS_ACTION_QUEUE_LEN // Maximum actions pending to the server
|
||||
#define MDNS_TXT_MAX_LEN 1024 // Maximum string length of text data in TXT record
|
||||
#if defined(CONFIG_LWIP_IPV6) && defined(CONFIG_MDNS_RESPOND_REVERSE_QUERIES)
|
||||
#define MDNS_NAME_MAX_LEN (64+4) // Need to account for IPv6 reverse queries (64 char address + ".ip6" )
|
||||
#else
|
||||
#define MDNS_NAME_MAX_LEN 64 // Maximum string length of hostname, instance, service and proto
|
||||
#endif
|
||||
#define MDNS_NAME_BUF_LEN (MDNS_NAME_MAX_LEN+1) // Maximum char buffer size to hold hostname, instance, service or proto
|
||||
#define MDNS_MAX_PACKET_SIZE 1460 // Maximum size of mDNS outgoing packet
|
||||
|
||||
#define MDNS_HEAD_LEN 12
|
||||
|
@ -117,6 +117,10 @@ void esp_log_write(esp_log_level_t level, const char *tag, const char *format, .
|
||||
{
|
||||
}
|
||||
|
||||
void esp_log(esp_log_config_t config, const char *tag, const char *format, ...)
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t esp_log_timestamp(void)
|
||||
{
|
||||
return 0;
|
||||
|
@ -3,6 +3,6 @@ commitizen:
|
||||
bump_message: 'bump(sockutls): $current_version -> $new_version'
|
||||
pre_bump_hooks: python ../../ci/changelog.py sock_utils
|
||||
tag_format: sock_utils-v$version
|
||||
version: 0.2.1
|
||||
version: 0.2.2
|
||||
version_files:
|
||||
- idf_component.yml
|
||||
|
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## [0.2.2](https://github.com/espressif/esp-protocols/commits/sock_utils-v0.2.2)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fix gai_strerror() impl to return const string ([f12a2056](https://github.com/espressif/esp-protocols/commit/f12a2056))
|
||||
|
||||
## [0.2.1](https://github.com/espressif/esp-protocols/commits/sock_utils-v0.2.1)
|
||||
|
||||
### Bug Fixes
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: 0.2.1
|
||||
version: 0.2.2
|
||||
description: The component provides helper implementation of common system/socket utilities
|
||||
url: https://github.com/espressif/esp-protocols/tree/master/components/sock_utils
|
||||
dependencies:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -18,13 +18,14 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Returns a numeric string representing of `getaddrinfo()` error code.
|
||||
* @brief Returns a string representing of `getaddrinfo()` error code.
|
||||
*
|
||||
* @param[in] ecode Error code returned by `getaddrinfo()`.
|
||||
* @param[in] errcode Error code returned by `getaddrinfo()`.
|
||||
*
|
||||
* @return A pointer to a string describing the error.
|
||||
* @return A pointer to a string containing the error code, for example "EAI_NONAME"
|
||||
* for EAI_NONAME error type.
|
||||
*/
|
||||
const char *gai_strerror(int ecode);
|
||||
const char *gai_strerror(int errcode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,17 +1,36 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "gai_strerror.h"
|
||||
#include "lwip/netdb.h"
|
||||
|
||||
_Thread_local char gai_strerror_string[32];
|
||||
#define HANDLE_GAI_ERROR(code) \
|
||||
case code: return #code;
|
||||
|
||||
const char *gai_strerror(int ecode)
|
||||
const char *gai_strerror(int errcode)
|
||||
{
|
||||
if (snprintf(gai_strerror_string, sizeof(gai_strerror_string), "EAI error:%d", ecode) < 0) {
|
||||
return "gai_strerror() failed";
|
||||
switch (errcode) {
|
||||
/* lwip defined DNS codes */
|
||||
HANDLE_GAI_ERROR(EAI_BADFLAGS)
|
||||
HANDLE_GAI_ERROR(EAI_FAIL)
|
||||
HANDLE_GAI_ERROR(EAI_FAMILY)
|
||||
HANDLE_GAI_ERROR(EAI_MEMORY)
|
||||
HANDLE_GAI_ERROR(EAI_NONAME)
|
||||
HANDLE_GAI_ERROR(EAI_SERVICE)
|
||||
/* other error codes optionally defined in platform/newlib or toolchain */
|
||||
#ifdef EAI_AGAIN
|
||||
HANDLE_GAI_ERROR(EAI_AGAIN)
|
||||
#endif
|
||||
#ifdef EAI_SOCKTYPE
|
||||
HANDLE_GAI_ERROR(EAI_SOCKTYPE)
|
||||
#endif
|
||||
#ifdef EAI_SYSTEM
|
||||
HANDLE_GAI_ERROR(EAI_SYSTEM)
|
||||
#endif
|
||||
default:
|
||||
return "Unknown error";
|
||||
}
|
||||
return gai_strerror_string;
|
||||
}
|
||||
|
@ -1,8 +1 @@
|
||||
sphinxcontrib-applehelp==1.0.4
|
||||
sphinxcontrib_devhelp==1.0.2
|
||||
sphinxcontrib-htmlhelp==2.0.1
|
||||
sphinxcontrib-serializinghtml==1.1.5
|
||||
sphinxcontrib-qthelp==1.0.3
|
||||
breathe==4.35
|
||||
recommonmark==0.7.1
|
||||
esp-docs==1.7.1
|
||||
esp-docs>=2.0.0
|
||||
|
Reference in New Issue
Block a user