Commit Graph

1087 Commits

Author SHA1 Message Date
Mason Tran c8556dfd66 [cmake] add option for RCP specific mbedtls library (#7781)
This commit enables a different mbedtls library to be used for RCP
builds. This will make it possible to use a PSA Crypto mbedtls library
for FTD/MTD images while using a non-PSA crypto library on RCPs.
2022-06-02 19:26:29 -07:00
Yakun Xu 36b2a173f9 [simulation] simulate energy scan (#7393)
This commit implements energy scan in simulation platform.

Verified locally
```bash
> ifconfig up
Done
> scan energy 100
| Ch | RSSI |
+----+------+
| 11 |  -98 |
| 12 |  -98 |
| 13 |  -98 |
| 14 |  -98 |
| 15 |  -30 |
| 16 |  -30 |
| 17 |  -98 |
| 18 |  -98 |
| 19 |  -30 |
| 20 |  -98 |
| 21 |  -98 |
| 22 |  -98 |
| 23 |  -30 |
| 24 |  -30 |
| 25 |  -30 |
| 26 |  -98 |
Done
```
2022-05-20 11:00:44 -07:00
Abtin Keshavarzian 658491a1aa [config] introduce OT_THREAD_VERSION_1_3 (#7692)
This commit adds `OT_THREAD_VERSION_1_3` constant (equal to `4`)
and change=s the `OPENTHREAD_CONFIG_THREAD_VERSION` default value
to be the 1.3 version number.

It also updates the build switch option (Cmake and autoconf)
to support 1.3 and use 1.3 as default version value (when not
explicitly specified).
2022-05-13 12:56:16 -07:00
jinran-google 2d977b0edd [simulation] fix build with RAM settings (#7648)
This commit fixes the build error when `OPENTHREAD_SETTINGS_RAM` is
enabled. Also adds a check to prevent this error in the future.
2022-05-01 19:20:47 -07:00
Yakun Xu 013ab41291 [gcov] use __gcov_dump() instead for gcc 11 (#7629)
__gcov_flush is removed from gcc 11. This commit moves reset setup to a
single header file.
2022-04-25 06:23:00 -07:00
Simon Lin b5a347a3f9 [simulation] use 128 max children for simulation (#7620) 2022-04-21 09:28:58 -07:00
Jonathan Donald a9b4e637f9 [docs] community discussion change (#7507)
Replace link to openthread-users Google Group with link to GitHub
OpenThread Discussions, clarify issue reporting links.
2022-04-07 13:29:08 -07:00
Eduardo Montoya 47fd27be3e [mac] remove beacons payload (#7472)
Thread Specification v1.2.1 removes support for Thread Beacons payload.
2022-04-06 12:18:22 -07:00
jinran-google c9f23ccdda [settings] set sensitive keys in platform settings initialization (#7496)
This commit makes the core pass the sensitive keys to the platform
settings initialization, so that the platform settings implementation
can know which keys are sensitive keys during the initializing and do
the migration when needed.
2022-03-24 21:22:32 -07:00
Jonathan Hui 0a74d66fed [doxygen] change inout to in,out (#7461) 2022-03-10 14:34:20 -08:00
Abtin Keshavarzian 564982c818 [log] implement new logging model with module name support (#7385)
This commit implements new logging model in OpenThread. Each core
module can specify its own module name using `RegisterLogModule()`.
The registered log module name is then included in the all the log
messages emitted from the specific file. This model replaces and
enhances the log region model.
2022-02-17 15:50:45 -08:00
Eduardo Montoya f759d163dc [link-metrics] support at least one series per child (#7416)
Thread Conformance document requires a Link Metrics Subject to
support at least one Link Metrics series (forward or enhanced ACK)
per connected SED.

Make sure this is the default configuration.
2022-02-17 09:10:08 -08:00
Abtin Keshavarzian 69ad96675f [trel] implement new TREL model using DNS-SD (#7125)
This commit implements the new TREL model which uses DNS-SD to
discover TREL peers on the network. This implementation replaces the
previous model which relied on link-local multicast.

This commit adds a new set of `otPlatTrel` APIs and callbacks that are
then used by an updated `Trel::Interface` implementation. The
`Trel::Interface` maintains a TREL peer table which is populated from
DNS-SD discovered services. A device supporting TREL registers a new
service to be advertised using DNS-SD with the service name
`_trel._udp`. It also initiates an ongoing DNS-SD browse for the same
service name within the local browsing domain to discover other
devices supporting TREL. `Trel::Interface` encapsulates and send
unicast frames as a unicast UDP message between TREL peers. Broadcast
frames are sent as a group of UDP unicast transmission to a sub-set
of TREL peers.

This commit also adds a new set of public APIs for TREL along with
support for them in CLI:
- APIs for enabling/disabling of TREL operation at run-time.
- Filter mode API which when enabled temporarily drops all the traffic
  on the TREL interface (is mainly intended for testing).
- APIs to get the TREL peer table entries.

This commit adds an implementation of the new `otPlatTrel` APIs under
`simulation` platform. This is used for testing. This implementation
emulates a simplified version of DNS-SD mechanism.

A basic implementation  of the `otPlatTrel` is also provided under
`posix` platform. However certain functions are tied to mDNS or
DNS-SD library being used on a device and need to be implemented per
project/platform. A set of weak empty functions `trelDnssd{}` are
defined (along with a description of the their expected behavior)
which can be overridden during project/platform integration.
2022-01-28 12:07:42 -08:00
Yi 37f9d171c0 [routing-manager] generate random nat64 prefix and add it to netdata (#7232)
This commit generates a random NAT64 prefix and adds the prefix to
NetworkData if none exits. The prefix will be saved in Settings for
recovery.

It also adds a new CLI command `br nat64prefix` to show the local
nat64 prefix.

A new config OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE is defined
and used to guard the change.

This initial implementation only supports a single BR.
2022-01-19 00:35:10 -08:00
Eduardo Montoya 0b3f87c588 [cmake] make TCP configurable with OT_TCP option (#7306) 2022-01-18 11:31:39 -08:00
Abtin Keshavarzian 5b9a1c0467 [net] add support for DNS Stateful Operations (DSO) (#7081)
This commit adds support for DNS Stateful Operations (DSO) as
specified in RFC 8490.

It adds `platform/dso_transport.hpp` header file which defines the
platform APIs/callbacks for DSO transport layer (e.g., DSN-over-TLS
or DNS-over-TCP).

The `Dso` module handles establishing connection with a peer, acting
either as a DSO client or server, establishing a DSO session over a
connection, and then sending and processing DSO request, response,
and unidirectional messages (including support for DSO TLV formats).
The `Dso` module also manages the session life cycle and timeouts,
namely the "Inactivity" and "Keep Alive" timeouts (including sending
and processing of Keep Alive messages when needed). It also handles
adding encryption padding before sending a message. It implements the
padding policy "Random-Block-Length Padding" from RFC 8467.

This commit also adds a detailed unit test `test_dso` covering the
behavior (including corner cases) of the `Dso` implementation. The
unit test provides an implementation of the DSO platform APIs which
emulate the DSO transport layer. It also includes a simplified alarm
platform implementation (emulating timers and allowing time to
advance in the unit test). These allow the unit test to cover more
complicated situations and behaviors (timeouts, failures, etc).
2022-01-14 16:25:16 -08:00
Zhanglong Xia b69aac4aa8 [simulation] fix the wrong timeout value issue (#7262)
When the type `time_t` is 32 bits wide, the current code will truncate
the value of time and returns a wrong value.
2022-01-09 21:48:25 -08:00
Simon Lin ed4dceaa6d [github-actions] add simulation tests registering 500 services to one SRP server (#6991)
This commit adds two simulation tests to verify that SRP clients can
register 500 services to one SRP server:
- Virtual time simulation test with one SRP server and 25 SRP clients,
  each client registering 20 SRP services.
- OTBR simulation test same as above, but run SRP server on OTBR
  (Docker).
2021-10-28 11:36:25 -07:00
nikita-s-wrk f4e1526a49 [cmake] add ability to pick custom lib for MTD/FTD (#7041)
This commit enables different libraries option for ftd, mtd and rcp
builds.
2021-10-19 17:28:02 -07:00
Simon Lin fcadd11ffb [cli-uart] fix va_end may not be called for va_copy (#7079) 2021-10-18 09:07:49 -07:00
Simon Lin d39fce1fa6 [uptime] enable uptime by default on posix and simulation (#7052)
This commit enables OPENTHREAD_CONFIG_UPTIME_ENABLE and
OPENTHREAD_CONFIG_LOG_PREPEND_UPTIME by default on posix and
simulation platforms.
2021-10-12 12:02:19 -07:00
Abtin Keshavarzian 5c22f6c521 [simulation] update alarm to avoid cast from uint to int (#7017)
This commit updates and simplifies the `alarm` platform implementation
under simulation by adding new functions to determine whether a timer
is expired and calculate the remaining time. The new code does not
use casting a `uint32_t` value to an `int32_t` (since its behavior is
toolchain/compiler dependent and it is not defined by the C++
standard).
2021-09-20 13:21:36 -07:00
Li Cao 097aa4f65d [cli] add cli-radio build (#6769)
Background:

In an early stage of developing a new product, developers may want to
verify the Thread related hardware functionality, for example, send,
receive, etc.  However if the product uses the posix <-> RCP mode,
it's hard to verify it before the posix daemon can run on the
host. cli-ftd and cli-mtd could be an alternative. However, if the
product uses the posix <-> RCP mode, the space of the 802.15.4 radio
chip will be very small. For example, nRF52811 doesn't have enough
space to flash cli-ftd or cli-mtd firmware. So this PR creates a new
firmware ot-cli-radio which has very limited functionality for
verifying the hardware.

Basically, the ot-cli-radio consists of openthread-radio and
libopenthread-cli-radio.a. It supports very few cli commands. The most
important command is diag. Currently, there are: diag, help, reset,
version.

Currently, the diag commands have different implementation on RCP:

- For commands like diag start, the process function
  (Diags::ProcessStart) is first called on host. Then host sends an
  SPI frame to the RCP and Diags::ProcessStart (different
  implementation) is called again on RCP.

- For commands like diag send, Diags::ProcessSend is first called on
  host.  Then host sends an SPI frame to the RCP, directly calling
  send API. And there is no Diags::ProcessSend implemented on RCP.

Let's call the implementation of Diags::Process* currently on host as
native diag commands. When we run ot-cli-radio, we should use the
native diag commands because it won't interact with a posix daemon and
it processes the diag commands through the whole process. So this PR
adds a new option OPENTHREAD_CONFIG_DIAG_NATIVE_CMDS_ON_RCP to control
whether to use the native diag implementation on RCP. When we use a
normal RCP, the option should be disabled. While when use
ot-cli-radio, the option should be enabled.
2021-09-18 09:51:35 -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
Simon Lin 7d91dd19c6 [thread-cert] add test to verify MED informs previous parent on reattach (#7005)
This commit verifies that MEDs can inform previous parent on reattach
with OPENTHREAD_CONFIG_MLE_INFORM_PREVIOUS_PARENT_ON_REATTACH enabled.
2021-09-16 21:00:15 -07:00
Simon Lin db2e313ef0 [cli] disallow concurrent commands (#6695)
This commit disallows concurrent commands.

With this commit, the CLI only execute a new command after it complete
the previous command. CLI can also prompt properly after the command
execution is done.

Other fixes and enhancements:
- Fixes premature command prompt
- Add ping async command for ping in async mode: output Done
  immediately but print ping responses later on.
- Fixes networkdiagnostic get outputs multiple Done by always waiting
  for 5 seconds.
2021-09-09 20:46:43 -07:00
hemanth-silabs cf452fbf7c [crypto] adding ARM PSA (Platform Security Architecture) support (#6862)
- New format for MAC keys, as a union between literal key and keyrefs.
- Modified key_manager to handle both literal keys or keyrefs.
- Modified MAC and sub_mac modules to handle both Literal Keys or keyrefs.
- Updated Crypto Modules to use abstracted APIs.
- New CLIs to handle networkkey and pskc references.
2021-09-08 14:47:46 -07:00
Bob MacDonald 0a6fba303a [cmake] remove obsolete efr32 cmake file (#6983) 2021-09-03 18:26:23 -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
Łukasz Maciejończyk 812fc1eaea [spinel] refactor connection handling for USB transport (#6963)
This commit simplifies USB connection handling after resetting (hard reset)
RCP device with USB transport.
It drops udev dependency making the new approach generic for USB CDC ACM
across all platform.
It is working also on dockers.
The feature is enabled by new radio Url parameter: 'uart-reset'.

Radio url example:
spinel+hdlc+uart:///dev/serial/by-id/SYMLINK_TO_RCP_DEVICE?uart-reset

It is meant only for connection with RCP devices working with USB
transport and performing hard reset on host reset command.
2021-08-30 12:41:16 -07:00
Abtin Keshavarzian 3c10ded88d [simulation] fix handling of overflow in virtual-time simulation (#6969)
This commit updates `platformAlarmGetNext()` in `alarm-sim` in
virtual-time simulation platform to return the remaining duration
to the next alarm as `uint64_t` (in microseconds). This fixes the
issue with potential overflow in calculating the next alarm time.
2021-08-30 11:57:14 -07:00
Abtin Keshavarzian 2798cc9c05 [utils] adding HistoryTracker module (#6807)
This commit adds History Tracker feature and its CLI support. This
feature records history of different events as the Thread network
operates (e.g., history of RX and TX IPv6 messages or network info
changes).

Recorded entries are timestamped. When the history list is read, the
timestamps are given as the entry age relative to the time the list
is being read. For example in CLI a timestamp can be shown as
`02:31:50.628 ago` indicating the entry was recorded 2 hours, 31 min,
50 sec, and 628 msec ago. Number of days is added for events that are
older than 24 hours, e.g., `31 days 03:00:23.931 ago`. Timestamps use
millisecond accuracy and are tacked up to 49 days. If an event is
older than 49 days, the entry is still tracked in the list but the
timestamp is shown as old or `more than 49 days ago`.

The `HistoryTracker` currently maintains 3 lists. The Network Info
history tracks changes to Device Role, Mode, RLOC16 and Partition ID.
The RX/TX history list records information about the received/sent
IPv6 messages:
- Message type (UDP, TCP, ICMP6 (and its subtype), etc.)
- Source and destination IPv6 addresses and port numbers
- IPv6 payload length
- The message checksum (for UDP, TCP, or ICMP6).
- Whether or not the link-layer security was used
- Message priority: low, norm, high, net (for control messages)
- Short address (RLOC16) of neighbor who send/received the msg
- Received Signal Strength (in dBm) for RX only
- Radio link info (15.4/TREL) on which msg was sent/received
  (useful when `OPENTHREAD_CONFIG_MULTI_RADIO` is enabled)

Config `HISTORY_TRACKER_EXCLUDE_THREAD_CONTROL_MESSAGES` can be used
to configure `HistoryTracker` to exclude Thread Control message
(e.g., MLE, TMF) from TX and RX history.

The number of entries recorded for each history list is configurable
through a set of OpenThread config options, e.g., number of entries
in Network Info history list is specified by OpenThread config option
`OPENTHREAD_CONFIG_HISTORY_TRACKER_NET_INFO_LIST_SIZE`. The
`HistoryTracker` will keep the most recent entries overwriting oldest
ones when the list gets full.

This commit also adds support for `HistoryTracker` in CLI. The CLI
commands provide two style for printing the history information: A
table format (more human-readable) and list style (better suited for
parsing by machine/code). `README_HISTORY.md` is added to document
the commands and the info provided by each history list entry.

This commit also adds `test_history_tracker.py` test-case which
covers the behavior of `HistoryTracker`.
2021-08-12 15:47:26 -07:00
canisLupus1313 f99f206bea [csl] allow to configure the CSL auto synchronization (#6913)
This commit allows configuration of auto synchronisation of CSL,
with data poll mechanism.
2021-08-12 10:51:21 -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
Eduardo Montoya a94e88cd50 [mac] add mIsHeaderUpdated frame flag (#6849)
When a platform provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability,
it updates the frame header with the dynamic data (frame counter,
key id...) and returns it back to MAC together with the transmission
result.

So far the `mIsARetx` flag was being used to instruct the radio
whether to update the header or not, but there was no mean to know
if the radio was able to do so.

This commit introduces the `mIsHeaderUpdated` flag which is used in
both directions, so the MAC layer can react to cases in which the
frame header was not properly updated by the radio platform.

The usage of mIsARetx remains restricted now to two cases:

- When a SSED decides to re-synchronize CSL parameters after a
retransmission.
- To check if sequence number was set for CSL/indirect retransmissions.
2021-08-10 18:17:40 -07:00
Sam Kumar 6fa60be75c [tcp] add third_party module for TCPlp (#6885)
This commit creates a module in third_party for TCPlp code. It is a
placeholder for now; the actual code will be added in future commits.
2021-08-06 22:04:31 -07:00
Zhanglong Xia 866c9602fb [include] resolve the unknown type name issue (#6867)
When compiling OpenThread public header files independently, the
compiller generates errors, such as `unknown type name "size_t"`
and 'unknown type name "otLogLevel"'.

This commit adds the corresponding header files to the public
headers to resolve this issue.
2021-07-29 08:37:29 -07:00
Abtin Keshavarzian 5030808e05 [simulation] add empty otPlatInfraIf platform APIs in simul/test (#6852)
This commit adds empty implementations of `otPlatInfraIf` platform
APIs under simulation. It also adds `otPlatInfraIfHasAddress()` in
`test_platform`. This allows the unit tests and simulation platform
builds to succeed when `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` is
enabled.
2021-07-26 21:47:11 -07:00
Abtin Keshavarzian cbd9661308 [cli] new config to log input command and the resulting output (#6827)
This commit adds `OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE`
option which configures the CLI module to log its input command
string and the resulting output. This is done in addition to emitting
the output string to the console. By default this config is enabled
on all POSIX based platforms and when `LOG_OUTPUT` is not set to use
CLI console itself.
2021-07-20 18:53:27 -07:00
canisLupus1313 681214da94 [csl] avoid OT version dependencies in platform config files (#6803) 2021-07-08 09:54:22 -07:00
Abtin Keshavarzian 2db3ddca33 [simulation] remove use of internal definitions/headers in radio platform (#6766)
This commit updates the `simulation/radio.c` and removes the uses of
core internal macro `VerifyOfExit()` and replaces them with
`otEXPECT_ACTION()`. This ensures that radio platform layer does not
include the internal OT header like "common/code_utils.hpp".
2021-06-28 09:45:01 -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
Jonathan Hui aaabf25ff2 [network-key] change name from master to network (#6721) 2021-06-16 23:07:23 -07:00
Łukasz Maciejończyk 0869422c2c [docs] fix info about default Thread version supported by OpenThread (#6689)
After changed the default Thread version, the description about it has
not been updated. This commit fixes it.
2021-05-27 10:43:36 -07:00
Eduardo Montoya 5cd088cd76 [low-power] extend EnableCsl API (#6675)
Include the peer's short address together with the extended address
when enabling the CSL link. This removes the need for the platform
to guess it.
2021-05-25 15:21:38 -07:00
Yakun Xu e708b308cd [simulation] avoid unnecessary recompilation (#6660) 2021-05-21 08:14:22 -07:00
Łukasz Maciejończyk fa997aead6 [posix] RCP(USB CDC ACM) hard reset support (#6454)
This commit handles the situation when RCP(USB CDC) performs hard
reset. This commit brings an alternative to pseudo reset by handling
the connection with RCP(USB CDC ACM) by reset the socket connection
after the device is reset.

When RCP is connected by USB CDC and we reset it, the RCP device is
numerated in host operating system.  So far for RCP(USB CDC) pseudo
reset has been performing meaning only specific parts of firmware were
reset thanks to results the connection hasn't been broken. For hard
resetting RCP(USB CDC) device the host needs to handle the connection
properly.

It uses udev library to check if device enumeration has ended if
libudev-dev package is present in the host system otherwise it waits
few seconds.

It works based on symlink to the RCP device created by udev in
/dev/serial/by-id/ directory.
2021-05-14 11:20:32 -07:00
Jonathan Hui 550c2056de [nrf528xx] move to openthread/ot-nrf528xx (#6585) 2021-05-11 16:53:13 -07:00
Yakun Xu 833f8e2cff [cli] process exit in ot-ctl (#6605)
The exit command should only exit ot-ctl itself in daemon mode. This
commit adds processing exit command in the ot-ctl.

This commit also moves the exit command implementation out from core
as a user command on simulation and posix cli mode.
2021-05-10 23:22:51 -07:00
Li Cao e5cdb56a71 [simulation] enhance command line arguments by using get_opt (#6544) 2021-05-06 17:01:38 -07:00