diff --git a/components/openthread/CMakeLists.txt b/components/openthread/CMakeLists.txt index 944e77eb60..49f91d3be7 100644 --- a/components/openthread/CMakeLists.txt +++ b/components/openthread/CMakeLists.txt @@ -17,6 +17,7 @@ if(CONFIG_OPENTHREAD_ENABLED) "openthread/examples/platforms" "openthread/src" "openthread/src/core" + "openthread/src/include" "openthread/src/lib" "openthread/src/lib/hdlc" "openthread/src/lib/spinel" @@ -102,8 +103,10 @@ if(CONFIG_OPENTHREAD_ENABLED) "openthread/src/core/thread/announce_sender.cpp" "openthread/src/core/thread/address_resolver.cpp" "openthread/src/core/thread/child_supervision.cpp" + "openthread/src/core/thread/csl_tx_scheduler.cpp" "openthread/src/core/thread/discover_scanner.cpp" "openthread/src/core/thread/energy_scan_server.cpp" + "openthread/src/core/thread/indirect_sender.cpp" "openthread/src/core/thread/key_manager.cpp" "openthread/src/core/thread/link_metrics.cpp" "openthread/src/core/thread/lowpan.cpp" @@ -215,6 +218,7 @@ elseif(CONFIG_OPENTHREAD_SPINEL_ONLY) "private_include" "openthread/src" "openthread/src/core" + "openthread/src/include" "openthread/src/lib" "openthread/src/lib/hdlc" "openthread/src/lib/spinel") diff --git a/components/openthread/openthread b/components/openthread/openthread index 005c5cefc2..9398342b49 160000 --- a/components/openthread/openthread +++ b/components/openthread/openthread @@ -1 +1 @@ -Subproject commit 005c5cefc22aaf0396e4327ee7f2e0ad32a7733b +Subproject commit 9398342b49a03cd140fae910b81cddf9084293a0 diff --git a/components/openthread/private_include/openthread-core-esp32x-ftd-config.h b/components/openthread/private_include/openthread-core-esp32x-ftd-config.h index 99b859ce17..1eec63bc70 100644 --- a/components/openthread/private_include/openthread-core-esp32x-ftd-config.h +++ b/components/openthread/private_include/openthread-core-esp32x-ftd-config.h @@ -440,6 +440,16 @@ #define OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE 1 #endif +/** + * @def OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE + * + * Define to 1 to enable upstream forwarding support. + * + */ +#ifndef OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE +#define OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE 1 +#endif + /** * @def OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE * diff --git a/components/openthread/sbom_openthread.yml b/components/openthread/sbom_openthread.yml index b227b42db8..1021051236 100644 --- a/components/openthread/sbom_openthread.yml +++ b/components/openthread/sbom_openthread.yml @@ -5,4 +5,4 @@ supplier: 'Organization: Espressif Systems (Shanghai) CO LTD' originator: 'Organization: Google LLC' description: OpenThread released by Google is an open-source implementation of the Thread networking url: https://github.com/espressif/openthread -hash: 005c5cefc22aaf0396e4327ee7f2e0ad32a7733b +hash: 9398342b49a03cd140fae910b81cddf9084293a0 diff --git a/components/openthread/src/port/esp_openthread_radio_spinel.cpp b/components/openthread/src/port/esp_openthread_radio_spinel.cpp index 066bf8b5c6..615728807f 100644 --- a/components/openthread/src/port/esp_openthread_radio_spinel.cpp +++ b/components/openthread/src/port/esp_openthread_radio_spinel.cpp @@ -93,6 +93,7 @@ esp_err_t esp_openthread_radio_init(const esp_openthread_platform_config_t *conf iidList[0] = 0; ot::Spinel::RadioSpinelCallbacks callbacks; + memset(&callbacks, 0, sizeof(callbacks)); #if CONFIG_OPENTHREAD_DIAG callbacks.mDiagReceiveDone = otPlatDiagRadioReceiveDone; callbacks.mDiagTransmitDone = otPlatDiagRadioTransmitDone; diff --git a/components/openthread/src/port/esp_openthread_trel.c b/components/openthread/src/port/esp_openthread_trel.c index 8424a7631d..91603b4bd0 100644 --- a/components/openthread/src/port/esp_openthread_trel.c +++ b/components/openthread/src/port/esp_openthread_trel.c @@ -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 */ @@ -41,6 +41,7 @@ typedef struct { typedef struct { struct pbuf *p; + otSockAddr *source_addr; } ot_trel_recv_task_t; typedef struct { @@ -90,7 +91,8 @@ static void trel_browse_notifier(mdns_result_t *result) static void trel_recv_task(void *ctx) { - struct pbuf *recv_buf = (struct pbuf *)ctx; + ot_trel_recv_task_t *task_ctx = (ot_trel_recv_task_t *)ctx; + struct pbuf *recv_buf = task_ctx->p; uint8_t *data_buf = (uint8_t *)recv_buf->payload; uint8_t *data_buf_to_free = NULL; uint16_t length = recv_buf->len; @@ -106,21 +108,49 @@ static void trel_recv_task(void *ctx) ExitNow(); } } - otPlatTrelHandleReceived(esp_openthread_get_instance(), data_buf, length); + otPlatTrelHandleReceived(esp_openthread_get_instance(), data_buf, length, task_ctx->source_addr); exit: if (data_buf_to_free) { free(data_buf_to_free); } pbuf_free(recv_buf); + if(task_ctx) { + free(task_ctx->source_addr); + } + free(task_ctx); } static void handle_trel_udp_recv(void *ctx, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, uint16_t port) { ESP_LOGD(OT_PLAT_LOG_TAG, "Receive from %s:%d", ip6addr_ntoa(&(addr->u_addr.ip6)), port); - if (esp_openthread_task_queue_post(trel_recv_task, p) != ESP_OK) { - ESP_LOGE(OT_PLAT_LOG_TAG, "Failed to receive OpenThread TREL message"); + + ot_trel_recv_task_t *task_ctx = (ot_trel_recv_task_t *)malloc(sizeof(ot_trel_recv_task_t)); + if (task_ctx == NULL) { + ESP_LOGE(OT_PLAT_LOG_TAG, "Failed to allocate buf for Thread TREL"); + ExitNow(); } + task_ctx->p = p; + task_ctx->source_addr = (otSockAddr *)malloc(sizeof(otSockAddr)); + if (task_ctx->source_addr == NULL) { + ESP_LOGE(OT_PLAT_LOG_TAG, "Failed to allocate buf for Thread TREL"); + ExitNow(); + } + memset(task_ctx->source_addr, 0, sizeof(otSockAddr)); + task_ctx->source_addr->mPort = port; + memcpy(&task_ctx->source_addr->mAddress.mFields.m32, addr->u_addr.ip6.addr, sizeof(addr->u_addr.ip6.addr)); + + if (esp_openthread_task_queue_post(trel_recv_task, task_ctx) != ESP_OK) { + ESP_LOGE(OT_PLAT_LOG_TAG, "Failed to receive OpenThread TREL message"); + ExitNow(); + } + return; +exit: + if(task_ctx) { + free(task_ctx->source_addr); + } + free(task_ctx); + pbuf_free(p); } static esp_err_t ot_new_trel(void *ctx) @@ -198,6 +228,20 @@ void otPlatTrelSend(otInstance *aInstance, esp_openthread_task_switching_lock_acquire(portMAX_DELAY); } +void otPlatTrelNotifyPeerSocketAddressDifference(otInstance *aInstance, + const otSockAddr *aPeerSockAddr, + const otSockAddr *aRxSockAddr) +{ + OT_UNUSED_VARIABLE(aInstance); + + char peer_string[OT_IP6_SOCK_ADDR_STRING_SIZE]; + char rx_string[OT_IP6_SOCK_ADDR_STRING_SIZE]; + otIp6SockAddrToString(aPeerSockAddr, peer_string, sizeof(peer_string)); + otIp6SockAddrToString(aRxSockAddr, rx_string, sizeof(rx_string)); + + ESP_LOGW(OT_PLAT_LOG_TAG, "TREL packet is received from a peer (%s) using a different socket address (%s)", peer_string, rx_string); +} + void otPlatTrelRegisterService(otInstance *aInstance, uint16_t aPort, const uint8_t *aTxtData, uint8_t aTxtLength) { esp_err_t ret = ESP_OK; diff --git a/components/openthread/src/port/esp_openthread_udp.c b/components/openthread/src/port/esp_openthread_udp.c index fd118b2a0f..614bac12b2 100644 --- a/components/openthread/src/port/esp_openthread_udp.c +++ b/components/openthread/src/port/esp_openthread_udp.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -258,7 +258,7 @@ static uint8_t get_netif_index(otNetifIdentifier netif_identifier) switch (netif_identifier) { case OT_NETIF_UNSPECIFIED: return NETIF_NO_INDEX; - case OT_NETIF_THREAD: + case OT_NETIF_THREAD_HOST: return esp_netif_get_netif_impl_index(esp_openthread_get_netif()); case OT_NETIF_BACKBONE: return esp_netif_get_netif_impl_index(esp_openthread_get_backbone_netif()); @@ -351,7 +351,7 @@ static void udp_send_task(void *ctx) VerifyOrExit(send_buf != NULL); otMessageRead(task->message, 0, send_buf->payload, len); - if (task->netif_index == get_netif_index(OT_NETIF_THREAD)) { + if (task->netif_index == get_netif_index(OT_NETIF_THREAD_HOST)) { // If the input arguments indicated the netif is OT, directly send the message. err = udp_sendto_if_src(task->pcb, send_buf, &task->peer_addr, task->peer_port, netif_get_by_index(task->netif_index), &task->source_addr); } else { @@ -402,12 +402,12 @@ otError otPlatUdpSend(otUdpSocket *udp_socket, otMessage *message, const otMessa #endif if (is_link_local(&message_info->mPeerAddr) || is_multicast(&message_info->mPeerAddr)) { - task->netif_index = get_netif_index(message_info->mIsHostInterface ? OT_NETIF_BACKBONE : OT_NETIF_THREAD); + task->netif_index = get_netif_index(message_info->mIsHostInterface ? OT_NETIF_BACKBONE : OT_NETIF_THREAD_HOST); } if (is_openthread_internal_mesh_local_addr(&message_info->mPeerAddr)) { // If the destination address is a openthread mesh local address, set the netif OT. - task->netif_index = get_netif_index(OT_NETIF_THREAD); + task->netif_index = get_netif_index(OT_NETIF_THREAD_HOST); } esp_openthread_task_switching_lock_release(); tcpip_callback(udp_send_task, task); diff --git a/components/openthread/src/port/esp_uart_spinel_interface.cpp b/components/openthread/src/port/esp_uart_spinel_interface.cpp index 6f683fdee4..8a4de3b953 100644 --- a/components/openthread/src/port/esp_uart_spinel_interface.cpp +++ b/components/openthread/src/port/esp_uart_spinel_interface.cpp @@ -18,7 +18,7 @@ #include "esp_openthread_types.h" #include "esp_openthread_uart.h" #include "driver/uart_vfs.h" -#include "core/common/code_utils.hpp" +#include "include/common/code_utils.hpp" #include "core/common/logging.hpp" #include "driver/uart.h" #include "lib/platform/exit_code.h"