We just updated the version from 14 to 16. But very unfortunately
clang-format-16 was just deprecated recently. So this time we update
the version to the latest available one. There are newer releases than
19 (like 20) but as I tested, sudo apt-get install -y clang-format-19
can work while 20 doesn't work.
misc-include-cleaner in clang-tidy-19 exerts a very strict check which
requires to directly include all headers for every symbols in the
source file. However in our current code we intentionally use some
indirect include. So this commit disables misc-include-cleaner.
- Add Wake-up Channel TLV to the dataset.
- Add CLI support to handle the wake-up channel.
- Add MAC support for wake-up channel (to be used for sending
and receiving wake-up frames).
This commit adds the `ParseTlvs()` helper method in the `Cli::Dataset`
class, which parses TLVs (as hex strings) from an input argument.
This is used in multiple methods to simplify the code.
The `Process<Cmd("set")>()` method is updated to avoid extra
conversion and use of core-internal types.
This commit enhances dataset handling:
- Adds `ValidateTlvs()` which parses and validates all known TLVs
within the `Dataset` and checks for any duplicates.
- Introduces a set of `SetFrom()` methods for constructing a `Dataset`
from various types of inputs, e.g., other `Dataset`, TLV sequences,
`DatasetInfo` structures, bytes read from `Message`. Now they
consistently clear the `Dataset` before setting it.
- Adds `WriteTlvsFrom()` to update a `Dataset` replacing/appending a
set of TLVs.
- Adds `AppendTlvsFrom()` to append an already encoded sequence of
TLVs without validating/checking the format.
- Renames `Get/SetSize()` to `Get/SetLength()` for consistency.
- Adds `test_dataset.cpp` unit test for basic `Dataset` validation.
This commit introduces the `ClearAllBytes<ObjectType>()` template
function to zero out all bytes within an object. This replaces
`memset(0)` calls in OT core modules, simplifying code and improving
safety by automatically using the correct object size.
This commit simplifies the `Cli::Dataset` implementation by defining
an array of `ComponentMapper` structures. Each `ComponentMapper`
structure corresponds to a Dataset component, and provides the
following information:
- The component's CLI name
- A method pointer to output that component
- A method pointer to parse that component
- A pointer to the component's mIsPresent boolean flag
A new `LookupMapper()` method allows us to find (using binary search)
the entry corresponding to a given component name. This model allows
us to reuse code patterns for the main dataset sub-commands,
`mgmtsetcommand`, and `mgmtgetcommand` commands when outputting or
parsing dataset components.
This commit adds a mechanism to delay the downgrade of routers or
leader when the security policy TLV changes in the Active Operational
Dataset such that the device is no longer eligible to act as a
router.
If the decision to become a child is made due to a security policy
change, the device first delays a random period up to the "router
selection jitter" before downgrading. If the device is the leader, an
additional fixed delay of 10 seconds is added to the random period.
If the security policy changes again while the device is waiting to
downgrade such that it becomes router-eligible again, the downgrade
is cancelled and the device remains in its current role.
This commit adds a `test_router_downgrade_on_sec_policy_change` to
validate the behavior of newly added mechanism.
This commit also updates the CLI `dataset` sub-commands to allow
getting and setting the "version threshold for routing" (VR) field in
security policy.
This commit adds `otDatasetConvertToTlvs()` to covert a given
Operational Dataset `otOperationalDataset` to TLVs. It also adds a
related CLI command `dataset tlvs`.
This commit adds compile-time check of format string to all CLI
`Output` methods. It also updates CLI module to make arg string
formats consistent. In particular we use `'%lu` for `uint32_t`
arguments and they are explicitly cast to `unsigned long` using
`ToUlong()`.
This commit also adds a helper `Uint64ToString()` method to convert a
`uint64_t` to decimal format string. The new methods allow us to
output `uint64_t` values without needing to cast to `unsigned long
long` and/or use of `%llu` (which may not be provided by certain
embedded libraries).
The `otOperationalDataset#mActiveTimestamp` should represent the full
Active Timestamp TLV value but not only the seconds. The same for
`otOperationalDataset#mPendingTimestamp`.
This commit updates how the CLI command handlers are defined. A
template `Process<CommandId>()` method is now used to process a CLI
command where the `CommandId` is a `uint64` hash ID derived from
the command string itself.
This model helps simplify the CLI modules. With this change, there is
no need to declare different process methods for every CLI command in
the header files. It also makes the association between a CLI command
and its command string explicit and simple (e.g., `"state"` command
with `Process<Cmd("state")>` method).
This commit adds set of generic binary search related functions in
OpenThread core under `BinarySearch` module. The binary search module
replaces and enhances the existing `Lookup` table module (which was
limited to search based on strings and mainly used by CLI to map from
command string to a handler function).
This commit also adds a new class `Stringfy` in `string.hpp` to help
convert from a set of `uint16_t` values (e.g., a non-sequential
`enum`) to strings using binary search in a table. The new methods are
used for converting `Coap::Code` and `IpProto` enumerations to
corresponding strings.
This commit adds a new class `Cli::Output` which now includes all the
simple `Output{Item}()` methods that are used by CLI and its
sub-modules. It also adds new `Output` method flavors that output an
item (e.g., an IPv6 address) with an appended newline at the end.
These patterns are often used by CLI modules so having such new
methods help simplify the code.
The commit also adds `OutputWrapper` which is a wrapper over an
`Output` instance providing similar methods. This class is used as
the base class of different CLI sub-modules (e.g., `Cli::Dataset` or
`Cli::Joiner`, etc.) which helps simplify their implementation
(allow them to use the same set of `Output` helper methods as the
ones used by the `Cli::Interpreter` class).
- 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.
This commit changes `ParseCmd()` such that as `aArgs` array entries
are populated with parsed arguments from a command line string, the
remaining unused `aArgs` entries in the array are marked as "empty".
We also ensure that the `aArgs[]` array always end with an "empty"
`Arg` which indicates end of the list (this is similar to how C
string ends with a null '\0' character). This commit also changes
different methods of `Arg` class (`Arg::ParseAs{Type}()` or overload
of operator `==`, etc) to check and handle when `Arg` is marked
as "empty".
These changes help simplify how the arguments are processed in CLI
modules. In `Cli::Process{Command}()` methods we can just pass the
`aArgs[]` array and do not need to pass a separate args length
parameter. In many cases the args length checks can be removed since
it will be checked from `ParseAs{Type}()` call.
This commit adds a new public API `otNetworkNameFromString()` to set
an `otNetworkName` instance from a given null terminated C string. The
new API will also validate that the given name string follows UTF-8
encoding and its length is not longer than max network name size.
This commit also simplifies the UTF-8 validation of `NetworkName` by
moving the check from `Mac::SetNetworkName()` to a newly added method
in `Mac::NetworkName` to set it from a C string.
It also defines `DomainName` as a `typedef` of `NetworkName` which
helps simplify its use and remove repeated code.
Finally, it updates the `Cli::Dataset` to use the new public API for
validating `otNetworkName`.
This commit adds a new `Arg` class in `parse_cmdline` which represents
a single argument (wrapper over a C string). The `Arg` class is then
used in CLI modules. This helps simplify the CLI code mainly using
simpler syntax, e.g., using an overload of `==` operator to compare an
argument with a C string, or calling `ParseAs{Type}()` methods
directly on an `Arg` instance.
This commit adds new helper functions under `Utils::CmdLineParser` to
parse a given ASCII string as different simple types, namely signed or
unsigned integers of different bit lengths (`uint8/16/32/64`, and
`int8/16/32`). The new functions validate that the parsed value fits
within the supported range of the expected int type. This commit also
adds different flavors of `ParseAsHexString()` to parse a hex string
into sequence of bytes (with fixed/known size or unknown size allowing
or disallowing truncation). It also moves the parse related methods
(like `ParseAsIp6Prefix`) from CLI modules in `CmdLineParser`.
The CLI modules are then updated to use the new `ParseAs{Type}`
functions simplifying the code and adding extra checks when parsing
the CLI input.
Finally, this commit adds a unit test `test_cmd_line_parser` verifying
the behavior of new `ParseAs{Type}()` functions.
This commit adds `LookupTable` module which provides helper methods to
perform binary search in a generic sorted lookup table for specific
entry matching a given name string. It also provides `constexpr`
methods to check (at build-time) whether a lookup table array is
sorted. This commit also updates CLI modules to use the `LookupTable`
methods for command lookup. It also adds a unit test for the lookup
table.
This commit also adds a template version of `OutputBytes()` which
accepts a reference array of a specific length. This helps simplify
the calls to this helper method where the array length can be
inferred. It also changes the code to use `OutputBytes()` for
outputting master key, pskc, xpanid, etc.
This commit contains a group of style fixes and smaller enhancements
in CLI modules:
- Remove unnecessary `struct` when declaring variable.
- Remove use of single `"%s"` in `Output` methods.
- Fix order of `#include` headers.
- Remove unnecessary use of `OT_UNUSED_VARIABLE`.
- Remove unnecessary temp variables and casts.
- Add comments to `#endif` directives than are more than than 20
lines away from the corresponding `#if` they are associated with.
This commit contains a group of smaller enhancements in Cli modules:
- Add and use OutputLine() helper method which outputs a formatted
string line (appends newline \r\n).
- Use binary search when finding the command in sCommands array (also
adds static_assert check to ensure sCommands array is sorted).
- Define Command struct as a private nested type.
- Use enum constants (replacing #define).
- Rename method to OutputResult() (from AppendResult) to harmonize
with rest of a Output{Something}() methods.
- Remove comments at #endif when within 20 lines of #if