149 Commits

Author SHA1 Message Date
Jonathan Hui e1b34bc5bc [simulation] increase socket receive buffer size to 2MB (#13173)
This commit sets the SO_RCVBUF socket option to 2MB on the
multicast receiving sockets in the simulation platform.

Under heavy simulation load (such as expect tests with 15 nodes
all sending MLE advertisements and discovery packets), the default
OS UDP receive socket buffer can overflow, leading to silent
packet drops. This occasionally caused expect tests like
cli-big-table.exp to fail with "Join failed [NotFound]" because
Node 4's discovery requests or response beacons were dropped.

Increasing the receive buffer size to 2MB prevents packet loss
during dense simulation runs, resolving intermittent CI test
failures.
2026-05-28 16:52:16 -07:00
Jonathan Hui dcbd870245 [dhcp6] obsolete DHCPv6 Server Unicast Option per RFC 9915 (#13146)
This commit updates the DHCPv6 Prefix Delegation (PD) client to
comply with RFC 9915, which obsoletes the Server Unicast option
(Option 12) and the UseMulticast status code.

Changes:
- Removed `mServerAddress` and `ProcessServerUnicastOption()` from
  `Dhcp6PdClient`.
- Modified `Dhcp6PdClient::SendMessage` to always transmit via
  multicast to `ff02::1:2`.
- Removed `UseMulticast` status code handling in `HandleReply()`.
- Added `otMessageFree` weak stub in simulation platform's
  `infra_if.c` to resolve linking errors on simulation radio-only
  targets when DHCPv6 PD client is enabled.
- Updated `test_dhcp6_pd_client.cpp` to expect multicast and
  removed the obsolete UseMulticast test case.
2026-05-27 10:31:00 -07:00
Yakun Xu 06e210fe89 [sub-mac] redo security processing for every (re)transmission (#13093)
Retransmissions of frames containing time-dependent header Information
Elements (IEs), such as CSL or Time Sync, require updates to these
IEs to reflect the exact time of sending. If the frame counter is not
incremented for these retransmissions, it leads to nonce reuse in
AES-CCM encryption, which is a security vulnerability.

This commit addresses this issue by ensuring that every transmission
attempt (initial or retry) uses a fresh frame counter:
- Deferred security processing from `SubMac::Send()` to
  `SubMac::BeginTransmit()`.
- Upon retransmission in `SubMac::HandleTransmitDone()`, the frame is
  restored to plaintext via `TxFrame::DecryptTransmitAesCcm()` and
  security flags are cleared.
- This allows time-dependent IEs to be updated and a new frame counter
  to be assigned for every attempt.

Added a Nexus test case `retransmission_security` to verify that both
CSL and standard MAC retransmissions use incrementing frame counters
and updated CSL phases.
2026-05-26 10:36:55 -07:00
Yakun Xu 87fdaa6946 [simulation] add IPv6 loopback address support (#12828)
This commit adds support for IPv6 loopback address (::1) in the
simulation platform. When the local interface is set to the IPv6
loopback address, it uses the interface-local multicast group
(ff01::116) instead of the link-local group (ff02::116) for
node-to-node communication.

It also ensures that the `sin6_scope_id` is correctly set for the
loopback address in the transmission socket.
2026-05-07 07:37:40 -07:00
Abtin Keshavarzian c923900de0 [platform] implement otPlatLogOutput platform API (#12762)
This commit provides the platform-level implementation for the
instance-aware logging API `otPlatLogOutput()`. This API is used when
`OPENTHREAD_CONFIG_LOG_INSTANCE_AWARE_API_ENABLE` is enabled, allowing
the platform to receive the `otInstance` pointer with each log line.

The new API is implemented across:
- The simulation platform logging.
- The POSIX platform using `syslog()`.
- The NCP base to route logs to the NCP host.
- The CLI logging module.
- Unit tests and mock platforms.

The `OPENTHREAD_CONFIG_LOG_INSTANCE_AWARE_API_ENABLE` configuration is
also enabled for Toranj simulations to support multi-instance log
testing.
2026-03-25 21:21:24 -05:00
Abtin Keshavarzian cf733a331e [infra-if] add missing otInstance parameter to otPlatInfraIf APIs (#12662)
This commit updates the following `otPlatInfraIf` platform APIs to
include an `otInstance *` as their first parameter:

- `otPlatInfraIfHasAddress()`
- `otPlatInfraIfSendIcmp6Nd()`
- `otPlatInfraIfDiscoverNat64Prefix()`

Other APIs under `otPlatInfraIf` already follow this pattern. Passing
the `otInstance` pointer is the required standard for all platform
and public APIs; however, it was missed during the initial design of
these specific APIs.

While missing this parameter is often not a blocker on platforms using
a single OpenThread instance, it has become a blocker for simulations,
especially when multiple Border Routers are emulated in the same
simulation setup.

This change introduces a compatibility break for existing platform
implementations, however, it is necessary to support new use cases
(simulation of BRs). It also helps ensure consistent API design
across the stack.
2026-03-12 10:10:08 -05:00
Yakun Xu 8612d40adf [posix] update mdns-socket to support one-shot multicast DNS queries (#12558)
This commit fixes the problem where OpenThread mDNS responder always
sends responses to port 5353, ignoring the source port of the query.

According to RFC 6762, a mDNS responder should support one-shot
multicast DNS queries by sending the response to the source address
and source port of the query.

Changes:
- Captured the actual source port from incoming queries in Simulation
  and POSIX platforms.
- Updated otPlatMdnsSendUnicast in Simulation platform to use the
  provided destination port.
- Verified that legacy unicast responses correctly cap TTL to 10
  seconds as required by RFC 6762 section 6.7.
2026-02-25 21:34:14 -06:00
Esko Dijk 3061fa19de [otns] add default (weak) OTNS platform API implementation in core (#12308)
A default OTNS platform API function otPlatOtnsStatus() is now
provided that writes the status push to the log always (regardless of
configured log level). This is useful as a default handling for apps
built with -DOT_OTNS=ON, avoiding linker errors while not mandating
each platform to implement the API by itself.

Specifically it enables the Posix CLI app ot-cli to be built with OTNS
support, which is required to run Posix nodes in OTNS and receive the
status-push events via stdout logging.

The logging is emitted from the module named "Otns" so that a
simulator or other tool can easily detect the OTNS format status push
events in the log output.
2026-01-22 10:49:37 -08:00
Yakun Xu a3b8361a19 [simulation] set virtual UART at runtime (#12199)
This commit changes the virtual UART to be configured at runtime, which
eliminates a build variants, which causes code coverage process problem.
2025-12-09 08:48:37 -08:00
Yakun Xu 3e0920c575 [simulation] add APIs for select() based event loop (#12135)
This commit adds select API so that simulation and be integrated with
other mainloops.

This commit also adds a flag to disable UART on simulation platform.
2025-11-18 22:19:04 -08:00
Zhanglong Xia fab01a7f0f [simulation] use the CSL receiver's peer address to include CSL IE (#11905)
The description of the method `otPlatRadioEnableCsl()` requires the platform
to include the CSL IE in the enhanced ACK when the received data frame's source
address matches the CSL receiver's peer address. This commit implements this
requirement in the simulation radio.
2025-09-29 18:24:38 -07:00
arnulfrupp bb5585d412 [tcat] add tcat implementations and bug fixes (#11402)
Commit adds check if commissioning is possible and if the tcat device is already commissioned.
Adds advertisement update on disconnected and role change.
Fixes key handling for key references.
Fixes the authorization processing.
Implements recent changes of the application TLVs.
2025-07-30 12:27:10 -07:00
Li Cao 6c6e99ee7c [style] upgrade clang-format and clang-tidy from 14 to 16 (#11682) 2025-07-10 18:19:26 -07:00
Zhanglong Xia 4764e6e714 [diag] deprecate otPlatDiagRadioTransmitDone() and otPlatDiagRadioReceiveDone() (#11615)
The radio platform API otPlatDiagRadioTransmitDone() and
otPlatDiagRadioReceiveDone() are the same with the API
otPlatRadioTxDone() and otPlatRadioReceiveDone(). This commit removes
the API otPlatDiagRadioTransmitDone() and otPlatDiagRadioReceiveDone()
to let the MAC layer and the diag module to use the same radio API to
send and receive 154 frames. So that the diag module could process the
ACK frame in the future.
2025-07-09 08:14:18 -07:00
Abtin Keshavarzian a495a2284b [otns] make various enhancements to Otns (#11643)
This commit contains various enhancements to the `Otns` class:

- Makes `Otns` methods non-static. This aligns their use with the
  clang-tidy `readability-static-accessed-through-instance` check,
  which disallows accessing static methods through an instance.
- Updates the `make-pretty` script to enable OTNS and include it in
  `clang-tidy` checks.
- Adds a stub implementation of `otPlatOtnsStatus()` in the simulation
  and fake platforms. This allows the OTNS feature to be enabled in
  `make-pretty` builds and covered by GitHub Action CI checks.
- Simplifies the `EmitStatus` methods to use the `String` class for
  constructing the status string.
- Adds a new helper method to construct the CoAP status string,
  removing duplicated code.
2025-06-30 14:39:30 -07:00
Abtin Keshavarzian f90d50b220 [dhcp6] implement DHCPv6 Prefix Delegation (PD) client (#11584)
This commit introduces the `Dhcp6PdClient` class, which implements
DHCPv6 Prefix Delegation (PD) client functionality. It integrates
with `BorderRouter::RoutingManager` and its `PdPrefixManager`
sub-component. The CMake `OT_BORDER_ROUTING_DHCP6_PD_CLIENT` mapped
to `OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE` config
enables this feature.

Previously, the platform layer was expected to implement client
functionality, acquiring and providing the delegated prefix(es) to
the OT stack using `otPlatBorderRouter*` callbacks. This approach
continues to be supported. The `Dhcp6PdClient` feature adds native
support for this functionality in the OpenThread core.

The `Dhcp6PdClient` implementation follows RFC 8415, focusing on
prefix delegation and all required behaviors. The client follows the
standard four-message Solicit/Advertise/Request/Reply exchange to
obtain a delegated prefix, followed by a two-message Renew/Reply or
Rebind/Reply exchange to extend the lifetime of the delegated prefix.
When the prefix is no longer needed, a two-message Release/Reply
exchange ends its lease. The current client implementation does not
support the optional "Reconfigure Accept" mechanism.

A set of `otPlatInfraIfDhcp6PdClient*` platform APIs are also
introduced for use by the `Dhcp6PdClient`. These APIs are used to
enable or disable listening for DHCPv6 messages and to handle sending
and receiving them on the standard client and server UDP ports
(546 and 547), effectively acting as a UDP socket.

This commit also includes a comprehensive unit test covering various
aspects of `Dhcp6PdClient`, including common behaviors and many
specific edge cases.
2025-06-20 19:35:44 -07:00
Yakun Xu 1662ca8001 [simulation] add reliable virtual time transport (#11029)
This commit adds a reliable transport based on SEQPACKET unix socket to
simulation platform and use this for tests on simulation platform.
2025-06-04 23:32:25 -07:00
Esko Dijk 1804273276 [posix] set sin6_scope_id / ipi6_ifindex for all transmits to link-local (#11555)
This will avoid the problem that scope id or ifindex remains 0 for a
link-local transmission. If 0, the OS cannot decide which network
interface to use based on address alone.
2025-06-03 09:22:41 -07:00
Yang Song 1f54a868cf [dns] signal an error immediately when no upstream DNS server available (#11480)
Currently, if the platform has no upstream DNS server configured,
upstream DNS query will eventually time out. This can lead to delays
in responding to the DNS client.

The new otPlatDnsIsUpstreamQueryAvailable API provides a mechanism for
the platform to proactively signal the unavailability of upstream DNS.
2025-05-20 14:50:18 -07:00
Abtin Keshavarzian 20aefc2215 [dnssd] support generic record queries via discovery proxy and SRP (#11357)
This commit enhances the OpenThread DNSSD name server/resolver and its
native Discovery Proxy to support queries for arbitrary record
types.

To enable this, a new set of `otPlatDnssd` APIs are introduced for
generic `RecordQuerier`. These APIs mirror the existing APIs in the
OpenThread native mDNS module, allowing direct use of the native mDNS
implementation.

The discovery proxy implementation is updated to start and stop the
mDNS `RecordQuerier` when receiving a query for an arbitrary record
type, passing the first response record back to the client.

The unit tests `test_dnssd_discovery_proxy` and `test_dns_client`
are updated to cover all the newly added behaviors in discovery proxy.
2025-04-23 12:14:05 -07:00
Zhanglong Xia c1c5db8f20 [utils] check whether mInfo.mTxInfo.mIeInfo is null before using it (#11238)
The simulation platform radio driver doesn't set the 'mInfo.mTxInfo.mIeInfo'
field of the ACK frame. And the function 'otMacFrameUpdateTimeIe()' directly
use the 'mInfo.mTxInfo.mIeInfo' field, this may cause the program crash.

This commit checks whether 'mInfo.mTxInfo.mIeInfo' is null before using it
and sets the 'mInfo.mTxInfo.mIeInfo' field of the ACK frame to null in
simulation platform.
2025-02-12 10:24:34 -08:00
Abtin Keshavarzian d1147d62b9 [trel] detect and handle socket addr discrepancy for TREL peers (#10869)
This commit introduces a new mechanism for the TREL link to detect and
handle discrepancies between the IPv6 address and port used by a TREL
peer in a received TREL packet, and the information previously
reported by the platform layer (through DNS-SD discovery) for the
same peer.

Ideally, the platform underlying DNS-SD should detect changes to
advertised ports and addresses by peers. However, there are
situations where this is not detected reliably.

As a received frame over the TREL radio link is processed by the MAC
or MLE layers, if the frame passes receive security checks at either
layer (indicating it is a secure and authenticated/fresh frame from a
valid neighbor), the TREL peer socket address is automatically
updated from the received TREL packet info. This ensures the TREL
peer table is updated correctly if there are changes to TREL peer
addresses of valid Thread neighbors upon rx from such neighbor,
increasing the robustness of the TREL link.

This commit also introduces a new `otPlatTrel` platform API,
`otPlatTrelNotifyPeerSocketAddressDifference()`. The TREL
implementation now notifies the platform layer whenever it detects a
discrepancy in a TREL peer's socket address, regardless of whether
the peer table is automatically updated. This allows the platform
layer to take any appropriate action, such as restarting or
confirming DNS-SD service resolution query for the peer service
instance and/or address resolution query for its associated host
name.

This commit also adds a new test that validates the newly added
behavior, including the auto-update of peer table information and
notification of the platform through the new API, triggered by either
MLE or MAC messages over the TREL radio link.
2024-12-18 20:35:58 -08:00
Zhanglong Xia c44538e4df [simulation] enable the platform assert (#10952)
When the ot-rcp enters the assert state, the host crashes and exits.
But the ot-rcp still runs in the dead loop and becomes an orphan
process.

This commit enables the platform assert so that the ot-rcp can
automatically exit when entering the assert state.
2024-11-22 16:48:51 -08:00
Zhanglong Xia 7f6723ffb3 [log] add build option OT_LOG_MAX_SIZE to set the max log string size (#10948) 2024-11-20 20:06:35 -08:00
Zhanglong Xia 51169ac032 [simulation] log the exit code when the program exits (#10936)
Sometimes `ot-rcp` will exit without any exit information in the
log. It is hard for developers to know what happens on the `ot-rcp`
side when the `ot-rcp` exits abnormally. This commit calls functions
defined in `lib/platform/exit_code.h` to exit the program and log the
exit information.
2024-11-20 07:22:47 -08:00
Abtin Keshavarzian 444d1dd6bc [mle] implement alternate RLOC16 usage during role transition (#10006)
This commit introduces a mechanism for a device transitioning from
child to router role to keep receiving frames addressed to its
previous short address for a brief period.

A new radio platform API, `otPlatRadioSetAlternateShortAddress()`, is
introduced. This allows the OT stack to configure an alternate short
address. Radio platform support for this function is indicated by the
`OT_RADIO_CAPS_ALT_SHORT_ADDR` capability in `otPlatRadioGetCaps()`
The same function can be used with `OT_RADIO_INVALID_SHORT_ADDR`
(`0xfffe`) to clear a previously set alternate short address. Support
for the new API is implemented in RCP and `RadioSpinel`, ensuring
backward compatibility by dynamically checking supported radio
capabilities.

MLE code is updated to instruct the radio to use the old child RLOC16
as an alternate address upon role transition. The MLE layer will
automatically clear the alternate address after eight seconds, or if
other state/mode changes occur. This eight-second window ensures the
new router can transmit four MLE Advertisement messages.
2024-10-30 16:38:10 -07:00
Li Cao 74cdd26085 [ncp] add empty implementation for dnssd platform APIs (#10877)
This commit adds empty implementation for a NCP based version of
otPlatDnssd APIs.

Like NCP version of otPlatInfraIf APIs, this commit adds a control
option to enable/disable the simulation platform version of
otPlatDnssd APIs to avoid conflict. By default, the simulation version
of implementation will still be turned on.
2024-10-30 13:10:30 -07:00
Yakun Xu 2ea0155129 [radio] fix ACK frame counter with previous key (#10816)
This commit tracks the frame counter used for the previous key index and
use it for the ACK frame to a frame still using previous key index.
2024-10-11 08:24:51 -07:00
Jonathan Hui c182933979 [doxygen] remove empty line at end of block (#10748) 2024-09-24 09:51:34 -07:00
Abtin Keshavarzian 4a57dd8e09 [include] fix #include style for public OT headers (#10710)
This commit updates `#include` of public OT headers to follow
the OT style guide and use brace (`<`) and (`>`) style.
2024-09-17 12:13:34 -07:00
Yakun Xu dccc5193af [radio] add a helper of SFD handler (#10670)
This commit adds a helper of SFD handler to deal with IEs and security
needs to be processed in SFD handler from ISR.
2024-09-12 23:02:07 -07:00
Li Cao c36c0ed760 [ncp] add NCP based implementation (empty) of platform InfraIf APIs (#10638)
This implementation will be used on all platforms for NCP nodes
(simulation, any vendor platforms). However the simulation platform
already has a different implementation. To avoid conflicts, the commit
adds a control flag in simulation config so that we can choose whether
to enable the simulation implementation.
2024-09-04 07:48:59 -07:00
Yakun Xu 2493658d6a [config] disable uptime logging when multi-instance enabled (#10659)
This commit soften enabling log uptime in simulation and posix platform
so that it won't be enabled when multiple instance is also enabled.
2024-09-03 13:05:58 -07:00
Yakun Xu 3c6b8a3dd2 [time] unify macros for time unit conversion (#10636)
This commit unifies macros used for time unit conversion so that we
don't need to define it on different components.
2024-08-26 20:26:31 -07:00
Yakun Xu e219fe92f1 [mac] support frames without sequence number (#10544)
This commit adds the capability to support frames without sequence
number.
2024-08-02 09:50:45 -07:00
Zhanglong Xia 215c23f2a6 [diag] add diag output callback (#10354)
The length of diag output messages is limited by the diag buffer size.
Developers have to change the diag buffer size to allow diag module to
output long messages. If diag output messages become longer and
longer, developers have to keep changing the diag buffer size.

This commit adds an output callback to diag module to output diag
messages.  Then the length of diag output messages won't be limited by
the diag buffer size.
2024-06-19 20:27:35 -07:00
Li Cao fc0646c6eb [simulation] fix tiny issue of infra if (#10402) 2024-06-18 10:38:59 -07:00
Abtin Keshavarzian 5dbbab175b [dnssd-server] implement DNS-SD discovery proxy functionality in core (#10050)
This commit implements a generic discovery proxy in the DNS-SD server.
It uses a set of newly added `otPlatDnssd` platform DNS-SD(mDNS) APIs
to start or stop browsers, SRV/TXT resolvers, and IPv6/IPv4 address
resolvers. These APIs closely match the native OpenThread mDNS
implementation.

OpenThread DNS-SD's existing `QueryCallback` mechanism, enabling
customized discovery proxy implementations, remains supported.

This commit includes a comprehensive unit test. This test validates
the discovery proxy's behavior, covering: standard use cases, request
timeout, s hared resolver/browser usage for multiple queries with the
same name, filtering of invalid addresses, and various edge cases.
2024-06-10 12:16:24 -07:00
Przemysław Bida 398df8c408 [tcat] implement tcat advertisement (#9858)
Commit introduces implementation of TCAT advertisement over BLE
compliant with Thread 1.3.1 specification.
2024-06-06 11:26:59 -07:00
Yakun Xu f97a01c40d [simulation] rename local host to local interface (#10241)
This commit renames command line argument --local-host to
--local-interface to reduce confusion as discussed in #10194.

This commit also add help message for local interface.
2024-05-15 11:04:37 -07:00
Yakun Xu 39ce8117a5 [simulation] support simulating radio over IPv6 (#10194)
This commit adds support to simulate Thread radio over IPv6.

With this commit, a simulation will be simulated over either IPv6 or IPv4.
If it's simulated on IPv6, it communicates with other simulation nodes
in IPv6 group `ff02::116`. And if it's simulated on IPv4, it communicates
with other simulation nodes in IPv4 group `224.0.0.116`.

Note that simulating virtual time is not included in this commit.
2024-05-13 09:27:54 -07:00
Abtin Keshavarzian b8f036a570 [simulation] remove example log lines from otPlatLogCrashDump() (#10137)
This commit removes the `LogCrit` example lines emitted from
`otPlatLogCrashDump()` in simulation platform. These extra log
lines can cause test failures.
2024-05-02 12:02:10 -07:00
Mason Tran 502797c0b3 [spinel] add support for logging crash dumps (#10061)
This commit adds a new feature that allows platforms to log crash logs.

### Additions
- `void otPlatLogCrashDump(void)` - API that logs a crash dump using
  OpenThread Logging APIs
- `SPINEL_PROP_RCP_LOG_CRASH_DUMP` - spinel prop that calls
  `otPlatLogCrashDump()` when `Set`
- `SPINEL_CAP_RCP_LOG_CRASH_DUMP` - spinel capability denoting that a
  RCP supports logging crash dumps

### Usage
- For `ot-cli-ftd|mtd`, `otPlatLogCrashDump()` is called at the end of
  app initialization, before the main loop. See [main.c]
- For Host/RCP setups, during initialization, the Host gets the RCP
  capabilities. If the RCP has the `SPINEL_CAP_RCP_LOG_CRASH_DUMP`
  capability, the Host will `Set` the `SPINEL_PROP_RCP_LOG_CRASH_DUMP`
  property, triggering the RCP to call `otPlatLogCrashDump()`.
  - If RCP Recovery is enabled, the this will also happen once the RCP
    has been restored
2024-04-29 09:09:54 -07:00
Abtin Keshavarzian bf41332061 [mdns] add native mDNS support in OT (#9797)
This commit introduces native mDNS support within the OpenThread
stack, implementing RFC 6762 compliant registration of hosts,
services, and keys. It supports the following functionalities:

- Sending probes to claim names.
- Sending announcements on initial registration and changes.
- Sending "goodbye" announcements when unregistered or upon record
  removal.
- Negative responses (NSEC).
- Support for service sub-types and their addition/removal.
- Support for `_services._dns-sd._udp` queries (all service types).
- Responding to queries (including "QU" questions).
- Delay mechanism when responding to multi-question query messages,
  ensuring unique answers.
- Providing extra records in the Additional Data section if not
  already in the Answer section (e.g., on a PTR query, include SRV
  and host AAAA addresses).
- Implementing Known-Answer Suppression.
- Supporting multi-packet queries with known answers in follow-up
  messages.
- Rate-limiting record multicasts (once per second).
- Rate-limiting probe responses (once per 250ms).
- Detecting conflicts after probes.
- Limiting the size of emitted responses or probes, breaking into
  multiple messages if necessary.
- Detecting self originating messages (sent by mDNS module).
- Support for service browser.
- Support for service resolvers (SRV and TXT records) and IPv4/IPv6
  address resolvers for hostnames.
- Introduces smart cache management:
  - Passively caches service records for active browsers.
  - Passively caches address records for active service resolvers.
- Enables multiple simultaneous browsers/resolvers for the same
  service/host.

This commit introduces public `otMdns` OpenThread APIs and related CLI
commands for the mDNS module.

For platform abstraction, `otPlatMdns` APIs are defined in
`mdns_socket.h` (e.g., to send or receive mDNS messages):

- An implementation of the platform APIs is provided for posix.
- Also under the simulation platform, a simplified implementation of the
  `otPlatMdns` APIs is provided (intended for testing).

This commit also adds a detailed `test_mdns` unit test, validating
various functionalities and covering potential edge cases.
2024-04-09 08:32:01 -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
Yakun Xu 3ebc3d3a06 [simulation] allow specify local host (#9925)
This commit adds a argument `-L`/`--local-host` to simulation platform
to specify the source IP address for packets simulating 15.4
frames. This allows the simulation packets being transmitted over
different network interfaces, so that the simulation can run on
different hosts.

This can be used to enable multiple emulation devices(e.g. Android
Virtual Device) communicating to each other over emulated Thread
radio.

The argument accepts either an IPv4 address or a network interface
name. In the latter case, the first found IPv4 address on that
interface will be used will be used.
2024-03-13 11:42:53 -07:00
Abtin Keshavarzian 39fcc5ea53 [simulation] implement otPlatInfraIf APIs in simulation platform (#9895)
This commit implements a subset of `otPlatInfraIf` platform APIs in
simulation platforms using the `utilsSocket` to emulate communication
between BRs. This can be used for testing.

This commit also adds one (simple) example test case with two BRs
attached to two different network on same infra-if.
2024-03-06 13:26:06 -08:00
Abtin Keshavarzian 5960215508 [simulation] add simul_utils.h for socket operation helpers (#9879)
This commit introduces a new module, `simul_utils.h`, under
`simulation` platform. This module provides common utility functions,
primarily related to socket operations (for emulation of radio or
TREL interface). The new functions are used by `radio.c` and
`trel.c`, consolidating code and preventing repetition.
2024-02-28 11:28:00 -08:00
Abtin Keshavarzian b212a0a748 [srp] implement AdvertisingProxy and define Dnssd platform APIs (#9268)
This commit adds a generic SRP Advertising Proxy implementation to
OpenThread core, which uses a set of newly defined `otPlatDnssd`
platform APIs for DNS-SD (mDNS) support on infrastructure network on
a Border Router.

`Srp::Server` provides `ServiceUpdateHandler` callback mechanism that
allows platforms to implement their own advertising proxy function.
While this is still supported, the new generic advertising proxy
implementation makes it easier to port and support the proxy function
on new platforms. The platform needs to provide the DNS-SD platform
APIs, which are designed to be simple and easy to implement.

The `AdvertisingProxy` directly interacts with `Srp::Server` and its
registered `Host` and `Service` entries, tracking whether an entry
has been successfully advertised, is currently being advertised, or
has been replaced by a new registration.

The `AdvertisingProxy` ensures that consecutive SRP updates for the
same host or service are committed on the server in the order they
are received, even if their advertisements are finished in a
different order. This is important for SRP Replication support, as
the server may receive a large number of SRP updates back-to-back for
the same host.

The `AdvertisingProxy` will also register key records for SRP host and
service instance names. This will keep the claim on the name of a
removed entry while its key lease is not expired. It is also used
when an SRP host registration has no off-mesh routable address.

This commit adds a detailed unit test `test_srp_adv_proxy` that
validates the `AdvertisingProxy` under many scenarios. The test
covers a range of cases, including delayed registration callbacks and
timeouts, new registrations replacing outstanding advertisements,
platform DNS-SD state changes and failures, host address changes
adding/removing OMR addresses.
2024-02-09 10:43:47 -08:00
Maciej Baczmański 84e0e77ce2 [radio] add API for resetting CSL parameters (#9772)
Add `ResetCsl` and `otPlatRadioResetCsl`
This allows handling stack reset as separate call instead of
using `kShortAddrInvalid` as `otShortAddress` and
`nullptr` as `otExtAddress` which can be difficult to handle
on vendor's side.

Default implementation still calls
`otPlatRadioEnableCsl(aInstance,0, Mac::kShortAddrInvalid, nullptr)`
So no action is needed if vendor has already implemented handling
this case.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-01-22 16:37:22 -08:00