diff --git a/.github/workflows/asio__build-target-test.yml b/.github/workflows/asio__build-target-test.yml index a8d70d656..b7d0e1556 100644 --- a/.github/workflows/asio__build-target-test.yml +++ b/.github/workflows/asio__build-target-test.yml @@ -13,7 +13,7 @@ jobs: name: Build strategy: matrix: - idf_ver: ["latest", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3"] + idf_ver: ["latest", "release-v5.0", "release-v5.1", "release-v5.2", "release-v5.3", "release-v5.4"] idf_target: ["esp32", "esp32s2"] example: ["asio_chat", "async_request", "socks4", "ssl_client_server", "tcp_echo_server", "udp_echo_server"] runs-on: ubuntu-22.04 @@ -64,7 +64,7 @@ jobs: name: Target tests strategy: matrix: - idf_ver: ["latest", "release-v5.0", "release-v5.2", "release-v5.3"] + idf_ver: ["latest", "release-v5.1", "release-v5.2", "release-v5.3", "release-v5.4"] idf_target: ["esp32"] example: ["asio_chat", "tcp_echo_server", "udp_echo_server", "ssl_client_server"] needs: build_asio diff --git a/.gitmodules b/.gitmodules index 60b373071..391f57233 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "components/asio/asio"] path = components/asio/asio - url = https://github.com/espressif/asio + url = https://github.com/chriskohlhoff/asio [submodule "components/mosquitto/mosquitto"] path = components/mosquitto/mosquitto url = https://github.com/eclipse/mosquitto diff --git a/components/asio/.cz.yaml b/components/asio/.cz.yaml index a993a1389..f48d4ec79 100644 --- a/components/asio/.cz.yaml +++ b/components/asio/.cz.yaml @@ -1,7 +1,8 @@ +--- commitizen: bump_message: 'bump(asio): $current_version -> $new_version' pre_bump_hooks: python ../../ci/changelog.py asio tag_format: asio-v$version - version: 1.28.0~0 + version: 1.32.0 version_files: - idf_component.yml diff --git a/components/asio/CHANGELOG.md b/components/asio/CHANGELOG.md index 06d4dbae2..48688264e 100644 --- a/components/asio/CHANGELOG.md +++ b/components/asio/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## [1.32.0](https://github.com/espressif/esp-protocols/commits/asio-v1.32.0) + +### Features + +- Upgrade asio to 1.32 ([9bdd429c](https://github.com/espressif/esp-protocols/commit/9bdd429c)) +- Drop esp/asio patches in favor of sock-utils ([27435b7f](https://github.com/espressif/esp-protocols/commit/27435b7f)) + +### Bug Fixes + +- Fix chat example to print only the message body ([76aaea08](https://github.com/espressif/esp-protocols/commit/76aaea08)) +- Make asio enable if_nametoindex to fix linking ([5db32cce](https://github.com/espressif/esp-protocols/commit/5db32cce)) +- Re-applie refs to common comps idf_component.yml ([9fe44a45](https://github.com/espressif/esp-protocols/commit/9fe44a45)) +- Reference common component from IDF ([74fc228c](https://github.com/espressif/esp-protocols/commit/74fc228c)) +- Revert referencing protocol_examples_common from IDF ([f9e0281a](https://github.com/espressif/esp-protocols/commit/f9e0281a)) +- reference protocol_examples_common from IDF ([09abb18b](https://github.com/espressif/esp-protocols/commit/09abb18b)) +- specify override_path in example manifest files ([1d8923cf](https://github.com/espressif/esp-protocols/commit/1d8923cf)) + +### Updated + +- docs(asio): Updates asio docs ([ce9337d3](https://github.com/espressif/esp-protocols/commit/ce9337d3)) + ## [1.28.2~0](https://github.com/espressif/esp-protocols/commits/asio-1.28.2_0) ### Bug Fixes diff --git a/components/asio/CMakeLists.txt b/components/asio/CMakeLists.txt index 3ec69bac4..8aebfc71b 100644 --- a/components/asio/CMakeLists.txt +++ b/components/asio/CMakeLists.txt @@ -6,8 +6,8 @@ if(NOT CONFIG_LWIP_IPV6 AND NOT CMAKE_BUILD_EARLY_EXPANSION) return() endif() -set(asio_sources "asio/asio/src/asio.cpp") -set(asio_requires lwip) +set(asio_sources "asio/asio/src/asio.cpp" "port/src/asio_stub.cpp") +set(asio_requires lwip sock_utils) if(CONFIG_ASIO_SSL_SUPPORT) list(APPEND asio_sources @@ -18,7 +18,7 @@ if(CONFIG_ASIO_SSL_SUPPORT) endif() idf_component_register(SRCS ${asio_sources} - INCLUDE_DIRS "asio/asio/include" "port/include" + INCLUDE_DIRS "port/include" "asio/asio/include" PRIV_INCLUDE_DIRS ${asio_priv_includes} PRIV_REQUIRES ${asio_requires}) @@ -30,6 +30,7 @@ target_compile_definitions(${COMPONENT_LIB} PUBLIC SA_RESTART=0x01 ASIO_STANDALONE ASIO_HAS_PTHREADS OPENSSL_NO_ENGINE + ASIO_DETAIL_IMPL_POSIX_EVENT_IPP # this replaces asio's posix_event constructor ) if(NOT CONFIG_COMPILER_CXX_EXCEPTIONS) diff --git a/components/asio/Kconfig b/components/asio/Kconfig index 8b46ae065..b8a30b7d3 100644 --- a/components/asio/Kconfig +++ b/components/asio/Kconfig @@ -1,6 +1,15 @@ menu "ESP-ASIO" visible if LWIP_IPV6 + config ASIO_IS_ENABLED + # Invisible option that is enabled if ASIO is added to the IDF components. + # This is used to "select" LWIP_NETIF_API option + # which enables if_indextoname() and if_nametoindex() functions + # (these are optionally used in asio) + bool + default "y" + select LWIP_NETIF_API + config ASIO_SSL_SUPPORT bool "Enable SSL/TLS support of ASIO" default n diff --git a/components/asio/asio b/components/asio/asio index a2e0f70d6..03ae834ed 160000 --- a/components/asio/asio +++ b/components/asio/asio @@ -1 +1 @@ -Subproject commit a2e0f70d612309f4623bd43d8a26629bd716bb2c +Subproject commit 03ae834edbace31a96157b89bf50e5ee464e5ef9 diff --git a/components/asio/examples/asio_chat/main/server.hpp b/components/asio/examples/asio_chat/main/server.hpp index 971c19d2f..af2c4a47f 100644 --- a/components/asio/examples/asio_chat/main/server.hpp +++ b/components/asio/examples/asio_chat/main/server.hpp @@ -120,7 +120,7 @@ private: asio::buffer(read_msg_.body(), read_msg_.body_length()), [this, self](std::error_code ec, std::size_t /*length*/) { if (!ec) { - ESP_LOGD("asio-chat:", "%s", read_msg_.body()); + ESP_LOGD("asio-chat", "%.*s", read_msg_.body_length(), read_msg_.body()); room_.deliver(read_msg_); do_read_header(); } else { diff --git a/components/asio/idf_component.yml b/components/asio/idf_component.yml index a54601f0f..3708c8510 100644 --- a/components/asio/idf_component.yml +++ b/components/asio/idf_component.yml @@ -7,3 +7,5 @@ repository: https://github.com/espressif/esp-protocols.git dependencies: idf: version: ">=5.0" + espressif/sock_utils: + version: "^0.1" diff --git a/components/asio/port/include/asio/detail/config.hpp b/components/asio/port/include/asio/detail/config.hpp new file mode 100644 index 000000000..288fe08b8 --- /dev/null +++ b/components/asio/port/include/asio/detail/config.hpp @@ -0,0 +1,11 @@ +// +// SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD +// +// SPDX-License-Identifier: BSL-1.0 +// +#pragma once + +#include "sys/socket.h" +#include "socketpair.h" + +#include_next "asio/detail/config.hpp" diff --git a/components/asio/port/include/openssl_stub.hpp b/components/asio/port/include/asio/ssl/detail/openssl_types.hpp similarity index 100% rename from components/asio/port/include/openssl_stub.hpp rename to components/asio/port/include/asio/ssl/detail/openssl_types.hpp diff --git a/components/asio/port/include/esp_asio_config.h b/components/asio/port/include/esp_asio_config.h deleted file mode 100644 index 2ad9c79c7..000000000 --- a/components/asio/port/include/esp_asio_config.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#ifndef _ESP_ASIO_CONFIG_H_ -#define _ESP_ASIO_CONFIG_H_ - -#define ASIO_SSL_DETAIL_OPENSSL_TYPES_HPP -#include "openssl_stub.hpp" - -#endif // _ESP_ASIO_CONFIG_H_ diff --git a/components/asio/port/mbedtls/src/mbedtls_context.cpp b/components/asio/port/mbedtls/src/mbedtls_context.cpp index bf9220ad5..4b3e2f418 100644 --- a/components/asio/port/mbedtls/src/mbedtls_context.cpp +++ b/components/asio/port/mbedtls/src/mbedtls_context.cpp @@ -8,7 +8,7 @@ // #include "asio/detail/config.hpp" -#include "openssl_stub.hpp" +#include "asio/ssl/detail/openssl_types.hpp" #include #include "asio/detail/throw_error.hpp" #include "asio/error.hpp" diff --git a/components/asio/port/mbedtls/src/mbedtls_engine.cpp b/components/asio/port/mbedtls/src/mbedtls_engine.cpp index 1d97b3a73..1c03a3284 100644 --- a/components/asio/port/mbedtls/src/mbedtls_engine.cpp +++ b/components/asio/port/mbedtls/src/mbedtls_engine.cpp @@ -7,7 +7,7 @@ // #include "asio/detail/config.hpp" -#include "openssl_stub.hpp" +#include "asio/ssl/detail/openssl_types.hpp" #include "asio/detail/throw_error.hpp" #include "asio/error.hpp" #include "asio/ssl/detail/engine.hpp" diff --git a/components/asio/port/src/asio_stub.cpp b/components/asio/port/src/asio_stub.cpp new file mode 100644 index 000000000..ebc0c93f6 --- /dev/null +++ b/components/asio/port/src/asio_stub.cpp @@ -0,0 +1,36 @@ +// +// SPDX-FileCopyrightText: 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// SPDX-License-Identifier: BSL-1.0 +// +// SPDX-FileContributor: 2024 Espressif Systems (Shanghai) CO LTD +// +#include "asio/detail/posix_event.hpp" +#include "asio/detail/throw_error.hpp" +#include "asio/error.hpp" +#include "asio/detail/push_options.hpp" +#include +#include + +namespace asio::detail { +// This replaces asio's posix_event constructor +// since the default POSIX version uses pthread_condattr_t operations (init, setclock, destroy), +// which are not available on all IDF versions (some are defined in compilers' headers, others in +// pthread library, but they typically return `ENOSYS` which causes trouble in the event wrapper) +// IMPORTANT: Check implementation of posix_event() when upgrading upstream asio in order not to +// miss any initialization step. +posix_event::posix_event() + : state_(0) +{ + int error = ::pthread_cond_init(&cond_, nullptr); + asio::error_code ec(error, asio::error::get_system_category()); + asio::detail::throw_error(ec, "event"); +} +} // namespace asio::detail + +extern "C" int pause (void) +{ + while (true) { + ::sleep(UINT_MAX); + } +}