355 Commits

Author SHA1 Message Date
Jonathan Hui 05ad9803d8 [nexus] add 1.4 PIC-TC-1 test for DHCPv6-PD and DNS (#12859)
This commit adds a new Nexus test that implements the test
specification in test-1-4-PIC-TC-1.md. The test verifies Border
Router functionality including:
- DHCPv6-PD client to obtain OMR prefix
- Advertising route to OMR prefix on AIL (Stub Router)
- DNS recursive resolver for public internet addresses
- Connectivity (ICMPv6, UDP, TCP/HTTP) to internet and local servers

New files:
- tests/nexus/test_1_4_PIC_TC_1.cpp: C++ test execution
- tests/nexus/verify_1_4_PIC_TC_1.py: Python pcap verification

Nexus platform enhancements:
- Enabled DHCPv6-PD client in openthread-core-nexus-config.h
- Implemented DHCPv6-PD platform APIs in nexus_infra_if.cpp
- Added RDNSS option to RA in nexus_infra_if.cpp
- Improved packet delivery on infrastructure interface in nexus_core.cpp
- Fixed upstream DNS query matching in nexus_dns.cpp
2026-04-09 15:29:35 -05:00
Jonathan Hui e3d03f4f14 [tcplp] fix boundary check in cbuf_reass_write (#12671)
This commit fixes a logic error in the TCP receive buffer reassembly
logic. The issue occurred when an out-of-order segment was exactly
the size of the circular buffer and the write index was non-zero.

The original logic incorrectly used modulo-wrapped indices to check
if a write should be contiguous or split:
start_index + numbytes % size. When numbytes == size, end_index ==
start_index, which evaluates to true, leading to an incorrect memory
write if start_index > 0.

This commit updates the check to use the absolute write boundary:
if (start_index + numbytes <= chdr->size). This ensures that any
write spanning the buffer boundary is correctly split.

A regression test test_cbuf_reass_boundary is added to test_all.c
to verify the fix and prevent future regressions. The test Makefile
is also updated to use $(CC) for better portability.
2026-03-11 14:04:02 -05:00
Łukasz Duda 5c9eeb1ce8 [crypto] mbedtls: refactor mbedtls-config.h for better readability (#12292)
Group mbedTLS configuration macros into logical sections and improve
formatting.

This commit helps prepare for PSA API backend introduction.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2026-01-15 07:44:32 -08:00
Abtin Keshavarzian e3b565cc40 [mbedtls] fix build failure by including crypto.h (#12297)
Replace the include of `<openthread/platform/memory.h>` with
`<openthread/platform/crypto.h>` in the mbedTLS config header file.

Recent PR #12290 introduced `otPlatCryptoCAlloc()` and
`otPlatCryptoFree()` platform APIs and updated the mbedTLS config to
use them. This commit ensures the correct header is included to
prevent build errors regarding use of undeclared functions
(e.g. "error: use of undeclared identifier 'otPlatCryptoCAlloc'").
2026-01-15 07:38:48 -08:00
Łukasz Duda 8bdc6cf339 [crypto] PSA API: introduce platform API for crypto dynamic memory mgmt (#12290)
This commit introduces two new platform functions:
- otPlatCryptoCAlloc()
- otPlatCryptoFree()

It also provides a default implementation using the OpenThread Heap.

This API is necessary for the upcoming work related to PSA API

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2026-01-13 18:46:00 -08:00
Yakun Xu 40e693762d [build] add printf literal string format checks for va_list functions (#12236)
This commit introduces enhanced format string checking. It activates a
new compiler warning to identify potential issues with non-literal
format strings and systematically applies format attribute macros to
functions that handle variable arguments.
2025-12-23 19:31:08 -08:00
Yakun Xu 7c9de986c7 [gn] add tcplp (#12205)
This commit adds the tcp support in gn build for projects relying on
OpenThread.
2025-12-17 08:07:31 -08:00
Li Cao 6acb3ff430 [mbedtls] bump mbedtls version to 3.6.5 (#12152) 2025-11-19 13:45:51 -08:00
Li Cao 02295b035f [mbedtls] change mbedtls to git submodule (#12107)
This commit changes the mbedtls repo in openthread from source code to
git submodule.

This makes it easier for mbedtls version upgrade. This PR doesn't
upgrade the mbedtls version. v.3.6.0 is stil used to ensure nothing is
broken. The original OT specific build files (BUILD.gn, CMakeLists.txt
and config) are kept and unchanged. I've verified that the headers and
sources in the list of BUILD.gn are correct.
2025-11-12 08:10:56 +01:00
Yakun Xu a50d1a74dc [gn] enable warnings (#12121)
This commit suppresses the undefined warnings in mbedtls. To detect
such warnings in OpenThread, this commit also enables warnings check
for gn BUILD and fixes issues found.
2025-11-08 11:34:48 -08:00
Yakun Xu b945928d72 [gn] move gn build into etc (#11577) 2025-06-17 14:21:37 +09:00
Yaoxing Shan 424de28a2f [tcp] send RST and clear send buffer on abort (#11269)
This commit corrects the timing of Transmission Control Block (TCB)
re-initialization to ensure proper RST packet sending during TCP
connection aborts and to prevent potential issues due to incomplete
TCB cleanup.
2025-04-22 15:07:45 -07:00
Marius Preda a21666e275 [tcp] redefine conflicting symbols (#11174)
This commit redefines tcplp symbols that conflict with LWIP's TCP implementation:
- tcp_input has been renamed tcplp_input
- tcp_output has be renamed tcplp_output
- tcp_close has been renamed tcp_close_tcb
- tcp_init was already removed but the prototype was still present and was deleted
- TCP_MSS and TCP6_MSS have been renamed to TCP_MAXSS and TCP6_MAXSS

Signed-off-by: Marius Preda <marius.preda@nxp.com>
2025-01-22 10:59:24 -08:00
Bob MacDonald fa3509ebce [tcplp] fix an issue that occurs when using LTO and TCP is not enabled (#10726)
When building and linking with link time optimizations and TCP is
not enabled (OPENTHREAD_CONFIG_TCP_ENABLE = 0) the following error
occurs:

tcp_subr.c:96: undefined reference to tcplp_sys_get_ticks'

To address the problem we are removing the __attribute__((used))
annotation on the initialize_tcb function which will prevent the
function from being retained when no one references it.
2024-09-18 10:50:03 -07:00
Jonathan Hui 59e202cbdd [mbedtls] remove -Wno-unused-but-set-variable (#10336) 2024-06-04 10:05:58 -07:00
Łukasz Duda 70bad1df78 [mbedtls] enable MBEDTLS_OID_C when MBEDTLS_PK_PARSE_C is enabled (#10332)
This commit fixes mbedTLS config where MBEDTLS_OID_C is not set
together with MBEDTLS_PK_PARSE_C in some OpenThread configurations.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-06-03 18:46:32 -07:00
Łukasz Duda 1336da4212 [mbedtls] optimize AES configuration (#10286)
This commit optimizes the configuration of AES encryption to be tailored
for OpenThread.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-05-28 12:07:57 -07:00
Łukasz Duda c96e3b9504 [mbedtls] migrate to MbedTLS v3.6.0 (#10286)
This commit updates the in-tree version of MbedTLS to v3.6.0.

Signed-off-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
2024-05-28 12:07:57 -07:00
Jonathan Hui 6444157e37 [mbedtls] remove config workaround (#10263) 2024-05-17 21:02:46 -07:00
Przemysław Bida 3ae275f1ac [simulation] add simulation tests framework for tcat (#9724)
This commit adds simulation framework for tcat based on posix udp
sockets.
2024-03-22 10:30:59 -07:00
Jonathan Hui 869c2ded9c [mbedtls] update to 2.28.7 (#9835) 2024-02-07 13:09:43 -08:00
Przemysław Bida 5cab15840d [tcat] initial commit of bluetooth-based commissioning (#9210)
This commit introduces first implementation of Bluetooth based
comissioning for thread devices.

Co-authored-by: Arnulf Rupp <a.rupp@inventronicsglobal.com>
Co-authored-by: Piotr Jasinski <piotr.jasinski@nordicsemi.no>
2023-12-04 12:09:25 -08:00
Mahavir Jain 017c7ab915 [crypto-platform] fix build issue with mbedtls v3.5.0 (#9492)
As per the mbedTLS v3.5.0 release notes:

Ref: https://github.com/Mbed-TLS/mbedtls/releases/tag/mbedtls-3.5.0

MBEDTLS_CIPHER_BLKSIZE_MAX is deprecated in favor of
MBEDTLS_MAX_BLOCK_LENGTH (if you intended what the name suggests:
maximum size of any supported block cipher) or the new name
MBEDTLS_CMAC_MAX_BLOCK_SIZE (if you intended the actual semantics:
maximum size of a block cipher supported by the CMAC module).

This commit fixes the build issue keeping the backward compatibility
intact.
2023-10-08 20:48:54 -07:00
Sam Kumar 519537dd9b [tcplp] add support for TCP Fast Open (without cookie management) (#9165)
This commit adds support for TCP Fast Open, without cookie management.

To add support for this, I looked at the FreeBSD codebase and brought
in some code from FreeBSD 12.0 that implements TCP Fast Open --- the
version of FreeBSD that TCPlp is based on did not fully support TCP
Fast Open.

Normally, a part of TFO is cookie management --- the server generates
a cookie and includes it in the initial handshake, and client is
expected to present this cookie on future handshakes. This part is not
yet implemented, and I changed the logic from FreeBSD to allow data to
be exchanged in the TFO handshake even if the client does not present
a cookie. If we implement this functionality for TFO later, it is
probably worth departing from FreeBSD's data structures and policies
for maintaining cookie state in favor of something that is simpler and
more memory-efficient.
2023-08-21 15:00:52 -07:00
Jonathan Hui 1f1c155dc2 [clang-tidy] move config to .clang-tidy file (#9308) 2023-07-24 11:45:18 -07:00
Yakun Xu 11a38a63de [build] remove autotools (#9027)
This commit removes autotools support from OpenThread project.
2023-06-28 08:54:23 -07:00
Mariusz Poslinski 3d3ed4fbc1 [tcp] remove EXCLUDE_TCPLP_LIB option (#8883)
Signed-off-by: Mariusz Poslinski <mariusz.poslinski@nordicsemi.no>
2023-05-08 21:23:40 -07:00
Yakun Xu 30b79ccee8 [test] migrate tests to cmake (#8929)
This commit migrate tests not targeting autotool to cmake.

* removed openthread-test-driver
* removed functional tests from autotool based check
* corrected file permission of python scripts
* added --run-directory to specify directory to collect logs and captures
* get test-ot-test-srp-server pass on POSIX platform
2023-05-04 09:59:24 -07:00
Abtin Keshavarzian 356b4a6a58 [build] address new warnings with clang-14 (#8924)
This commit adds two small changes to address new warnings when
building with clang-14.

It also updates `mbedtls` CMakeLists to set `MBEDTLS_FATAL_WARNINGS`
option as `OFF` (so that compiler warnings are not treated as errors).
This avoid issues with new warning for `unused-but-set-variable` emitted
by clang-14.
2023-04-06 09:51:29 -07:00
Sam Kumar 65a8d520b1 [cli-tcp] add TLS mode to TCP CLI tool and TLS callbacks to TCP API (#8257)
This commit adds support for TLS in the TCP CLI tool, along with a
test of TLS functionality.

The main purpose of this is to provide an example of how to use
mbedTLS with TCPlp to run TLS. I felt it is important to have an
example because I expect that many applications that use TCP,
particularly those in which a Thread device exchanges data with a
device outside the Thread mesh, will need to run TLS over TCP for
security reasons.

A secondary benefit is to add TCP functionality to the TCP CLI
tool. Additionally, by having the example code be part of a "real"
application (the CLI tool), there is less risk of the code going stale
as OpenThread evolves.

I added an "expects" test for the TLS functionality in the CLI tool. I
also ran the code on two Nordic NRF52840-DK boards to make sure it
works.

The performance impact of TLS appears to be small. When using TCP
without TLS, I am able to achieve ~80 kb/s goodput between two
NRF52840-DK boards. With TLS in the same setup, I am able to achieve
~70-75 kb/s goodput.
2023-01-23 10:56:16 -08:00
Sam Kumar 9bb00f7e2d [tcplp] fix code scanning alerts relating to integer overflow in multiplication (#8578) 2022-12-22 17:11:10 -08:00
Yaoxing Shan 2592e3433a [tcplp] fix call to tcplp_sys_accept_ready() (#8327)
aAddr should be the source address not the destination address.
2022-10-26 04:38:25 -07:00
Sam Kumar 3d1bdf3317 [tcplp] fix bad memory access when refusing incoming TCP connection (#8291) 2022-10-17 09:10:47 -07:00
Abtin Keshavarzian 92f18c5c53 [cmake] add separate tcplp libraries for ftd and mtd (#8175)
This commit adds separate `tpclp-ftd` and `tcplp-mtd` libraries.
Each library is then `target_link_libraries()` with the related
`openthread-ftd/mtd`. This should help avoid situation where both
`openthread-ftd` and `openthread-mtd` are included as dependency
and linked and address linker failures under certain versions of
`clang`.
2022-09-20 15:43:19 -07:00
Sam Kumar 19f9ba20a3 [tcp] implement TCP Circular Send Buffer (#7867) 2022-09-19 10:30:48 -07:00
Sam Kumar dd02babfeb [tcplp] add test for contiguify functionality (#7868) 2022-09-12 21:54:33 -07:00
Sam Kumar 829632e33e [tcp] implement otTcpReceiveContiguify (#7634) 2022-08-19 10:12:40 -07:00
Sam Kumar 0126c5f44b [tcp] modify cbuf to be able to use all bytes provided by the user (#7634) 2022-08-19 10:12:40 -07:00
Steven Cooreman 0b41ae0a30 [crypto] allow selecting randomized ECDSA instead of deterministic (#7894)
There is no hard dependency in the Thread specification which requires
the use of deterministic signatures. On the contrary, looking at the
tinycrypt implementation, that one issues randomized ECDSA signatures
and seems to be quite happy with that.

This change does not change the default behaviour, which is to use
deterministic ECDSA when using the default MbedTLS backend. It does
however make it possible for platforms which have qualified hardware
entropy to select 'plain' ECDSA instead, which gives both a performance
and code size improvement on those platforms.
2022-08-08 10:27:12 -07:00
Sam Kumar d79468bb18 [tcp] add support for otTcpForwardProgress callback (#7583)
This commit adds support for the remaining TCP callback, which was not
yet supported.

Originally, the unimplemented callback was otTcpSendReady, which would
indicate to the application when new data added to the TCP send buffer
would be sent out immediately. There was also discussion of adding an
otTcpBytesAcked callback, which, together with the
otTcpSendByExtension() call, would allow a circular buffer to be
implemented efficiently on top of the otLinkedBuffer API.

Ultimately, it seemed best to generalize the otTcpSendReady callback
to include both cases where bytes are acked by the connection peer,
and where the send buffer drains, allowing new data to be sent
immediately. The reasoning behind this decision is that both the
otTcpSendReady and otTcpBytesAcked callbacks are triggered by the same
event --- an ACK received from the connection peer --- and that it may
require the application to have to "coordinate state" across
callbacks. Having a single callback function to indicate both
conditions seemed like it could simplify applications significantly.

The new, combined, callback is otTcpForwardProgress. This commit
implements support and documentation for this callback function.
2022-04-22 09:12:12 -07:00
Sam Kumar cda71d1b25 [tcp] remove extraneous #define and restrict inclusion of TCPlp headers (#7570)
* remove extraneous #define
* restrict inclusion of `third_party/tcplp/tcplp.h`
2022-04-07 10:42:17 -07:00
Jonathan Hui 9be687a1d0 [mbedtls] move mbedtls to 2.28.0 LTS version (#7539)
- Squashed 'third_party/mbedtls/repo/' content from commit 23e9e0bd2

git-subtree-dir: third_party/mbedtls/repo
git-subtree-split: 23e9e0bd2c7d1b5496773356d5a2c0c56d722d93

- update Makefiles
- update `check-android-build`
2022-04-07 10:35:51 -07:00
Sam Kumar 216b40e4bf [tcp] improve logging in TCPlp (#7379)
* Avoid printf, and omit newline at end of tcplp_sys_log calls
* Add new tcplp_sys_panic call to use for assertion failures
* Fix code in "#ifdef INSTRUMENT_TCP" so that it can be used
2022-01-31 14:32:36 -08:00
Sam Kumar 876aa82164 [tcp] add rewrite of TCPlp's interface code to support OpenThread's TCP API (#7190) 2022-01-27 21:48:52 -08:00
Sam Kumar a7b6eac41d [tcp] minor changes to FreeBSD-derived code for integration into OpenThread (#7190)
* update TCPlp #include guards to be TCPlp-specific

* do not use sys/queue.h in tcp_var.h, to avoid polluting global namespace

* avoid bitfields in TCP header structure

* use int32_t instead of int in tcpcb and reorder fields to eliminate padding
2022-01-27 21:48:52 -08:00
Sam Kumar 097ab86369 [tcp] update Android build to include TCPlp (#7190) 2022-01-27 21:48:52 -08:00
Sam Kumar 3fdaaab07c [tcp] fix minor bugs (#7335)
This commit fixes minor bugs in TCP.

1. The first change fixes a bug where the TCP CLI prints out an
incorrect message when a connection is terminated. This appears to
have been introduced in #7279.

2. The second change fixes a null pointer dereference when accepting a
TCP connection. This issue is purely theoretical at the moment,
because in the case where the dereferenced pointer is NULL, the
dereferenced value is not used, and so the compiler optimizes out the
memory access (so it seems). As a result, TCP actually runs without
issues. But I've fixed it anyway, to avoid depending on that behavior.
2022-01-19 19:56:13 -08:00
Eduardo Montoya 0b3f87c588 [cmake] make TCP configurable with OT_TCP option (#7306) 2022-01-18 11:31:39 -08:00
Yakun Xu 34b64d3c6a [tcplp] remove unused type defines (#7191) 2021-11-30 11:28:41 -08:00
Yakun Xu 43778e314d [tcplp] suppress warnings by target_compile_options (#7184)
Add the following options `-Wno-sign-compare` and
`-Wno-unused-parameter` with target_compile_options to suppress
warnings. These options will be appended to the end of options
inherited from COMPILE_OPTIONS and CMAKE_C_FLAGS.
2021-11-19 08:39:14 -08:00