Commit Graph

298 Commits

Author SHA1 Message Date
Yakun Xu ff259b845b [android] only set -std=c99 for mbedtls (#8310) 2022-10-21 13:02:18 -07:00
Yakun Xu 74cc79d7a2 [cmake-build] allow specify multiple targets (#8264)
This commit allows using OT_CMAKE_NINJA_TARGET to specify multiple
targets.
2022-10-12 13:09:04 -07:00
Song GUO 06a6de24fa [nat64] add functional tests (#8161)
The test includes:
- Counters (protocol & error (4to6 no mapping, other errors are not
  expected))
- ICMP ping Connectivity
- UDP connectivity
2022-09-29 10:54:49 -07:00
Jonathan Hui 2cab708443 [cc2538] move to openthread/ot-cc2538 (#8169) 2022-09-16 09:03:28 -07:00
Jonathan Hui 1fad9f7626 [github-actions] use external repo for arm build check (#8153)
Also remove autotools build checks.
2022-09-14 11:39:28 -07:00
Song GUO bce7c1ae1f [nat64] change BORDER_ROUTING_NAT64 to NAT64_BORDER_ROUTING (#8047)
We decided to rename BORDER_ROUTING_NAT64 to NAT64_BORDER_ROUTING so
the flag won't be confusing since we have NAT64_TRANSLATOR which does
not depends on the border routing manager.
2022-08-30 21:05:28 -07:00
Song GUO e84f05c641 [nat64] implement nat64 translator (ot::Nat64::Translator) (#7836)
This commit:

- implements the core logic for translating packets for NAT64,
  including the public APIs exposed to platform daemons.

- includes changes for POSIX platform, use `OT_POSIX_NAT64_CIDR`,
  `OPENTHREAD_POSIX_CONFIG_NAT64_CIDR` for setting the CIDR for NAT64
  during build time.

- exposes `otNat64Send(otInstance *aInstance, otMessage *aMessage)`
  and `void otNat64SetReceiveIp4Callback(otInstance *aInstance,
  otNat64ReceiveIp4Callback aCallback, void *aContext)`.
2022-08-18 22:28:26 -07:00
Yi 80565c58a9 [nat64] fetch NAT64 prefix from infrastructure interface and advertise it to netdata (#7619)
This commit fetches the NAT64 prefix on infrastructure interface and
advertise it to Network Data at medium preference.

- Use `getaddrinfo_a()` function to asynchronously lookup the ipv6
  address of the special domain `ipv4only.arpa`. The infrastructure
  NAT64 prefix is extracted from the domain answer.

- `mInfraIfNat64PrefixStaleTimer` is scheduled to monitor the presence
  and change of infrastructure NAT64 prefix.

- `EvaluateNat64Prefix` evaluates whether to advertise the
  infrastructure prefix or the local ULA prefix or neither. When there
  is a new infrastructure prefix, it will withdraw the legacy one and
  add the new one. When the infrastructure prefix no longer exists, it
  will withdraw the legacy one and add the local ULA prefix. When the
  infrastructure prefix presents again, it will add the infrastructure
  prefix and withdraw the local ULA prefix.

New tests are added to test the scenarios when infrastructure NAT64
prefix exists.  `DNS64` on OTBR is turned on to enable `bind9` with
NAT64 prefix on infrastructure interface for these tests. `bind9` is
explicitly turned off when testing local ULA prefix.  Since bind9 is
conflict with other components like dnssd, all nat64 tests are moved
under /nat64 directory and configured separately.

The case that two or more BRs have same infrastructure NAT64 prefix is
not covered by this commit and will be followed up later.
2022-08-12 07:37:05 -07:00
Abtin Keshavarzian 5bc71b2a4f [message] allow msg pool using external heap (#7933)
This commit updates the code to allow the config combination of
`OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE` along using external heap
`OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE`. This commit updates `Message`
`GetFreeBufferCount()` and `GetTotalBufferCount()` methods to return
special value `0xffff` under this config combo indicating the numbers
cannot be estimated.

This commit also updates `check-simulation-build-autotools` to add
such a build config so to be covered as part OT CI tests.
2022-07-22 15:43:48 -07:00
Yi bec3a5edb0 [nat64] fix build options for NAT64 tests (#7929)
This commit fixes the build options for NAT64 tests. A new option was
added in ot-br-posix recently.
2022-07-21 07:22:27 -07:00
Robert Quattlebaum 8095a086d7 [bootstrap] Explicitly use arm-none-eabi-gcc from armmbed (#7917)
The bootstrap script taps `armmbed/formulae`, and then tries
to install `arm-none-eabi-gcc` from that tap. However, if the
user has already tapped a different tap that offers
`arm-none-eabi-gcc`, then the install will fail.

This change removes the ambiguity of the install by specifying
the tap to use.
2022-07-19 14:35:19 -07:00
Yi 095f530bd7 [nat64] run nat64 ci tests as an independent job (#7885)
This commit changes the NAT64 CI tests to be ran as an independent
job. A new /nat64 folder is added and it would make it easier to
configure new NAT64 tests in the future.
2022-07-18 14:15:00 -07:00
Zhanglong Xia 366786dbed [posix] add a vendor interface for the radio spinel layer (#7884)
This commit adds a vendor interface for developers to implement
the bus interface by themselves.
2022-07-14 13:10:51 -07:00
Abtin Keshavarzian 5d09e9ca4f [mle] update number parent requests in an attach cycle (#7538)
This commit updates the MLE attach process so that in the first attach
cycle device tries a total of six MLE Parent Requests, the first two
to routers only followed by four to routers and REEDs. For example,
the six Parent Request message will be used before device can decide
to act the leader. An MTD in the next attach attempt (if cannot find a
parent in first attempt cycle), will go to the model of two Parent
Requests (first to routers, then to routers/REEDs).

This change impacts the time it takes for a device to start as leader
(due to increased number of Parent Request and wait time). This commit
updates different test scripts to address the change in the wait
time. It adds a new `config.LEADER_STARTUP_DELAY` constants which is
used for wait time for leader to start.
2022-07-07 16:50:21 -07:00
Abtin Keshavarzian 747e20cc54 [script] fix multiple LOG_OUTPUT definitions (#7833)
This commit updates `check-simulation-build-autotools` to use the
`LOG_OUTPUT` switch directly. This addresses an issue where
we could end up with multiple `OPENTHREAD_CONFIG_LOG_OUTPUT`
definitions in the `CPPFLAGS`.
2022-06-23 21:22:41 -07:00
Jonathan Hui 0c48ade2ff [tests] change 1.2 builds to 1.3 (#7756) 2022-06-08 11:44:23 -07:00
hemanth-silabs 8f92d2dc81 [mac] enable Beacon Payload in outgoing beacons (#7767)
This commit enables beacon payloads on outgoing beacons to prevent
backward compatibility issues with existing devices in the market.
2022-06-01 16:50:01 -07:00
hemanth-silabs e8b9b874f5 [mac] re-add API to receive Thread-specific Beacon payload (#7736)
Some of the current implementations of thread stack use active scans
to find out the joining network name and extended panids. These
details are then used as part of commissioning process.

So at the very minimum we will need processing the incoming beacons to
extract these information.
2022-05-26 14:02:07 -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
Jonathan Hui 9be687a1d0 [mbedtls] move mbedtls to 2.28.0 LTS version (#7539)
- Squashed 'third_party/mbedtls/repo/' content from commit 23e9e0bd2

git-subtree-dir: third_party/mbedtls/repo
git-subtree-split: 23e9e0bd2c7d1b5496773356d5a2c0c56d722d93

- update Makefiles
- update `check-android-build`
2022-04-07 10:35:51 -07:00
Abtin Keshavarzian 9021935bcc [log] add OT_SHOULD_LOG_AT(aLevel) (#7456)
This commit adds new helper macro `OT_SHOULD_LOG_AT(aLevel)` which
indicates whether logging is enabled at a given log level. This helps
simplify the code and makes sure the the condition used for enabling
logging related functions/methods is consistent across all the core
modules.

With this change, when `OPENTHREAD_CONFIG_LOG_OUTPUT` is set to
`LOG_OUTPUT_NONE` (which practically disables all logging), all the
related code/methods that are used to prepare the log line
(e.g. `Mac::OperationToString()`) are excluded from the build
(become empty functions/methods). This way, under `LOG_OUTPUT = NONE`
instead of preparing the log line and then passing it to an empty
`otPlatLog()` implementation to be dropped, the code is optimized to
not prepare the log line in first place.
2022-03-09 10:38:50 -08:00
Yakun Xu bdec466cee [build] remove unnecessary config files (#7414)
This commit removes unnecessary OPENTHREAD_CONFIG_FILE by only
including it when it's defined.
2022-02-22 12:44:06 -08:00
Yi a201e9d5d0 [tests] add tests for NAT64 prefix advertisement (#7361)
This commit adds tests for NAT64 prefix
advertisement. BORDER_ROUTING_NAT64 is set to 1 to enable the feature
in tests.

It also adjusted some util functions for prefixes and routes in
netdata.

Testing outbound connectivity to IPv4 hosts is not covered yet. It
will be added after we update OTBR.
2022-02-11 00:08:10 -08:00
Simon Lin 40b5fd3749 [trel] small updates and adding trel test (#7205)
- Adds platform API `trelDnssdInitialize` to initialize TREL
  DNS-SD module.
- Adds `test_trel_connectivity.py` test.
- Fixed `Border Router` TREL test to really use TREL.
2022-01-28 12:07:42 -08:00
Yakun Xu f113eb4b71 [script] support cmake-build in different dir (#7344)
This commit allows calling this cmake-build script from a different
directory. Currently it only supports root of OpenThread source.
2022-01-23 22:12:22 -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
Abtin Keshavarzian 88973676c5 [continuous-integration] enable BORDER_ROUTING in some of build scripts (#7321)
This commit enables `OT_BORDER_ROUTING` feature in some of the
build scripts (e.g., `script/check-scan-build` or `make-pretty`) so
that it is covered by github actions workflow CI.
2022-01-18 16:41:59 -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
Abtin Keshavarzian a04a68b51b [logging] simplify logging by removing DEFINE_AS_MACRO_ONLY (#7268)
This commit removes `OPENTHREAD_CONFIG_LOG_DEFINE_AS_MACRO_ONLY`.
which helps simplify the logging implementation. This feature enabled
all logging including the platform API to be defined as macros and
was intended for certain restricted platforms. With the new logging
model, OpenThread core itself will prepare the entire log line
instead of platform layer, so this feature is no longer applicable or
useful.
2022-01-04 21:42:27 -08:00
whd 13870f5e57 [firewall] ingress filtering (#7107)
This commit implements OTBR firewall. This implementation focuses on
ingress filtering. We may also introduce egress filtering when
necessary.

For security purpose, there are some packet forwarding rules to
follow, which were originally introduced in the spec.

- Inbound packets initiated with On-Link addresses source (OMR and
  mesh local prefix based addresses) should be blocked.

- Inbound unicast packets whose destination address is not OMR address
  or DUA should be blocked.

- Inbound unicast packets whose source address or destination address
  is link-local should be blocked. Note that we don’t need to
  explicitly add rules for link-local addresses since this should
  already be handled by the kernel.

These rules can be easily implemented by iptables and ipset.

Before otbr-agent starts, there is a script creating the iptables
rules. The rules themselves are constant so we don't need to change
them dynamically. During the runtime of otbr-agent, otbr-agent updates
ipsets accordingly whenever there's a change of on-link prefixes.
2021-12-13 09:17:21 -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
Abtin Keshavarzian afcfb7ac00 [script] update check-simulation-build-cmake to local options variable (#7090) 2021-10-22 11:54:11 -07:00
Jonathan Hui ea2783f5cb Revert "[border-router] firewall: ingress filtering (#7043)" (#7096)
This reverts commit c88a37b658.
2021-10-20 23:14:39 -07:00
whd c88a37b658 [border-router] firewall: ingress filtering (#7043)
This commit implements part of the OTBR firewall. This implementation
focuses on the ingress filtering part. We may also introduce egress
filtering part when necessary.

For security purpose, there are some packet forwarding rules to
follow, which were originally introduced in the spec.
- Inbound packets initiated with On-Link addresses source (OMR and
  mesh local prefix based addresses) should be blocked.
- Inbound unicast packets whose destination address is not OMR address
  or DUA should be blocked.
- Inbound unicast packets whose source address or destination address
  is link-local should be blocked. Note that we don’t need to
  explicitly add rules for link-local addresses since this should
  already be handled by the kernel.

These rules can be easily implemented by iptables and ipset.
- Before otbr-agent starts, there is a script creating the iptables
  rules. The rules themselves are constant so we don't need to change
  them dynamically.
- During the runtime of otbr-agent, otbr-agent updates ipsets
  accordingly whenever there's a change of on-link prefixes.
2021-10-20 17:14:56 -07:00
Yakun Xu 71e4df9820 [daemon] add environment to allow all users access (#7076)
This commit adds an environment variable to allow all users access
Thread daemon via ot-ctl.
2021-10-18 13:02:50 -07:00
kangping 31320993fb [docs] add document for running BR tests locally (#7044) 2021-10-01 08:13:31 -07:00
Simon Lin dc7676a032 [br-tests] enable BR tests with TREL (#7022)
This commit runs all Border Router (OTBR) tests with TREL enabled.
2021-09-28 09:10:26 -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
Jonathan Hui b9fadd227b [github-actions] use --no-check-certificates when invoking wget (#7011) 2021-09-15 19:58:03 -07:00
Simon Lin 7ba6111516 [thread-cert] output more logs in OTBR tests (#7003) 2021-09-13 08:49:02 -07:00
Jonathan Hui 6aac6708a7 [script] update scan-build to use cmake/ninja (#6982) 2021-09-09 15:48:53 -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 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
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
Simon Lin d8ad60ff6d [dns-sd] add DNS-SD server network interface binding configuration(#6838)
This commit allows DNS-SD server to configure the network interface to
bind the UDP socket.
2021-08-05 22:34:31 -07:00
Yakun Xu 354387c931 [test] fix reporting expect failure (#6869)
This commit fixes reporting expect failures by adding fail on error
flag to the ot_exec_expect_script function in script/test script.

This commit also fixes failing expect tests and removes expect tests
on macOS for unstable issues.
2021-08-02 20:26:32 -07:00
Yakun Xu e40c01d355 [build] allow specify build date time (#6856)
This commit adds a macro for specifying OpenThread build date time,
which can be empty so that this field can be omitted.
2021-07-27 18:18:57 -07:00
Jonathan Hui 5f39ba055b [srp-server] fix clang-tidy warnings (#6822)
- enable SRP server in clang-tidy check
- remove static member access through instance
2021-07-16 09:49:18 -07:00
Jonathan Hui d89f9222f0 [multi-radio] fix clang-tidy warnings (#6821)
- enable TREL in clang-tidy check
- add explicit keyword to constructors
- fix inconsistent parameter names
- remove redundant initializer
- use nullptr
2021-07-16 09:48:56 -07:00