Skip to content

Commit eb12d05

Browse files
authored
Merge pull request #773 from david-cermak/fix/mdns_add_version_macro
[mdns]: Bump 1.7.0 -> 1.8.0
2 parents 37f84ee + 520b819 commit eb12d05

File tree

12 files changed

+96
-82
lines changed

12 files changed

+96
-82
lines changed

.github/workflows/clang-tidy.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ on:
99
jobs:
1010
build:
1111
name: Run clang-tidy
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-22.04
1313
container: espressif/idf:latest
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
with:
1717
submodules: 'true'
1818
- name: Install esp-clang
@@ -50,7 +50,7 @@ jobs:
5050
results.sarif
5151
results.sarif.raw
5252
- name: Upload SARIF file
53-
uses: github/codeql-action/upload-sarif@v2
53+
uses: github/codeql-action/upload-sarif@v3
5454
with:
5555
sarif_file: results.sarif
5656
category: clang-tidy

components/mdns/.cz.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ commitizen:
33
bump_message: 'bump(mdns): $current_version -> $new_version'
44
pre_bump_hooks: python ../../ci/changelog.py mdns
55
tag_format: mdns-v$version
6-
version: 1.7.0
6+
version: 1.8.0
77
version_files:
88
- idf_component.yml

components/mdns/CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## [1.8.0](https://github.com/espressif/esp-protocols/commits/mdns-v1.8.0)
4+
5+
### Features
6+
7+
- Add version keys ([e01e67e7](https://github.com/espressif/esp-protocols/commit/e01e67e7))
8+
9+
### Bug Fixes
10+
11+
- Reformat mdns sources per indent-cont=120 ([c7663cde](https://github.com/espressif/esp-protocols/commit/c7663cde))
12+
313
## [1.7.0](https://github.com/espressif/esp-protocols/commits/mdns-v1.7.0)
414

515
### Features

components/mdns/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ if(${target} STREQUAL "linux")
3434
target_link_libraries(${COMPONENT_LIB} PRIVATE "-lbsd")
3535
endif()
3636

37-
3837
if(CONFIG_ETH_ENABLED)
3938
idf_component_optional_requires(PRIVATE esp_eth)
4039
endif()
40+
41+
idf_component_get_property(MDNS_VERSION ${COMPONENT_NAME} COMPONENT_VERSION)
42+
target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DESP_MDNS_VERSION_NUMBER=\"${MDNS_VERSION}\"")

components/mdns/examples/query_advertise/main/mdns_example_main.c

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Unlicense OR CC0-1.0
55
*/
@@ -44,12 +44,12 @@ static void initialise_mdns(void)
4444
char *hostname = generate_hostname();
4545

4646
//initialize mDNS
47-
ESP_ERROR_CHECK( mdns_init() );
47+
ESP_ERROR_CHECK(mdns_init());
4848
//set mDNS hostname (required if you want to advertise services)
49-
ESP_ERROR_CHECK( mdns_hostname_set(hostname) );
49+
ESP_ERROR_CHECK(mdns_hostname_set(hostname));
5050
ESP_LOGI(TAG, "mdns hostname set to: [%s]", hostname);
5151
//set default mDNS instance name
52-
ESP_ERROR_CHECK( mdns_instance_name_set(EXAMPLE_MDNS_INSTANCE) );
52+
ESP_ERROR_CHECK(mdns_instance_name_set(EXAMPLE_MDNS_INSTANCE));
5353

5454
//structure with TXT records
5555
mdns_txt_item_t serviceTxtData[3] = {
@@ -59,10 +59,10 @@ static void initialise_mdns(void)
5959
};
6060

6161
//initialize service
62-
ESP_ERROR_CHECK( mdns_service_add("ESP32-WebServer", "_http", "_tcp", 80, serviceTxtData, 3) );
63-
ESP_ERROR_CHECK( mdns_service_subtype_add_for_host("ESP32-WebServer", "_http", "_tcp", NULL, "_server") );
62+
ESP_ERROR_CHECK(mdns_service_add("ESP32-WebServer", "_http", "_tcp", 80, serviceTxtData, 3));
63+
ESP_ERROR_CHECK(mdns_service_subtype_add_for_host("ESP32-WebServer", "_http", "_tcp", NULL, "_server"));
6464
#if CONFIG_MDNS_MULTIPLE_INSTANCE
65-
ESP_ERROR_CHECK( mdns_service_add("ESP32-WebServer1", "_http", "_tcp", 80, NULL, 0) );
65+
ESP_ERROR_CHECK(mdns_service_add("ESP32-WebServer1", "_http", "_tcp", 80, NULL, 0));
6666
#endif
6767

6868
#if CONFIG_MDNS_PUBLISH_DELEGATE_HOST
@@ -78,15 +78,15 @@ static void initialise_mdns(void)
7878
addr6.addr.type = ESP_IPADDR_TYPE_V6;
7979
addr4.next = &addr6;
8080
addr6.next = NULL;
81-
ESP_ERROR_CHECK( mdns_delegate_hostname_add(delegated_hostname, &addr4) );
82-
ESP_ERROR_CHECK( mdns_service_add_for_host("test0", "_http", "_tcp", delegated_hostname, 1234, serviceTxtData, 3) );
81+
ESP_ERROR_CHECK(mdns_delegate_hostname_add(delegated_hostname, &addr4));
82+
ESP_ERROR_CHECK(mdns_service_add_for_host("test0", "_http", "_tcp", delegated_hostname, 1234, serviceTxtData, 3));
8383
free(delegated_hostname);
8484
#endif // CONFIG_MDNS_PUBLISH_DELEGATE_HOST
8585

8686
//add another TXT item
87-
ESP_ERROR_CHECK( mdns_service_txt_item_set("_http", "_tcp", "path", "/foobar") );
87+
ESP_ERROR_CHECK(mdns_service_txt_item_set("_http", "_tcp", "path", "/foobar"));
8888
//change TXT item value
89-
ESP_ERROR_CHECK( mdns_service_txt_item_set_with_explicit_value_len("_http", "_tcp", "u", "admin", strlen("admin")) );
89+
ESP_ERROR_CHECK(mdns_service_txt_item_set_with_explicit_value_len("_http", "_tcp", "u", "admin", strlen("admin")));
9090
free(hostname);
9191
}
9292

@@ -314,6 +314,8 @@ void app_main(void)
314314
ESP_ERROR_CHECK(esp_netif_init());
315315
ESP_ERROR_CHECK(esp_event_loop_create_default());
316316

317+
ESP_LOGI(TAG, "mDNS Ver: %s", ESP_MDNS_VERSION_NUMBER);
318+
317319
initialise_mdns();
318320

319321
/* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig.
@@ -375,12 +377,12 @@ static void query_mdns_host_with_gethostbyname(char *host)
375377
while (res->h_addr_list[i] != NULL) {
376378
ESP_LOGI(TAG, "gethostbyname: %s resolved to: %s", host,
377379
#if defined(CONFIG_LWIP_IPV6) && defined(CONFIG_LWIP_IPV4)
378-
res->h_addrtype == AF_INET ? inet_ntoa(*(struct in_addr *) (res->h_addr_list[i])) :
379-
inet6_ntoa(*(struct in6_addr *) (res->h_addr_list[i]))
380+
res->h_addrtype == AF_INET ? inet_ntoa(*(struct in_addr *)(res->h_addr_list[i])) :
381+
inet6_ntoa(*(struct in6_addr *)(res->h_addr_list[i]))
380382
#elif defined(CONFIG_LWIP_IPV6)
381-
inet6_ntoa(*(struct in6_addr *) (res->h_addr_list[i]))
383+
inet6_ntoa(*(struct in6_addr *)(res->h_addr_list[i]))
382384
#else
383-
inet_ntoa(*(struct in_addr *) (res->h_addr_list[i]))
385+
inet_ntoa(*(struct in_addr *)(res->h_addr_list[i]))
384386
#endif
385387
);
386388
i++;

components/mdns/idf_component.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.7.0"
1+
version: "1.8.0"
22
description: "Multicast UDP service used to provide local network service and host discovery."
33
url: "https://github.com/espressif/esp-protocols/tree/master/components/mdns"
44
issues: "https://github.com/espressif/esp-protocols/issues"

components/mdns/include/mdns.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ esp_err_t mdns_service_instance_name_set(const char *service_type, const char *p
373373
* - ESP_ERR_NO_MEM memory error
374374
*/
375375
esp_err_t mdns_service_instance_name_set_for_host(const char *instance_old, const char *service_type, const char *proto, const char *hostname,
376-
const char *instance_name);
376+
const char *instance_name);
377377

378378
/**
379379
* @brief Set service port
@@ -407,7 +407,7 @@ esp_err_t mdns_service_port_set(const char *service_type, const char *proto, uin
407407
* - ESP_ERR_NO_MEM memory error
408408
*/
409409
esp_err_t mdns_service_port_set_for_host(const char *instance, const char *service_type, const char *proto, const char *hostname,
410-
uint16_t port);
410+
uint16_t port);
411411

