36 Commits

Author SHA1 Message Date
Abtin Keshavarzian 55b3adbf81 [docs] fix double 'the' typos across the codebase (#13176)
This commit fixes instances of "the the" typos found in various
files across the codebase, including documentation, headers, source
files, and test scripts.
2026-05-29 17:34:54 -07:00
Kevin Zhao 06e2cdbf5c [github-actions] fix pwn-request vulnerability in size.yml workflow (#12625)
The size.yml workflow used pull_request_target with git checkout
FETCH_HEAD, which replaced the entire working directory (including
scripts) with untrusted fork code. Since pull_request_target grants
a read/write GITHUB_TOKEN even from public forks, and the workflow
had no top-level permissions restriction, this allowed arbitrary
code execution with write access to the repository.

Fix by:
1. Adding top-level permissions: contents: read (consistent with
   all other workflows in this repository).
2. Replacing `git checkout FETCH_HEAD` with a fetch-only approach
   that passes the PR merge commit SHA via the OT_SHA_NEW environment
   variable. The check-size script uses git-archive to extract code
   by SHA, so it does not need the working directory to be switched.
   This ensures ./script/check-size always runs from the base branch.
3. Updating check-size to accept OT_SHA_NEW from the environment,
   falling back to git rev-parse HEAD when not set (preserving
   existing behavior for push-triggered and local runs).
2026-03-05 16:27:33 -06:00
Yakun Xu d4734df8bb [size-report] checkout pull request head (#11724) 2025-07-15 10:48:46 -07:00
Yakun Xu f4e239e651 [size-report] migrate to GitHub Actions (#11681) 2025-07-14 16:01:32 -07:00
Yakun Xu 7bd3abd67b [script] allow specify old commit for check-size (#11147) 2025-01-10 09:41:56 -08:00
Yakun Xu b6a7f076c2 [script] enhance check-size for local use (#11116)
This simplifies doing local check by enhancing the script to accept
extra cmake options and specifying the commit to compare.

Example usage:

```bash
OT_SHA_OLD=e4a390f34 ./script/check-size nrf52840 -DOT_FULL_LOGS=ON
```
2025-01-06 16:20:04 -08:00
Jonathan Hui f3715b4596 [check-size] SC2004: $/${} is unnecessary on arithmetic variables (#10820) 2024-10-11 13:38:40 -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
Abtin Keshavarzian 5c051ffeb5 [script] check-size to generate formatted table on push (#9382)
This commit updates the `check-size` script to generate a formatted
table on a branch push. The table will first include the code size
difference for all binary files, followed by the difference for all
library files. This allows us to use the `check-size` script on local
machines during development to get a full size impact report, similar
to what will be reported on the GitHub Action branch push.

This commit also generates a size report for posting on a pull request
in Markdown format. In particular, the table with the size difference
for all library files is added as a collapsible section after the
main table for binary files.
2023-09-06 11:13:18 -07:00
Abtin Keshavarzian d5a09415be [script] update the check-size report (#9368)
This commit updates the `check-size` script and how the OpenThread
size report is generated and reported.

The size report now includes four device types:
- FTD (not acting as a BR)
- MTD (including SED)
- Border Router (BR)
- RCP

Each type uses its own example config header file (e.g., BR uses
`examples/config/ot-core-config-check-size-br.h`). These header files
specify all the OT configs and enable/disable the set of features
that make sense for the given type.

This replaces the previous model where the same set of configs were
used for all types. This change allows us to track the code size of a
typical BR build, as well as the code size of other device types.

In order to build and generate a size report for the BR configuration
example with BR-specific features enabled (such as Border Routing
Manager or NAT64), we need an implementation of the related platform
APIs that are used by these features (e.g. `otPlatInfraIf` APIs).
This commit adds mock empty implementations of these APIs, which are
only included in the size-report builds.
2023-08-25 11:29:39 -07:00
Abtin Keshavarzian 0f94f26a20 [net-diag] introduce Server and Client classes (#8936)
This commit introduces `Server` and `Client` classes breaking the
`NetworkDiagnostic` module into two components. The `Server` responds
to queries and requests (handling Net Diag TMF commands), while
`Client` issues queries/requests and processes responses. The
`Server` is available under both FTD and MTD (which follows the
requirement of Thread spec). The client is enabled using newly added
`OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE` config option which is
also available as `OT_NETDIAG_CLIENT` CMake option or the autoconf
build switch `NETDIAG_CLIENT`. The client functionality is by default
enabled on Border Routers (tied to `CONFIG_BORDER_ROUTING_ENABLE`
config).

The previous `TMF_NETWORK_DIAG_MTD_ENABLE` config is now removed
along with its CMake `OT_MTD_NETDIAG` and autoconf switch. This
commit adds checks to trigger build error if the previous config
and/or its related CMake option are used.
2023-04-07 15:58:07 -07:00
Abtin Keshavarzian 091f68ed70 [child-supervision] mechanism to inform interval from child to parent (#7993)
This commit contains changes to child supervision feature. It adds a
new mechanism for a child to inform its desired supervision interval
to its parent. A new optional MLE TLV is added with type 27 and value
of `uint16_t` indicating the supervision interval in seconds. This
TLV is included in MLE Child ID Request and MLE Child Update Request
(sent from the child). The parent echoes back this TLV in the
corresponding responses to indicate that it supports supervision. This
commit changes the parent implementation to track the supervision
interval per child.

This commit also updates the OT public APIs along with the related
CLI commands:
- API now allows the supervision interval to be set on a child.
- New field in `otChildInfo` to indicate the child's supervision
  interval.
- New counter is added to track the number of supervision check
  timeouts failures on a child (intended for testing and debugging).

This commit adds a test `test_child_supervision` to cover behavior of
child supervision and its new behaviors.

This change allows backward compatibility: If the parent does not
support child supervision, it ignores the new TLV in the MLE messages
and the child would fall back to periodically exchanging MLE Child
Update Request with parent. If the child does not support supervision
and/or does not indicate its desired child supervision interval, the
parent will fall back to use the configured default interval.
2023-02-28 23:01:43 -08:00
Jonathan Hui 48c0582e4e [shellcheck] fix SC2155 warning (#8490)
Declare and assign separately to avoid masking return values.
2022-12-07 16:23:20 -08:00
Jonathan Hui 0c48ade2ff [tests] change 1.2 builds to 1.3 (#7756) 2022-06-08 11:44:23 -07:00
Abtin Keshavarzian 95fa6220d7 [tmf] add AnycastLocator module (#6513)
This commit adds a new class `AnycastLocator` which can be used to
locate the closest destination of an anycast IPv6 address (i.e., find
the related mesh local EID and RLOC16). The closest destination is
determined based on the the current routing table and path costs
within the Thread mesh.

The implementation uses a CoAP confirmable post request to a newly
added URI path ("a/yl"). The destination IPv6 address of such as
request message is set to the anycast address to be located. The
receiver of the request message sends a CoAP response which includes
the "Mesh Local EID"  and "Thread RLOC16" TLVs.

This commit also adds support this new feature in CLI (adding a new
`locate <anycast-addr>` command).

Finally this commit adds `test_anycast_locator.py` to test behavior of
the new feature.
2021-09-17 08:04:44 -07:00
Jonathan Hui b9fadd227b [github-actions] use --no-check-certificates when invoking wget (#7011) 2021-09-15 19:58:03 -07:00
Abtin Keshavarzian ca3830fac2 [uptime] new feature to track OT instance uptime (in msec) (#6968)
This commit adds a new module `Uptime` which tracks the number of
milliseconds since OpenThread stack initialization as an `uint64_t`
value. It also adds public OT APIs to get the current uptime value
(either as the number of milliseconds or in human-readable string
format like "2 days 12:45:12.762"). A CLI `uptime` command is also
added. This feature can be enabled using the newly added config
option `OPENTHREAD_CONFIG_UPTIME_ENABLE` (or the related CMake
`OT_UPTIME` option).
2021-09-02 13:44:40 -07:00
Abtin Keshavarzian 2e625bfe39 [netdata] adding NetworkData::Publisher (#6768)
This commit implements a new feature "Network Data Publisher" which
provides mechanisms to limit the number of similar entries (service
and/or prefix) in the Thread Network Data by monitoring the Network
Data and managing if or when to add or remove entries. This feature is
enabled using `OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE` config, or
`NETDATA_PUBLISHER` in autoconf, or `OT_NETDATA_PUBLISHER` cmake
option.

This commit adds support for publishing DNS/SRP anycast/unicast
service, on-mesh prefix, and external route prefix entries.

When there is a request to publish an entry, the `Publisher` monitors
the Network Data and counts the number of similar entries. If there
are fewer entries than a desired target number, the entry is added
after a short random delay.

If there are too many similar entries, `Publisher` starts the process
of removing its own entry (again after some random wait time). When
removing entries, certain entries are preferred over others (e.g., an
entry from a router over one from an end-device or if they are from
the same type of node, the one with smaller RLOC16). If `Publisher`
determines that its own entry is a preferred one, it adds an extra
wait time before removing its entry. This gives higher chance for a
non-preferred entry from another device to be removed before removing
a preferred entry which helps towards quicker convergence of the
process to the desired number of entries.

On-mesh prefix and external route entries have a "preference" field.
When publishing such an entry, a matching entry in the network data is
counted only if its preference is same or higher than the entry's
preference. This ensures that a device with a higher preference entry
publishes its entry even when there are many lower preference similar
entries in the network data (potentially causing a lower preference
entry to be removed).

This commit also adds `test_netdata_publisher.py` to verify the
behavior of the `Publisher`.
2021-08-10 22:32:33 -07:00
canisLupus1313 126e232ad5 [link-metrics] split OPENTHREAD_CONFIG_MLE_LINK_METRICS_ENABLE macro (#6716)
This commit splits OPENTHREAD_CONFIG_MLE_LINK_METRICS_ENABLE macro
into two subsequent ones:
- OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
- OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
2021-06-22 10:49:53 -07:00
Yakun Xu 33012716ee [github-actions] download size reporter in workflow file (#6475) 2021-04-20 07:30:37 -07:00
Abtin Keshavarzian 06ca5d855c [utils] add 'Utils::PingSender' (#6284)
This commit adds a new module `Utils::PingSender`. This module
is then used by CLI to support ping command.
2021-03-19 16:04:55 -07:00
Yakun Xu ae88a2c677 [test] print size diff symbol by symbol (#6305)
This commit enhances the size check by printing size diff symbol by
symbol, which can help us better analyze size changes.
2021-03-19 13:20:38 -07:00
Yakun Xu a3e87b14fe [git] pull dependency pull requests (#6234) 2021-03-04 08:26:26 -08:00
Li Cao b7ba04f720 [github-actions] use cmake to build nrf in size action (#6126) 2021-02-22 15:37:41 -08:00
Simon Lin 89aacf5dd7 [dns-sd] DNS-SD server implementation (#6103)
This commit implements the DNS-SD server:
- Handle Standard DNS Query from clients
  - Supported resource records: PTR, SRV, TXT, AAAA
- Query services from SRP server
- Add tests
  - simulation test using DNS client (only test AAAA query)
  - OTBR test using dig command to verify all resource records can be
    queried successfully
2021-02-09 20:25:26 -08:00
kangping 1ec9fd525d [net] SRP server implementation (#5986)
This PR includes the initial implementation of the SRP server
defined in https://tools.ietf.org/html/draft-ietf-dnssd-srp-07.

- SRP server Service TLV propagation: Includes only the 2-bytes
  dynamic listening port in the Server TLV.
- SRP request processing (parsing & validation)
- LEASE & KEY-LEASE management
- SIG(0) verification
- Interface for advertising proxy
- CLI commands for testing
- Support removing indivitual SRP service
2021-01-22 13:19:21 -08:00
Abtin Keshavarzian 966baf5e6b [net] SRP client implementation (#6038)
This commit adds support for SRP (Service Registration Protocol)
client in OpenThread. The implementation allows a user to provide host
info (host name and a list of host IPv6 addresses) along with a list
of services to be registered with an SRP server. Services and/or host
addresses can be added or removed during operation of client.

Users can get the list of services and host info and their current
state (indicating, for example, if service is registered with server,
being registered or being removed, etc). Users can also provide a
callback to get notified whenever there is change or an error.

When there is a new request (e.g., a new service is added/removed)
that requires an update, the SRP client will wait for a short delay
before preparing and sending an SRP update message to server. This
allows user to provide more changes that are then all sent in the same
update message. The implementation handles retries in case of
different errors and failures. An exponentially increasing retry wait
interval (with configurable min, max, and growth factor) is
implemented.

The implementation also manages the lease renew time for each service
and refreshes (re-registers) services with server before lease is
expired. It supports "opportunistic early refresh" mechanism such that
when sending an SRP update, the services that are not yet expired but
are close, are allowed to refresh early and are included in the SRP
update. This helps place more services on the same lease refresh
schedule reducing number of messages sent to the SRP server. This
behavior (whether to allow early refresh or not, and its related
parameters) can be controlled through a set of OT config definitions.
2021-01-22 13:19:21 -08:00
Abtin Keshavarzian 1cac116526 [utils] adding 'DatasetUpdater' (#5807)
This commit adds a new module `DatasetUpdater` which provides
easy-to-use APIs for user to request an update to any component (a
subset of components) in Operational Dataset of the Thread network.
The change can be requested from any node in the network. The
implementation uses `MGMT_PENDING_SET` command and takes care of
preparing the Pending Dataset and updating timestamps and monitoring
for the Dataset to be updated and possibly retrying. It reports the
outcome (success or failure status) back to the user in a callback.

This commit also updates the `ChannelManager` module is to use the
`DatasetUpdater` to change the channel.
2020-11-23 16:27:54 -08:00
Yakun Xu 8367f00923 [memory] use heap for messages (#5792)
This commit adds an option to allow share heap memory with message
buffer pool.

For MTD, there is usually no border agent or commissioner service. This
change allows the heap for meshcop to be used by application or network
management data after the device is attached. Thus the total memory
usage can be reduced.
2020-11-12 18:37:51 -08:00
Li Cao 42fb2e44be [low-power] implement forward tracking series (#5608)
This commit implements the Forward Tracking Series feature in Link Metrics.

- Two new apis are added:
  - otLinkMetricsSendMgmtRequestForwardTrackingSeries, which is used
    to send an MLE Link Metrics Management Request
  - otLinkMetricsSendLinkProbe, which is used to send an MLE Link Probe

- A new class LinkMetricsSeriesInfo is used to maintain the data of
  one Series configured by a neighbor. This class inherits
  LinkedListEntry and each Neighbor has a list of
  LinkMetricsSeriesInfo. All LinkedListEntrys are allocated and freed
  by a Pool in LinkMetrics.

- To specify SeriesFlags in cli command for Forward Tracking Series, a
  similar approach with LinkMetricsFlags is used. Another character
  flags is used to represent SeriesFlags.

- Whenever the node receives a frame (including ACK) from a neighbor,
  it would call Neighbor::AggregateLinkMetrics which goes through each
  LinkMetricsSeriesInfo entry in the neighbor's list and aggregate the
  data if the frame type matches the entry.

- Two test scripts are added to test this function:
  - v1_2_LowPower_7_2_01_ForwardTrackingSeries.py
  - v1_2_LowPower_test_forward_tracking_series.py
2020-10-29 20:04:39 -07:00
Li Cao 3fd161e4d4 [low-power] enhance CSL transmission on NRF52840 using transmit_at (#5545) 2020-10-27 08:26:34 -07:00
Simon Lin 21b49e2e2b [size-report] add size-report for Thread 1.2 (#5424)
This commit adds size-report for Thread 1.2 features in the simplest
way that does not require any change to openthread-size-report on
Glitch.
2020-09-09 21:27:37 -07:00
Simon Lin a3860d6036 [size-report] retry multiple times (#5111) 2020-06-18 14:48:25 -07:00
Jonathan Hui cb9b353fb3 [scripts] apply shfmt changes (#4966) 2020-05-19 13:04:42 -07:00
Yakun Xu c034fd0c0c [size-report] support local check (#4866) 2020-04-21 15:37:46 -07:00
Yakun Xu fd6cde5981 [size-report] support github actions (#4825) 2020-04-16 23:22:01 -07:00