Commit Graph

7482 Commits

Author SHA1 Message Date
Jonathan Hui dc6bf363dd [docs] update Code of Conduct to Contributor Covenant v2.1 (#9627) 2023-11-21 10:14:41 -08:00
gytxxsy ebdc026779 [spinel] expose RestoreProperties as a public method within RadioSpinel (#9501)
When running border routers, users have the option to perform RCP
firmware updates. After completing the update, users prefer not to
restart or reinitialize the master device but only want to restart and
restore the RCP device.

Restarting can be initiated by the user; for example, they can restart
the RCP device by triggering the reset pin. However, after this
restart is done, certain RCP information needs to be restored, such as
the panid and extended address.

Typically, the master device can restore the RCP by triggering
`RecoverFromRcpFailure`, but this behavior is not
user-controllable. So there's a need to implement a callable API for
RCP restoration.

If the `RestoreProperties` is made public, users can actively restore
the RCP by calling it and some other public functions.
2023-11-21 10:13:29 -08:00
Li Cao 1d4e6571f9 [cli] make linkmetrics cli as a separate module (#9619) 2023-11-21 09:48:27 -08:00
Konrad Derda 30c94db4a4 [message] add API functions to enable multicast looping of a message (#9524)
At the moment, C API does not allow to get/set the configuration flag
which the message to be looped back to the Thread interface. It is
important within the context of sending already prepared IPv6 mutlicast
packets with `otIp6Send()`.
2023-11-20 19:22:19 -08:00
Yakun Xu 9165bc62d7 [simulation] SIGHUP when parent dies (#9624) 2023-11-20 17:48:17 -08:00
Abtin Keshavarzian 34dd612008 [routing-manager] learn and copy M & O flags from discovered routers (#9607)
This commit implements a mechanism in `RoutingManager` to learn the
Managed Address Config `M` and Other Config `O` flags in received RA
message from discovered routers on the infrastructure link and copy
the same flags in the emitted RA message from BR.

If any discovered router on the infrastructure that is not itself a
stub router (i.e., does not include the Stub Router flag) includes
the `M` or `O` flags, the same flag are included in the emitted RA
message. If a discovered router has failed to respond to the maximum
number of NS probe attempts, we consider it as offline and ignore its
flags.

This commit also adds a detailed test case in `test_routing_manager`
to validate the newly added mechanism.
2023-11-20 16:37:08 -08:00
jrhodie 364e315768 [cli] add Doxygen tags to SRP commands (#9615) 2023-11-20 16:18:25 -08:00
Yakun Xu beea7bac68 [lint] explicitly initialize failedAddresses (#9622)
Compiling with GCC 13.2.0, got the maybe-uninitialized error. This
commit fixes it by initializing the array.
2023-11-20 15:22:14 -08:00
Abtin Keshavarzian 6f3b4317d6 [routing-manager] new API to get list of discovered routers (#9601)
This commit adds `otBorderRoutingGetNextRouterEntry` as a new API to
iterate over discovered routers on the infrastructure link and get
information about them such as their address, their Managed Address
Configuration (`M`), Other Configuration (`O`), and Stub Router
flags.

The `otBorderRoutingPrefixTableEntry` is also updated to contain
the same information.

This commit also updates the CLI `br` sub-commands to provide this
information, adding `br routers` to obtain a list of discovered
routers.
2023-11-20 11:49:26 -08:00
hastigondaliya 0bb9eeb500 [posix] clear SPI tx buffer after usage (#9567)
This commit clear "mSpiTxPayloadSize" buffer once packet has been
successfully transmitted.
2023-11-20 11:33:51 -08:00
dependabot[bot] ece7943a0e github-actions: bump actions/upload-artifact from 3.1.2 to 3.1.3 (#9625)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/0b7f8abb1508181956e8e162db84b466c27e18ce...a8a3f3ad30e3422c9c7b888a15615d19a852ae32)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-20 08:26:11 -08:00
Abtin Keshavarzian 6e7ed5cb55 [encoding] avoid the use of using for Big/LittleEndian functions (#9621)
This commit refactors the code to eliminate the use of `using` for
`BigEndian` or `LittleEndian` functions like `HostSwap` and `ReadUint`.
As these functions are frequently used in header files, using the
direct namespace enhances code safety by mitigating potential conflicts
arising from the order of included headers in the absence of explicit
`using` declarations. Generally, avoiding the `using` keyword in headers
is considered a recommended practice.

Additionally, this commit removes the `Encoding` namespace to shorten
the full function names.
2023-11-19 21:19:13 -08:00
Abtin Keshavarzian ce9edaf8b5 [num-limits] add kBitsPerByte, BitSizeOf(), and BytesForBitSize() (#9618)
This commit removes the use of `CHAR_BIT` in the code and instead
defines a constant `kBitsPerByte` for this in `numeric_limits.hpp`.
`CHAR_BIT` is generally defined as `8` but there are some platforms
were this may not be the case. The way we use `CHAR_BIT` is to
determine number of bits in a byte, so introducing our own constant
`kBitsPerByte` helps improve code readability and safety.

This commit also adds `BitSizeOf()` macro which is similar to `sizeof()`
but returns the number of bits of a given type or variable. Macro
`BytesForBitSize()` is also added which returns the number of bytes
needed to represent a given bit size. This replaces the
`BitVectorBytes()` macro previously defined in `encoding.hpp`.
2023-11-19 20:10:40 -08:00
Abtin Keshavarzian 7936f8bcf9 [core] add missing platform function for OT_PLATFORM_KEY_REF (#9620)
This commit contains the following changes:
- Adds `CMake` option `OT_PLATFORM_KEY_REF`, corresponding to the
  existing `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE`
  config.
- Add empty implementations of `otPlatCryptoEcdsa{}` under the
  simulation platform.
- Modifies `test_platform.cpp` to ensure that the key-ref related APIs
  are defined only when the key reference feature is enabled.
- Updates `toranj/build.sh` script to provide the option to enable the
  key reference feature.
- Updates GitHub workflow to validate build with key reference feature
  under simulation platform, ensuring that future PRs are validated
  with this feature enabled.
2023-11-19 18:49:30 -08:00
Abtin Keshavarzian 657b973bb2 [dns] support longer key length in otDnsTxtEntryIterator (#9616)
This commit introduces `OT_DNS_TXT_KEY_ITER_MAX_LENGTH` with a value
of `64` to represent the maximum TXT data key length supported by
`otDnsTxtEntryIterator`. We intentionally set this value higher than
the recommended maximum key length of `9` (as specified in RFC 6763
section 6.4) to enable the parsing of TXT data when longer keys are
employed.
2023-11-19 18:47:21 -08:00
Abtin Keshavarzian 23c0fc4d4b [test] define all unit tests in ot namespace (#9617)
This commit updates unit test modules to be defined under the `ot`
namespace. This aligns all the unit tests to follow the same
model, eliminating the need to use `ot::` prefix in unit test
code.
2023-11-19 18:40:20 -08:00
Abtin Keshavarzian b77573586c [joiner-router] enhance & fix appending TLVs to Joiner Entrust msg (#9614)
This commit updates `JoinerRouter::PrepareJoinerEntrustMessage()` to
improve how TLVs from Active Operational Dataset are appended to the
message. The TLV types that should be included in Joiner Entrust are
now defined in an array `kTlvTypes`, and the code iterating over this
array will find the TLV in Dataset and append it to the message.

Previously, if a required TLV type was not present in the Dataset, the
code would have appended the TLV with an uninitialized and possibly
random value, which could lead to unexpected behavior. The new code
will fail if the required TLVs are not present in the Dataset
instead, ensuring that only valid TLVs are included in the Joiner
Entrust message.
2023-11-17 21:45:48 +01:00
Kangping 02ccb9a506 [posix] more robust netlink message handler (#9613)
Check and ensure at least the netlink header is received in the netlink
socket to be safe before intepreting the buffer as a netlink message.

Per https://linux.die.net/man/3/netlink, should make sure
current message type is not NLMSG_DONE before calling NLMSG_NEXT
to properly handle multi-part netlink message.
2023-11-17 21:39:54 +01:00
Abtin Keshavarzian 700f6247e5 [mle] add ChannelTlvValue to use in ChannelTlv & CslChannelTlv (#9612) 2023-11-16 08:47:12 +01:00
Abtin Keshavarzian f596a2ae99 [cli] remove extra line in trel peers docs in README.md (#9611) 2023-11-16 08:29:48 +01:00
Abtin Keshavarzian 7d41c9e27a [mle] remove MleRouter class definition under MTD build (#9610) 2023-11-16 08:23:41 +01:00
Tom Rebbert 5c34ca2cc3 [mle] fix responding to "Child Update Request" from non-parent device (#9609)
After a router with children downgrades, it's former children will
still send child update requests until they timeout. This allows the
downgraded device to respond with status TLV indicating error to help
those children realize they need to reattach sooner.
2023-11-16 04:34:50 +01:00
aalami90 68426231a5 [cli] adding set ipv4 CIDR for NAT64 in README (#9511) 2023-11-16 00:21:01 +01:00
Abtin Keshavarzian 22fcb0effe [test] ensure to FinalizeTest() in TestProcessPlatfromGeneratedNd() (#9606) 2023-11-15 08:03:44 +01:00
Eduardo Montoya 193e77e40e [radio] add OT_RADIO_CAPS_RX_ON_WHEN_IDLE capability (#9554) (#9554)
Add a new `OT_RADIO_CAPS_RX_ON_WHEN_IDLE` radio capability which lets
OpenThread know what the radio idle state operation will be: receive
or sleep.

This allows to save power on sleepy devices since the active --> idle
transition is much faster, specially for the cases in which there is
some kind of serialization between OpenThread core and the radio
driver.
2023-11-14 11:46:10 +01:00
Abtin Keshavarzian 86215fc31c [mle] define IsRouterIdValid() helper in mle_types.hpp (#9598) 2023-11-14 11:43:21 +01:00
dependabot[bot] 588d55cfc7 github-actions: bump docker/setup-buildx-action from 2.9.1 to 3.0.0 (#9600)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2.9.1 to 3.0.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/4c0219f9ac95b02789c1075625400b2acbff50b1...f95db51fddba0c2d1ec667646a06c2ce06100226)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-14 11:42:36 +01:00
Abtin Keshavarzian 6eb358f6e3 [test] address occasional failure of test_routing_manager (#9603)
This commit addresses occasional failures in `test_routing_manager` in
the `TestBorderRoutingProcessPlatfromGeneratedNd` case. Unlike other
tests, this test sets the `heapAllocations` after the call `InitTest
(/* aEnableBorderRouting */ true)` (which enables `RoutingManager`).
This means that depending on the random timing, the `heapAllocations`
may already count some allocated heap items by `RoutingManager`
itself. With the change in this commit, at the end of the test, we
check that the number of remaining heap allocations is less than
`heapAllocations`.
2023-11-14 11:42:18 +01:00
Abtin Keshavarzian f239c49d78 [toranj] update config header to use OT_LOG_LEVEL_INFO (#9595) 2023-11-10 11:01:08 -08:00
Abtin Keshavarzian 1723ae9d71 [routing-manager] check mIsRunning in ScheduleRoutingPolicyEvaluation() (#9594) 2023-11-10 09:48:16 -08:00
Abtin Keshavarzian cd425ebdc1 [multi-radio] perform tag duplication check for first fragment (#9590)
This commit updates the duplicate detection mechanism for the frag
header tags under `MULTI_RADIO` config. The tag check is now
performed upon receiving the first fragment. For subsequent
fragments, older tags are permitted to be processed, but they will be
discarded if there is no matching entry in the reassembly list.

This change addresses an issue where lowpan fragment frames using
older tags could be erroneously discarded if they are interrupted by
higher-priority messages (e.g., an MLE message).
2023-11-10 07:26:39 -08:00
Abtin Keshavarzian 0f55e79263 [routing-manager] use Heap::Array for OnMeshPrefixArray (#9592)
This commit updates `RoutingManager` to use heap allocated array
for `OnMeshPrefixArray` under `BORDER_ROUTING_USE_HEAP_ENABLE`
config.

This commit also updates the `toranj-config-posix` header to
explicitly disable `BORDER_ROUTING_USE_HEAP_ENABLE` under the POSIX
config to validate builds with this config disabled. This aligns with
the main purpose of the `toranj` posix build config, which is to
validate builds under different configs (run from the
`toranj-unittest` job in the `toranj.yml` GitHub action workflow).
2023-11-09 15:31:41 -08:00
jrhodie e987138701 [cli] TCP readme corrections (#9593) 2023-11-09 14:26:52 -08:00
whd 6edb06e4e0 [posix] allow OT process to run when infra netif gets lost (#9583)
In `ot::Posix::InfraNetif::GetFlags()`, the OT process would die if
the infra network interface is removed on the POSIX platform. On
Android platform, this is not the desired behavior because the system
server may tell the OT process to switch another infra network
interface. It's fine for OT process to keep running when the previous
infra network interface disappears because later system server will
call `otSysSetInfraNetif()` to specify the new infra network
interface.
2023-11-08 18:20:46 -08:00
Abtin Keshavarzian a05954b01e [slaac] simplify adding/removing addresses and other enhancements (#9579)
This commit makes the following smaller enhancements in `Slaac`
class:
- Adds a new `ShouldUseForSlaac()` method to check if a network data
  prefix should be used for SLAAC, checking flags and applying the
  filter if set.
- Introduces separate `RemoveAddresses()` and `AddAddresses()` methods
  to manage SLAAC addresses, replacing the previous `Update()` method.
- Adds helper methods to `RemoveAllAddresses()`, `RemoveAddress()` to
  remove a specific address, and `AddAddressFor(prefix)` to  generate
  and add an address for a given prefix.
- Simplifies `GenerateIid()` by removing unused input parameters.
2023-11-07 12:43:02 -08:00
Eduardo Montoya 3b30c842a2 [csl] add OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_LOCAL_TIME_SYNC option (#9568) (#9568)
Allow platforms to reduce the periodic access to `otPlatRadioGetNow`
to calculate CSL synchronization elapsed time in the case when those
radio API calls are costly.
2023-11-06 22:23:37 -08:00
jrhodie 0d74e43fa6 [docs] TCP Commands - add Doxygen tags (#9578) 2023-11-06 15:41:32 -08:00
Kangping 74061eebd4 [dataset] returns OT_ERROR_REJECTED when MGMT_SET is rejected by leader (#9582)
The current code won't return a failure error code when a MGMT_SET
request is rejected by the leader, so the client doesn't know whether
the operation succeed or not.

This commit fixes this issue by converting the REJECTED state to the
OT_ERROR_REJECTED error code which is propagated back via the
otDatasetMgmtSetCallback callback.
2023-11-06 11:21:45 -08:00
dependabot[bot] f889bf9f2e github-actions: bump ossf/scorecard-action from 2.2.0 to 2.3.1 (#9584)
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.2.0 to 2.3.1.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](https://github.com/ossf/scorecard-action/compare/08b4669551908b1024bb425080c797723083c031...0864cf19026789058feabb7e87baa5f140aac736)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-06 08:23:14 -08:00
Zhanglong Xia 5058500e5d [build] move radio_spinel.cpp to new lib openthread-radio-spinel (#9530)
The lib `openthread-spinel-ncp` is used by the NCP build, it doesn't
need the file `radio_spinel.cpp`. This commit changes the CMake file
to make only the lib `openthread-spinel-rcp` include the file
`radio_spinel.cpp`.
2023-11-02 09:11:26 -07:00
Abtin Keshavarzian 4a9fb0609e [netdata] simplify Leader class (#9563)
This commit updates the `NetworkData::Leader` sub-class model,
removing `LeaderBase` (which intended to provide common functions
shared between FTD and MTD) and instead adding all methods directly
in `Leader` class with all `FTD`-specific methods having conditional
`#if` check.
2023-10-31 15:36:20 -07:00
Abtin Keshavarzian c6ffe1ae2c [mac] validate received ack frame PSDU in ProcessEnhAckSecurity() (#9565) 2023-10-31 15:33:33 -07:00
dependabot[bot] 7074a43e45 github-actions: bump github/codeql-action from 2.22.3 to 2.22.5 (#9571)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.22.3 to 2.22.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/0116bc2df50751f9724a2e35ef1f24d22f90e4e1...74483a38d39275f33fcff5f35b679b5ca4a26a99)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-30 14:04:51 -07:00
Mason Tran 0b0db37a13 [api] add API to reset to bootloader mode (#9523) 2023-10-27 15:54:15 -07:00
Abtin Keshavarzian 1528c8831d [core] define core/instance folder for instance modules (#9561)
This commit moves the `instance` module to a newly added folder
`core/instance` (from `core/common`.  Header file `extension.hpp`
and its example is also moved to the same folder.
2023-10-26 05:08:24 -07:00
hastigondaliya 4c75b6b489 [posix] fix uninitialized pointer read (#9562) 2023-10-26 04:47:41 -07:00
Abtin Keshavarzian 91b7c3ff3f [log] add otLogGenerateNextHexDumpLine() to generate hex dump (#9555)
This commit adds a public OT API to generate hex dump output line by
line. This function is then used for both `LogDump{}()` and frame
capture output by CLI `promiscuous` command (removing repeated
similar code) and harmonize the hex dump outputs.
2023-10-25 14:54:33 -07:00
whd 9106817c62 [posix] add otSysSetInfraNetif API (#9528)
This commit adds a new API `otSysSetInfraNetif` to support specifying
the infrastructure network interface for the platform. This can be
useful in following cases:
- The infra link cannot be determined at the start up of
  `otbr-agent`. We can call this API to specify the infra link without
  specifying it in the command line arguments.
- Let Thread Border Router switch to another infra link without
  restarting the whole OpenThread stack.
2023-10-25 01:33:52 -07:00
Abtin Keshavarzian 52e0c8bdd9 [mle] add TxMessage::AppendSteeringData() (#9559) 2023-10-24 22:11:31 -07:00
hastigondaliya fbeb4d18f2 [posix] addressing coverity warning: resource leak (#9472)
The "assert" and "VerifyOrDie" were checking same condition, so
the second validation was never executed if (rval != sizeof(key)).
Additionally,"aSwapFd" was not freed on assertion.

With this commit,
1. addressed the memory leak to system resources.
2. Replaced VerifyOrDie() or assert() by VerifyOrExit()
3. handle error at exit
2023-10-24 14:38:30 -07:00