412412
/**
413413
* @brief Replace all TXT items for service
@@ -482,7 +482,7 @@ esp_err_t mdns_service_txt_item_set(const char *service_type, const char *proto,
482482
* - ESP_ERR_NO_MEM memory error
483483
*/
484484
esp_err_t mdns_service_txt_item_set_with_explicit_value_len(const char *service_type, const char *proto,
485-
const char *key, const char *value, uint8_t value_len);
485+
const char *key, const char *value, uint8_t value_len);
486486

487487
/**
488488
* @brief Set/Add TXT item for service TXT record with hostname
@@ -503,7 +503,7 @@ esp_err_t mdns_service_txt_item_set_with_explicit_value_len(const char *service_
503503
* - ESP_ERR_NO_MEM memory error
504504
*/
505505
esp_err_t mdns_service_txt_item_set_for_host(const char *instance, const char *service_type, const char *proto, const char *hostname,
506-
const char *key, const char *value);
506+
const char *key, const char *value);
507507

508508
/**
509509
* @brief Set/Add TXT item for service TXT record with hostname and txt value length
@@ -523,8 +523,8 @@ esp_err_t mdns_service_txt_item_set_for_host(const char *instance, const char *s
523523
* - ESP_ERR_NO_MEM memory error
524524
*/
525525
esp_err_t mdns_service_txt_item_set_for_host_with_explicit_value_len(const char *instance, const char *service_type, const char *proto,
526-
const char *hostname, const char *key,
527-
const char *value, uint8_t value_len);
526+
const char *hostname, const char *key,
527+
const char *value, uint8_t value_len);
528528

529529
/**
530530
* @brief Remove TXT item for service TXT record
@@ -557,7 +557,7 @@ esp_err_t mdns_service_txt_item_remove(const char *service_type, const char *pro
557557
* - ESP_ERR_NO_MEM memory error
558558
*/
559559
esp_err_t mdns_service_txt_item_remove_for_host(const char *instance, const char *service_type, const char *proto, const char *hostname,
560-
const char *key);
560+
const char *key);
561561

562562
/**
563563
* @brief Add a subtype for service.
@@ -575,7 +575,7 @@ esp_err_t mdns_service_txt_item_remove_for_host(const char *instance, const char
575575
* - ESP_ERR_NO_MEM memory error
576576
*/
577577
esp_err_t mdns_service_subtype_add_for_host(const char *instance_name, const char *service_type, const char *proto,
578-
const char *hostname, const char *subtype);
578+
const char *hostname, const char *subtype);
579579

580580
/**
581581
* @brief Remove a subtype for service.
@@ -592,7 +592,7 @@ esp_err_t mdns_service_subtype_add_for_host(const char *instance_name, const cha
592592
* - ESP_ERR_NOT_FOUND Service not found
593593
*/
594594
esp_err_t mdns_service_subtype_remove_for_host(const char *instance_name, const char *service_type, const char *proto,
595-
const char *hostname, const char *subtype);
595+
const char *hostname, const char *subtype);
596596

597597
/**
598598
* @brief Add multiple subtypes for service at once.
@@ -611,7 +611,7 @@ esp_err_t mdns_service_subtype_remove_for_host(const char *instance_name, const
611611
* - ESP_ERR_NO_MEM memory error
612612
*/
613613
esp_err_t mdns_service_subtype_add_multiple_items_for_host(const char *instance_name, const char *service_type, const char *proto,
614-
const char *hostname, mdns_subtype_item_t subtype[], uint8_t num_items);
614+
const char *hostname, mdns_subtype_item_t subtype[], uint8_t num_items);
615615

616616
/**
617617
* @brief Update subtype for service.
@@ -632,7 +632,7 @@ esp_err_t mdns_service_subtype_add_multiple_items_for_host(const char *instance_
632632
* - ESP_ERR_NO_MEM memory error
633633
*/
634634
esp_err_t mdns_service_subtype_update_multiple_items_for_host(const char *instance_name, const char *service_type, const char *proto,
635-
const char *hostname, mdns_subtype_item_t subtype[], uint8_t num_items);
635+
const char *hostname, mdns_subtype_item_t subtype[], uint8_t num_items);
636636
/**
637637
* @brief Remove and free all services from mDNS server
638638
*
@@ -686,7 +686,7 @@ bool mdns_query_async_get_results(mdns_search_once_t *search, uint32_t timeout,
686686
* NULL otherwise.
687687
*/
688688
mdns_search_once_t *mdns_query_async_new(const char *name, const char *service_type, const char *proto, uint16_t type,
689-
uint32_t timeout, size_t max_results, mdns_query_notify_t notifier);
689+
uint32_t timeout, size_t max_results, mdns_query_notify_t notifier);
690690

691691
/**
692692
* @brief Generic mDNS query
@@ -825,7 +825,7 @@ esp_err_t mdns_lookup_delegated_service(const char *instance, const char *servic
825825
* - ESP_ERR_INVALID_ARG parameter error
826826
*/
827827
esp_err_t mdns_lookup_selfhosted_service(const char *instance, const char *service_type, const char *proto, size_t max_results,
828-
mdns_result_t **result);
828+
mdns_result_t **result);
829829

830830
/**
831831
* @brief Query mDNS for A record

components/mdns/tests/host_test/components/esp_netif_linux/esp_netif_linux.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ esp_err_t esp_netif_get_ip_info(esp_netif_t *esp_netif, esp_netif_ip_info_t *ip_
5151
if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_INET) {
5252
char addr[20];
5353
struct sockaddr_in *pAddr = (struct sockaddr_in *) tmp->ifa_addr;
54-
inet_ntop(AF_INET, &pAddr->sin_addr, addr, sizeof(addr) );
54+
inet_ntop(AF_INET, &pAddr->sin_addr, addr, sizeof(addr));
5555
if (strcmp(esp_netif->if_desc, tmp->ifa_name) == 0) {
5656
ESP_LOGD(TAG, "AF_INET4: %s: %s\n", tmp->ifa_name, addr);
5757
memcpy(&ip_info->ip.addr, &pAddr->sin_addr, 4);
@@ -105,7 +105,7 @@ esp_err_t esp_netif_get_ip6_linklocal(esp_netif_t *esp_netif, esp_ip6_addr_t *if
105105
if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_INET6) {
106106
char addr[64];
107107
struct sockaddr_in6 *pAddr = (struct sockaddr_in6 *)tmp->ifa_addr;
108-
inet_ntop(AF_INET6, &pAddr->sin6_addr, addr, sizeof(addr) );
108+
inet_ntop(AF_INET6, &pAddr->sin6_addr, addr, sizeof(addr));
109109
if (strcmp(esp_netif->if_desc, tmp->ifa_name) == 0) {
110110
ESP_LOGD(TAG, "AF_INET6: %s: %s\n", tmp->ifa_name, addr);
111111
memcpy(if_ip6->addr, &pAddr->sin6_addr, 4 * 4);

components/mdns/tests/host_test/main/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static void mdns_test_app(esp_netif_t *interface)
111111
.func = exit_console,
112112
.argtable = NULL
113113
};
114-
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd_exit) );
114+
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd_exit));
115115
mdns_console_register();
116116
ESP_ERROR_CHECK(esp_console_start_repl(repl));
117117
xEventGroupWaitBits(s_exit_signal, 1, pdTRUE, pdFALSE, portMAX_DELAY);

components/mdns/tests/test_afl_fuzz_host/test.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ int main(int argc, char **argv)
243243
//
244244
// Note: parameter1 is a file (mangled packet) which caused the crash
245245
file = fopen(argv[1], "r");
246-
assert(file >= 0 );
246+
assert(file >= 0);
247247
len = fread(buf, 1, 1460, file);
248248
fclose(file);
249249
}

components/mdns/tests/test_apps/main/main.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -55,17 +55,17 @@ static void initialise_mdns(void)
5555
char *hostname = generate_hostname();
5656

5757
//initialize mDNS
58-
ESP_ERROR_CHECK( mdns_init() );
58+
ESP_ERROR_CHECK(mdns_init());
5959

6060
//set mDNS hostname (required if you want to advertise services)
61-
ESP_ERROR_CHECK( mdns_hostname_set(hostname) );
61+
ESP_ERROR_CHECK(mdns_hostname_set(hostname));
6262

6363
ESP_LOGI(TAG, "mdns hostname set to: [%s]", hostname);
6464
//set default mDNS instance name
65-
ESP_ERROR_CHECK( mdns_instance_name_set(CONFIG_TEST_MDNS_INSTANCE) );
65+
ESP_ERROR_CHECK(mdns_instance_name_set(CONFIG_TEST_MDNS_INSTANCE));
6666

6767
//initialize service
68-
ESP_ERROR_CHECK( mdns_service_add("ESP32-WebServer", "_http", "_tcp", 80, NULL, 0) );
68+
ESP_ERROR_CHECK(mdns_service_add("ESP32-WebServer", "_http", "_tcp", 80, NULL, 0));
6969

7070
#if CONFIG_TEST_MDNS_PUBLISH_DELEGATE_HOST
7171
char *delegated_hostname;
@@ -80,12 +80,12 @@ static void initialise_mdns(void)
8080
addr6.addr.type = ESP_IPADDR_TYPE_V6;
8181
addr4.next = &addr6;
8282
addr6.next = NULL;
83-
ESP_ERROR_CHECK( mdns_delegate_hostname_add(delegated_hostname, &addr4) );
84-
ESP_ERROR_CHECK( mdns_service_add_for_host("test0", "_http", "_tcp", delegated_hostname, 1234, NULL, 0) );
83+
ESP_ERROR_CHECK(mdns_delegate_hostname_add(delegated_hostname, &addr4));
84+
ESP_ERROR_CHECK(mdns_service_add_for_host("test0", "_http", "_tcp", delegated_hostname, 1234, NULL, 0));
8585
free(delegated_hostname);
8686
#endif // CONFIG_TEST_MDNS_PUBLISH_DELEGATE_HOST
8787

88-
ESP_ERROR_CHECK( mdns_service_subtype_add_for_host("ESP32-WebServer", "_http", "_tcp", NULL, "_server") );
88+
ESP_ERROR_CHECK(mdns_service_subtype_add_for_host("ESP32-WebServer", "_http", "_tcp", NULL, "_server"));
8989

9090
free(hostname);
9191
}

0 commit comments

Comments
 (0)