diff --git a/.clang-format b/.clang-format
index dce55a85efc..b384cc6d396 100644
--- a/.clang-format
+++ b/.clang-format
@@ -11,7 +11,7 @@ AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: InlineOnly
+AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
diff --git a/examples/platforms/cc2538/Makefile.platform.am b/.github/dependabot.yml
similarity index 78%
rename from examples/platforms/cc2538/Makefile.platform.am
rename to .github/dependabot.yml
index f908b4ed863..b4cb6e3b232 100644
--- a/examples/platforms/cc2538/Makefile.platform.am
+++ b/.github/dependabot.yml
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2017, The OpenThread Authors.
+# Copyright (c) 2022, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -26,14 +26,13 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-#
-# cc2538 platform-specific Makefile
-#
-
-LDADD_COMMON += \
- $(top_builddir)/examples/platforms/cc2538/libopenthread-cc2538.a \
- $(NULL)
-
-LDFLAGS_COMMON += \
- -T $(top_srcdir)/examples/platforms/cc2538/cc2538.ld \
- $(NULL)
+version: 2
+updates:
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ commit-message:
+ prefix: "github-actions"
+ rebase-strategy: "disabled"
+ open-pull-requests-limit: 1
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d158eeaac6f..b385b343178 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -28,28 +28,38 @@
name: Build
-on: [push, pull_request]
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
-jobs:
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+permissions:
+ contents: read
+
+jobs:
pretty:
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
- sudo apt-get --no-install-recommends install -y clang-format-9 clang-tidy-9 shellcheck
+ sudo apt-get --no-install-recommends install -y clang-format-14 clang-tidy-14 shellcheck
python3 -m pip install yapf==0.31.0
sudo snap install shfmt
- name: Check
@@ -59,23 +69,39 @@ jobs:
markdown-lint-check:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
- - uses: gaurav-nelson/github-action-markdown-link-check@v1
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - uses: gaurav-nelson/github-action-markdown-link-check@5c5dfc0ac2e225883c0e5f03a85311ec2830d368 # v1
with:
use-verbose-mode: 'yes'
max-depth: 3
cmake-version:
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
- sudo pip3 install --system -U cmake==3.10.3
+ sudo apt-get --no-install-recommends install -y build-essential ninja-build libreadline-dev libncurses-dev
+ sudo apt-get remove cmake
+ sudo apt-get purge --auto-remove cmake
+ wget http://www.cmake.org/files/v3.10/cmake-3.10.3.tar.gz
+ tar xf cmake-3.10.3.tar.gz
+ cd cmake-3.10.3
+ ./configure
+ sudo make install
cmake --version | grep 3.10.3
- sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
- name: Build
run: |
OT_NODE_TYPE=rcp ./script/test build
@@ -97,7 +123,12 @@ jobs:
CC: ${{ matrix.compiler_c }}
CXX: ${{ matrix.compiler_cpp }}
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -109,33 +140,43 @@ jobs:
script/test package
scan-build:
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
- sudo apt-get --no-install-recommends install -y clang-tools-9 ninja-build
+ sudo apt-get --no-install-recommends install -y clang-tools-14 ninja-build
- name: Run
run: |
script/check-scan-build
mbedtls3-build:
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
rm -rf third_party/mbedtls/repo
- - uses: actions/checkout@v2
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
repository: ARMmbed/mbedtls
- ref: v3.1.0
+ ref: v3.2.1
path: third_party/mbedtls/repo
- name: Build
run: |
@@ -143,7 +184,7 @@ jobs:
arm-gcc:
name: arm-gcc-${{ matrix.gcc_ver }}
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
@@ -163,37 +204,63 @@ jobs:
- gcc_ver: 9
gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
gcc_extract_dir: gcc-arm-none-eabi-9-2019-q4-major
+ - gcc_ver: 10
+ gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
+ gcc_extract_dir: gcc-arm-none-eabi-10.3-2021.10
+ - gcc_ver: 11
+ gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz
+ gcc_extract_dir: arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi
+ - gcc_ver: 12
+ gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz
+ gcc_extract_dir: arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
cd /tmp
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
- sudo apt-get --no-install-recommends install -y lib32z1 ninja-build gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
- wget --tries 4 --no-check-certificate --quiet ${{ matrix.gcc_download_url }} -O gcc-arm.tar.bz2
- tar xjf gcc-arm.tar.bz2
- # use the minimal required cmake version
- sudo pip3 install --system -U cmake==3.10.3
+ sudo apt-get --no-install-recommends install -y build-essential lib32z1 ninja-build gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
+ wget --tries 4 --no-check-certificate --quiet ${{ matrix.gcc_download_url }} -O gcc-arm
+ tar xf gcc-arm
+ sudo apt-get remove cmake
+ sudo apt-get purge --auto-remove cmake
+ wget http://www.cmake.org/files/v3.10/cmake-3.10.3.tar.gz
+ tar xf cmake-3.10.3.tar.gz
+ cd cmake-3.10.3
+ ./configure
+ sudo make install
cmake --version | grep 3.10.3
- name: Build
+ env:
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
export PATH=/tmp/${{ matrix.gcc_extract_dir }}/bin:$PATH
script/check-arm-build
gcc:
name: gcc-${{ matrix.gcc_ver }}
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
- gcc_ver: [5, 6, 7, 8, 9, 10, 11]
+ gcc_ver: [9, 10, 11, 12]
env:
CC: gcc-${{ matrix.gcc_ver }}
CXX: g++-${{ matrix.gcc_ver }}
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -216,12 +283,17 @@ jobs:
strategy:
fail-fast: false
matrix:
- clang_ver: ["6.0", "7", "8", "9", "10", "11", "12", "13"]
+ clang_ver: ["9", "10", "11", "12", "13"]
env:
CC: clang-${{ matrix.clang_ver }}
CXX: clang++-${{ matrix.clang_ver }}
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -246,7 +318,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- clang_ver: ["6.0", "7", "8", "9", "10", "11", "12", "13"]
+ clang_ver: ["9", "10", "11", "12", "13"]
env:
CC: clang-${{ matrix.clang_ver }}
CXX: clang++-${{ matrix.clang_ver }}
@@ -254,7 +326,12 @@ jobs:
CXXFLAGS: -m32 -Wconversion
LDFLAGS: -m32
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -277,7 +354,12 @@ jobs:
gn:
runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -308,27 +390,52 @@ jobs:
CC: ${{ matrix.CC }}
CXX: ${{ matrix.CXX }}
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
- rm -f '/usr/local/bin/2to3'
brew update
- brew install automake m4 ninja
- [ ${{ matrix.CC }} != clang ] || brew install llvm
+ brew install automake m4
+ wget --tries 4 https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-mac.zip
+ unzip ninja-mac.zip && mv ninja /usr/local/bin/.
- name: Build
run: |
export PATH=$(brew --prefix m4)/bin:$PATH
script/check-posix-build
script/check-simulation-build
- android:
- runs-on: ubuntu-20.04
+ android-ndk:
+ name: android-ndk
+ runs-on: ubuntu-22.04
+ container:
+ image: openthread/environment
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
+ - name: Install unzip
+ run: apt update && apt install -y unzip
+ - name: Setup NDK
+ id: setup-ndk
+ uses: nttld/setup-ndk@v1
+ with:
+ ndk-version: r25c
+ local-cache: true
+
- name: Build
+ env:
+ NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
- docker run --rm -v $PWD:/build/openthread openthread/android-trusty /build/openthread/script/check-android-build
+ rm -rf build/ && OT_CMAKE_NINJA_TARGET="ot-daemon ot-ctl" script/cmake-build android-ndk
+ rm -rf build/ && OT_CMAKE_NINJA_TARGET="ot-cli" script/cmake-build android-ndk
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 00000000000..fc4821b2bf2
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,85 @@
+#
+# Copyright (c) 2022, The OpenThread Authors.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the copyright holder nor the
+# names of its contributors may be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+name: "CodeQL"
+
+on:
+ push:
+ branches: [ "main" ]
+ pull_request:
+ branches: [ "main" ]
+
+permissions: # added using https://github.com/step-security/secure-workflows
+ contents: read
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ 'cpp', 'python' ]
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
+
+ steps:
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - name: Checkout repository
+ uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+
+ - name: Bootstrap
+ run: |
+ sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
+
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@7df0ce34898d659f95c0c4a09eaa8d4e32ee64db # v2.2.12
+ with:
+ languages: ${{ matrix.language }}
+ # If you wish to specify custom queries, you can do so here or in a config file.
+ # By default, queries listed here will override any specified in a config file.
+ # Prefix the list here with "+" to use these queries and those in the config file.
+
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
+ # queries: security-extended,security-and-quality
+
+ - run: |
+ ./script/test build
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@7df0ce34898d659f95c0c4a09eaa8d4e32ee64db # v2.2.12
+ with:
+ category: "/language:${{matrix.language}}"
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 339bb1a09a7..46786d4669b 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -28,17 +28,22 @@
name: Docker
-on: [push, pull_request]
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
-jobs:
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+permissions: # added using https://github.com/step-security/secure-workflows
+ contents: read
+
+jobs:
buildx:
name: buildx-${{ matrix.docker_name }}
@@ -49,7 +54,12 @@ jobs:
include:
- docker_name: environment
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
@@ -63,17 +73,17 @@ jobs:
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
- echo ::set-output name=docker_image::${DOCKER_IMAGE}
- echo ::set-output name=version::${VERSION}
- echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
+ echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
+ echo "version=${VERSION}" >> $GITHUB_OUTPUT
+ echo "buildx_args=--platform ${DOCKER_PLATFORMS} \
--build-arg OT_GIT_REF=${{ github.sha }} \
--build-arg VERSION=${VERSION} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=${GITHUB_SHA::8} \
- ${TAGS} --file ${DOCKER_FILE} .
+ ${TAGS} --file ${DOCKER_FILE} ." >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v1
+ uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0
- name: Docker Buildx (build)
run: |
@@ -81,7 +91,7 @@ jobs:
- name: Login to DockerHub
if: success() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
- uses: docker/login-action@v1
+ uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml
index 8f549c50514..e1b37fe67b0 100644
--- a/.github/workflows/fuzz.yml
+++ b/.github/workflows/fuzz.yml
@@ -27,24 +27,41 @@
#
name: CIFuzz
-on: [pull_request]
+
+on:
+ pull_request:
+ branches:
+ - 'main'
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
+
+permissions: # added using https://github.com/step-security/secure-workflows
+ contents: read
+
jobs:
Fuzzing:
runs-on: ubuntu-20.04
steps:
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
- name: Build Fuzzers
- uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
+ uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@c0e4bb8d15a68b7f8cc731ea75523e48a2301bcf # master
with:
oss-fuzz-project-name: 'openthread'
dry-run: false
- name: Run Fuzzers
- uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
+ uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@c0e4bb8d15a68b7f8cc731ea75523e48a2301bcf # master
with:
oss-fuzz-project-name: 'openthread'
fuzz-seconds: 1800
dry-run: false
- name: Upload Crash
- uses: actions/upload-artifact@v1
+ uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: failure()
with:
name: artifacts
diff --git a/.github/workflows/makefile-check.yml b/.github/workflows/makefile-check.yml
index 37e80243cf0..6972074492e 100644
--- a/.github/workflows/makefile-check.yml
+++ b/.github/workflows/makefile-check.yml
@@ -28,21 +28,31 @@
name: Makefile Check
-on: [push, pull_request]
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
-jobs:
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
+
+permissions: # added using https://github.com/step-security/secure-workflows
+ contents: read
+jobs:
makefile-check:
runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Check
diff --git a/.github/workflows/otbr.yml b/.github/workflows/otbr.yml
index 6f9412b8665..9cab9ad97fe 100644
--- a/.github/workflows/otbr.yml
+++ b/.github/workflows/otbr.yml
@@ -28,17 +28,22 @@
name: Border Router
-on: [push, pull_request]
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
-jobs:
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+permissions:
+ contents: read
+
+jobs:
backbone-router:
runs-on: ubuntu-20.04
@@ -57,7 +62,7 @@ jobs:
# of OMR prefix and Domain prefix is not deterministic.
BORDER_ROUTING: 0
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Build OTBR Docker
@@ -81,11 +86,11 @@ jobs:
export CI_ENV="$(bash <(curl -s https://codecov.io/env)) -e GITHUB_ACTIONS -e COVERAGE"
echo "CI_ENV=${CI_ENV}"
sudo -E ./script/test cert_suite ./tests/scripts/thread-cert/backbone/*.py || (sudo chmod a+r *.log *.json *.pcap && false)
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-thread-1-3-backbone-docker
path: /tmp/coverage/
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: thread-1-3-backbone-results
@@ -98,7 +103,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-thread-1-3-backbone
path: tmp/coverage.info
@@ -138,7 +143,7 @@ jobs:
cert_scripts: ./tests/scripts/thread-cert/border_router/nat64/*.py
packet_verification: 1
nat64: 1
- description: "nat64"
+ description: "nat64 openthread"
- otbr_mdns: "avahi"
otbr_trel: 0
cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
@@ -167,7 +172,7 @@ jobs:
NAT64: ${{ matrix.nat64 }}
MAX_JOBS: 3
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Build OTBR Docker
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
@@ -190,11 +195,11 @@ jobs:
export CI_ENV="$(bash <(curl -s https://codecov.io/env)) -e GITHUB_ACTIONS -e COVERAGE"
echo "CI_ENV=${CI_ENV}"
sudo -E ./script/test cert_suite ${{ matrix.cert_scripts }} || (sudo chmod a+r *.log *.json *.pcap && false)
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-thread-border-router-docker
path: /tmp/coverage/
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: thread-border-router-results
@@ -207,7 +212,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-thread-border-router
path: tmp/coverage.info
@@ -218,13 +223,13 @@ jobs:
- thread-border-router
runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- - uses: actions/download-artifact@v2
+ - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
path: coverage/
- name: Combine Coverage
@@ -233,7 +238,7 @@ jobs:
script/test combine_coverage
- name: Upload Coverage
continue-on-error: true
- uses: codecov/codecov-action@v2
+ uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3
with:
files: final.info
fail_ci_if_error: true
@@ -242,7 +247,7 @@ jobs:
needs: upload-coverage
runs-on: ubuntu-20.04
steps:
- - uses: geekyeggo/delete-artifact@1-glob-support
+ - uses: geekyeggo/delete-artifact@54ab544f12cdb7b71613a16a2b5a37a9ade990af # v2.0.0
with:
name: cov-*
useGlob: true
diff --git a/.github/workflows/otci.yml b/.github/workflows/otci.yml
index a1e3a9b99df..46f07450e8c 100644
--- a/.github/workflows/otci.yml
+++ b/.github/workflows/otci.yml
@@ -28,17 +28,22 @@
name: OTCI
-on: [push, pull_request]
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
-jobs:
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+permissions: # added using https://github.com/step-security/secure-workflows
+ contents: read
+
+jobs:
cli-sim:
name: cli-sim VIRTUAL_TIME=${{ matrix.virtual_time }}
@@ -48,25 +53,33 @@ jobs:
matrix:
virtual_time: [0, 1]
env:
- REFERENCE_DEVICE: 1
VIRTUAL_TIME: ${{ matrix.virtual_time }}
REAL_DEVICE: 0
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
- sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel
+ sudo apt-get --no-install-recommends install -y g++-multilib ninja-build python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
+ python3 -m pip install pytype adb-shell
+ - name: Style check
+ run: |
+ PYTHONPATH=./tests/scripts/thread-cert pytype tools/otci
- name: Build
run: |
- ./bootstrap
- make -f examples/Makefile-simulation THREAD_VERSION=1.3 DUA=1 MLR=1 BACKBONE_ROUTER=1 CSL_RECEIVER=1
+ ./script/cmake-build simulation -DOT_THREAD_VERSION=1.3 -DOT_DUA=ON -DOT_MLR=ON -DOT_BACKBONE_ROUTER=ON \
+ -DOT_CSL_RECEIVER=ON -DOT_SIMULATION_VIRTUAL_TIME=${VIRTUAL_TIME}
- name: Install OTCI Python Library
run: |
- (cd tools/otci && python3 setup.py install --user)
+ (cd tools/otci && python3 -m pip install .)
- name: Run
run: |
export PYTHONPATH=./tests/scripts/thread-cert/
- export OT_CLI=./output/simulation/bin/ot-cli-ftd
+ export OT_CLI=./build/simulation/examples/apps/cli/ot-cli-ftd
python3 tools/otci/tests/test_otci.py
diff --git a/.github/workflows/otns.yml b/.github/workflows/otns.yml
index 46dc33c65e6..ba09fbdce58 100644
--- a/.github/workflows/otns.yml
+++ b/.github/workflows/otns.yml
@@ -28,7 +28,17 @@
name: OTNS
-on: [push, pull_request]
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
env:
COVERAGE: 1
@@ -38,28 +48,28 @@ env:
MAX_NETWORK_SIZE: 999
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
-jobs:
+permissions: # added using https://github.com/step-security/secure-workflows
+ contents: read
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+jobs:
unittests:
name: Unittests
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-go@v1
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
- go-version: '1.14'
- - name: Set up Python 3.6
- uses: actions/setup-python@v1
+ go-version: "1.20"
+ - name: Set up Python
+ uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
with:
- python-version: 3.6
+ python-version: "3.9"
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
@@ -73,7 +83,7 @@ jobs:
cd /tmp/otns
./script/test py-unittests
)
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: unittests-pcaps
@@ -83,23 +93,23 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-otns-unittests
path: tmp/coverage.info
examples:
name: Examples
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-go@v1
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
- go-version: '1.14'
- - name: Set up Python 3.6
- uses: actions/setup-python@v1
+ go-version: "1.20"
+ - name: Set up Python
+ uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
with:
- python-version: 3.6
+ python-version: "3.9"
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
@@ -113,7 +123,7 @@ jobs:
cd /tmp/otns
./script/test py-examples
)
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: examples-pcaps
@@ -123,14 +133,14 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-otns-examples
path: tmp/coverage.info
stress-tests:
name: Stress ${{ matrix.suite }}
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
@@ -150,14 +160,19 @@ jobs:
env:
STRESS_LEVEL: ${{ matrix.stress_level }}
steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-go@v1
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
- go-version: '1.14'
- - name: Set up Python 3.6
- uses: actions/setup-python@v1
+ go-version: "1.20"
+ - name: Set up Python
+ uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
with:
- python-version: 3.6
+ python-version: "3.9"
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
@@ -171,7 +186,7 @@ jobs:
cd /tmp/otns
./script/test stress-tests ${{ matrix.suite }}
)
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: stress-tests-${{ matrix.suite }}-pcaps
@@ -181,7 +196,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-otns-stress-tests-${{ matrix.suite }}
path: tmp/coverage.info
@@ -191,13 +206,18 @@ jobs:
- unittests
- examples
- stress-tests
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- - uses: actions/download-artifact@v2
+ - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
path: coverage/
- name: Upload Coverage
diff --git a/.github/workflows/posix.yml b/.github/workflows/posix.yml
index 2ec9fa574f3..ded9e81def7 100644
--- a/.github/workflows/posix.yml
+++ b/.github/workflows/posix.yml
@@ -28,25 +28,35 @@
name: POSIX
-on: [push, pull_request]
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
-jobs:
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+permissions:
+ contents: read
+
+jobs:
expects-linux:
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-20.04
env:
CFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15
CXXFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y expect ninja-build lcov socat
@@ -55,13 +65,17 @@ jobs:
ulimit -c unlimited
./script/test prepare_coredump_upload
OT_OPTIONS='-DOT_READLINE=OFF -DOT_FULL_LOGS=ON -DOT_LOG_OUTPUT=PLATFORM_DEFINED' VIRTUAL_TIME=0 OT_NODE_TYPE=rcp ./script/test build expect
+ - name: Run ot-fct
+ run: |
+ OT_CMAKE_NINJA_TARGET="ot-fct" script/cmake-build posix
+ tests/scripts/expect/ot-fct.exp
- name: Check Crash
if: ${{ failure() }}
run: |
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED_RCP=$CRASHED" >> $GITHUB_ENV
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() && env.CRASHED_RCP == '1' }}
with:
name: core-expect-rcp
@@ -70,19 +84,19 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-expects-linux-1
path: tmp/coverage.info
- name: Run TUN Mode
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
- sudo apt-get install --no-install-recommends -y dnsmasq bind9-host ntp
- sudo systemctl start dnsmasq ntp
- host ipv6.google.com 127.0.0.1
- echo 'listen-address=::1' | sudo tee /etc/dnsmasq.conf
echo 0 | sudo tee /proc/sys/net/ipv6/conf/all/disable_ipv6
- sudo systemctl restart dnsmasq
+ sudo apt-get install --no-install-recommends -y bind9-host ntp socat
+ sudo systemctl restart ntp
+ sudo socat 'UDP6-LISTEN:53,fork,reuseaddr,bind=[::1]' UDP:127.0.0.53:53 &
+ socat 'TCP6-LISTEN:2000,fork,reuseaddr' TCP:127.0.0.53:53 &
+ host ipv6.google.com 127.0.0.53
host ipv6.google.com ::1
ulimit -c unlimited
./script/test prepare_coredump_upload
@@ -93,13 +107,13 @@ jobs:
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED_TUN=$CRASHED" >> $GITHUB_ENV
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() && env.CRASHED_TUN == '1' }}
with:
name: core-expect-linux
path: |
./ot-core-dump/*
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: syslog-expect-linux
@@ -107,7 +121,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-expects-linux-2
path: tmp/coverage.info
@@ -117,37 +131,37 @@ jobs:
env:
COVERAGE: 1
PYTHONUNBUFFERED: 1
- READLINE: readline
- REFERENCE_DEVICE: 1
THREAD_VERSION: 1.1
VIRTUAL_TIME: 1
- VIRTUAL_TIME_UART: 1
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
- sudo apt-get --no-install-recommends install -y libreadline6-dev python3-setuptools python3-wheel lcov
+ sudo apt-get --no-install-recommends install -y lcov ninja-build python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
- ./bootstrap
- make -f examples/Makefile-simulation
- make -f src/posix/Makefile-posix
+ OT_NODE_TYPE=rcp ./script/test build
- name: Run
run: |
- VERBOSE=1 OT_CLI_PATH="$PWD/output/posix/bin/ot-cli -v" RADIO_DEVICE="$PWD/output/simulation/bin/ot-rcp" make -f src/posix/Makefile-posix check
- - uses: actions/upload-artifact@v2
+ MAX_JOBS=$(getconf _NPROCESSORS_ONLN) ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: thread-cert
- path: build/posix/tests/scripts/thread-cert
+ path: ot_testing
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-thread-cert
path: tmp/coverage.info
@@ -157,7 +171,12 @@ jobs:
env:
COVERAGE: 1
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -174,7 +193,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-ncp-rcp-migrate
path: tmp/coverage.info
@@ -191,7 +210,12 @@ jobs:
OT_DAEMON: ${{ matrix.OT_DAEMON }}
OT_READLINE: 'readline'
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
@@ -219,7 +243,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-pty-linux-${{ matrix.DAEMON }}
path: tmp/coverage.info
@@ -235,10 +259,24 @@ jobs:
OT_DAEMON: ${{ matrix.OT_DAEMON }}
OT_READLINE: 'off'
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Bootstrap
run: |
- rm -f '/usr/local/bin/2to3'
+ rm -f /usr/local/bin/2to3
+ rm -f /usr/local/bin/2to3-3.11
+ rm -f /usr/local/bin/idle3
+ rm -f /usr/local/bin/idle3.11
+ rm -f /usr/local/bin/pydoc3
+ rm -f /usr/local/bin/pydoc3.11
+ rm -f /usr/local/bin/python3
+ rm -f /usr/local/bin/python3.11
+ rm -f /usr/local/bin/python3-config
+ rm -f /usr/local/bin/python3.11-config
brew update
brew install ninja socat
- name: Build
@@ -251,7 +289,12 @@ jobs:
rcp-stack-reset:
runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Bootstrap
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
@@ -267,7 +310,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-rcp-stack-reset
path: tmp/coverage.info
@@ -280,20 +323,25 @@ jobs:
- thread-cert
runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- - uses: actions/download-artifact@v2
+ - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
path: coverage/
- name: Combine Coverage
run: |
script/test combine_coverage
- name: Upload Coverage
- uses: codecov/codecov-action@v2
+ uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3
with:
files: final.info
fail_ci_if_error: true
@@ -302,7 +350,12 @@ jobs:
needs: upload-coverage
runs-on: ubuntu-20.04
steps:
- - uses: geekyeggo/delete-artifact@1-glob-support
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: geekyeggo/delete-artifact@54ab544f12cdb7b71613a16a2b5a37a9ade990af # v2.0.0
with:
name: cov-*
useGlob: true
diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml
new file mode 100644
index 00000000000..3d982a4325d
--- /dev/null
+++ b/.github/workflows/scorecards.yml
@@ -0,0 +1,100 @@
+#
+# Copyright (c) 2022, The OpenThread Authors.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the copyright holder nor the
+# names of its contributors may be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+# This workflow uses actions that are not certified by GitHub. They are provided
+# by a third-party and are governed by separate terms of service, privacy
+# policy, and support documentation.
+
+name: Scorecards supply-chain security
+on:
+ # For Branch-Protection check. Only the default branch is supported. See
+ # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
+ branch_protection_rule:
+ # To guarantee Maintained check is occasionally updated. See
+ # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
+ schedule:
+ - cron: '33 12 * * 0'
+ push:
+ branches: [ "main" ]
+
+# Declare default permissions as read only.
+permissions: read-all
+
+jobs:
+ analysis:
+ name: Scorecards analysis
+ runs-on: ubuntu-latest
+ permissions:
+ # Needed to upload the results to code-scanning dashboard.
+ security-events: write
+ # Needed to publish results and get a badge (see publish_results below).
+ id-token: write
+ # Uncomment the permissions below if installing in a private repository.
+ # contents: read
+ # actions: read
+
+ steps:
+ - name: "Checkout code"
+ uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ with:
+ persist-credentials: false
+
+ - name: "Run analysis"
+ uses: ossf/scorecard-action@80e868c13c90f172d68d1f4501dee99e2479f7af # v2.1.3
+ with:
+ results_file: results.sarif
+ results_format: sarif
+ # (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
+ # - you want to enable the Branch-Protection check on a *public* repository, or
+ # - you are installing Scorecards on a *private* repository
+ # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
+ # repo_token: ${{ secrets.SCORECARD_TOKEN }}
+
+ # Public repositories:
+ # - Publish results to OpenSSF REST API for easy access by consumers
+ # - Allows the repository to include the Scorecard badge.
+ # - See https://github.com/ossf/scorecard-action#publishing-results.
+ # For private repositories:
+ # - `publish_results` will always be set to `false`, regardless
+ # of the value entered here.
+ publish_results: true
+
+ # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
+ # format to the repository Actions tab.
+ - name: "Upload artifact"
+ uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.0
+ with:
+ name: SARIF file
+ path: results.sarif
+ retention-days: 5
+
+ # Upload the results to GitHub's code scanning dashboard.
+ - name: "Upload to code-scanning"
+ uses: github/codeql-action/upload-sarif@7df0ce34898d659f95c0c4a09eaa8d4e32ee64db # v2.1.27
+ with:
+ sarif_file: results.sarif
diff --git a/.github/workflows/simulation-1.1.yml b/.github/workflows/simulation-1.1.yml
index 3754c9d3cc7..d996c0e6320 100644
--- a/.github/workflows/simulation-1.1.yml
+++ b/.github/workflows/simulation-1.1.yml
@@ -28,17 +28,22 @@
name: Simulation 1.1
-on: [push, pull_request]
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
-jobs:
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+permissions:
+ contents: read
+
+jobs:
distcheck:
runs-on: ubuntu-20.04
@@ -49,7 +54,12 @@ jobs:
THREAD_VERSION: 1.1
VIRTUAL_TIME: 1
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -75,7 +85,12 @@ jobs:
VIRTUAL_TIME: 1
MULTIPLY: 3
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -92,7 +107,7 @@ jobs:
- name: Run
run: |
./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: packet-verification-pcaps
@@ -102,7 +117,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-packet-verification
path: tmp/coverage.info
@@ -118,30 +133,34 @@ jobs:
THREAD_VERSION: 1.1
VIRTUAL_TIME: 1
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
- sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel lcov
+ sudo apt-get --no-install-recommends install -y lcov ninja-build g++-multilib python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
- ./bootstrap
- make -f examples/Makefile-simulation
+ ./script/test build
- name: Run
run: |
- VERBOSE=1 make -f examples/Makefile-simulation check
- - uses: actions/upload-artifact@v2
+ ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: cli-ftd-thread-cert
- path: build/simulation/tests/scripts/thread-cert
+ path: ot_testing
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-cli-ftd
path: tmp/coverage.info
@@ -164,30 +183,34 @@ jobs:
VIRTUAL_TIME: 1
MESSAGE_USE_HEAP: ${{ matrix.message_use_heap }}
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
- sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel lcov
+ sudo apt-get --no-install-recommends install -y lcov ninja-build g++-multilib python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
- ./bootstrap
- make -f examples/Makefile-simulation
+ ./script/test build
- name: Run
run: |
- VERBOSE=1 make -f examples/Makefile-simulation check
- - uses: actions/upload-artifact@v2
+ ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: cli-mtd-thread-cert
- path: build/simulation/tests/scripts/thread-cert
+ path: ot_testing
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-cli-mtd-${{ matrix.message_use_heap }}
path: tmp/coverage.info
@@ -201,45 +224,53 @@ jobs:
COVERAGE: 1
REFERENCE_DEVICE: 1
THREAD_VERSION: 1.1
- TIME_SYNC: 1
VIRTUAL_TIME: 1
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
- sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel lcov
+ sudo apt-get --no-install-recommends install -y g++-multilib lcov ninja-build python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
- ./bootstrap
- make -f examples/Makefile-simulation
+ OT_OPTIONS="-DOT_TIME_SYNC=ON" ./script/test build
- name: Run
run: |
- VERBOSE=1 make -f examples/Makefile-simulation check
- - uses: actions/upload-artifact@v2
+ ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: cli-time-sync-thread-cert
- path: build/simulation/tests/scripts/thread-cert
+ path: ot_testing
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-cli-time-sync
path: tmp/coverage.info
expects:
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-20.04
env:
CFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15
CXXFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15
THREAD_VERSION: 1.1
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y expect ninja-build lcov socat
@@ -254,7 +285,7 @@ jobs:
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED_CLI=$CRASHED" >> $GITHUB_ENV
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() && env.CRASHED_CLI == '1' }}
with:
name: core-expect-cli
@@ -263,7 +294,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-expects
path: tmp/coverage.info
@@ -273,7 +304,12 @@ jobs:
env:
THREAD_VERSION: 1.1
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -306,7 +342,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-ot-commissioner
path: tmp/coverage.info
@@ -315,35 +351,37 @@ jobs:
runs-on: ubuntu-20.04
env:
COVERAGE: 1
- MULTIPLE_INSTANCE: 1
- REFERENCE_DEVICE: 1
THREAD_VERSION: 1.1
VIRTUAL_TIME: 1
CXXFLAGS: "-DOPENTHREAD_CONFIG_LOG_PREPEND_UPTIME=0"
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
- sudo apt-get --no-install-recommends install -y python3-setuptools python3-wheel lcov
+ sudo apt-get --no-install-recommends install -y lcov ninja-build python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
- ./bootstrap
- make -f examples/Makefile-simulation
+ OT_OPTIONS="-DOT_MULTIPLE_INSTANCE=ON" ./script/test build
- name: Run
run: |
- VERBOSE=1 make -f examples/Makefile-simulation check
- - uses: actions/upload-artifact@v2
+ ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
- name: multiple-instance-thread-cert
+ name: ot_testing
path: build/simulation/tests/scripts/thread-cert
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-multiple-instance
path: tmp/coverage.info
@@ -359,20 +397,25 @@ jobs:
- multiple-instance
runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- - uses: actions/download-artifact@v2
+ - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
path: coverage/
- name: Combine Coverage
run: |
script/test combine_coverage
- name: Upload Coverage
- uses: codecov/codecov-action@v2
+ uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3
with:
files: final.info
fail_ci_if_error: true
@@ -381,7 +424,12 @@ jobs:
needs: upload-coverage
runs-on: ubuntu-20.04
steps:
- - uses: geekyeggo/delete-artifact@1-glob-support
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: geekyeggo/delete-artifact@54ab544f12cdb7b71613a16a2b5a37a9ade990af # v2.0.0
with:
name: cov-*
useGlob: true
diff --git a/.github/workflows/simulation-1.2.yml b/.github/workflows/simulation-1.2.yml
index 26166466d98..cbf2c9ee132 100644
--- a/.github/workflows/simulation-1.2.yml
+++ b/.github/workflows/simulation-1.2.yml
@@ -28,17 +28,22 @@
name: Simulation 1.3
-on: [push, pull_request]
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
-jobs:
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+permissions: # added using https://github.com/step-security/secure-workflows
+ contents: read
+
+jobs:
thread-1-3:
name: thread-1-3-${{ matrix.compiler.c }}-${{ matrix.arch }}
@@ -51,6 +56,7 @@ jobs:
THREAD_VERSION: 1.3
VIRTUAL_TIME: 1
INTER_OP: 1
+ INTER_OP_BBR: 1
CC: ${{ matrix.compiler.c }}
CXX: ${{ matrix.compiler.cxx }}
strategy:
@@ -59,7 +65,12 @@ jobs:
compiler: [{c: "gcc", cxx: "g++", gcov: "gcc"}, { c: "clang-10", cxx: "clang++-10", gcov: "llvm"}]
arch: ["m32", "m64"]
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -84,12 +95,12 @@ jobs:
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: thread-1-3-${{ matrix.compiler.c }}-${{ matrix.arch }}-pcaps
path: "*.pcap"
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-packet-verification-thread-1-3
@@ -98,7 +109,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage "${{ matrix.compiler.gcov }}"
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-thread-1-3-${{ matrix.compiler.c }}-${{ matrix.arch }}
path: tmp/coverage.info
@@ -115,7 +126,12 @@ jobs:
INTER_OP: 1
INTER_OP_BBR: 0
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -143,14 +159,14 @@ jobs:
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: packet-verification-low-power-pcaps
path: |
*.pcap
*.json
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-packet-verification-low-power
@@ -159,7 +175,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-packet-verification-low-power
path: tmp/coverage.info
@@ -171,9 +187,15 @@ jobs:
VIRTUAL_TIME: 1
PACKET_VERIFICATION: 1
THREAD_VERSION: 1.3
+ INTER_OP_BBR: 1
MULTIPLY: 3
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -190,7 +212,7 @@ jobs:
- name: Run
run: |
./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: packet-verification-1.1-on-1.3-pcaps
@@ -200,7 +222,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-packet-verification-1-1-on-1-3
path: tmp/coverage.info
@@ -212,7 +234,12 @@ jobs:
THREAD_VERSION: 1.3
VIRTUAL_TIME: 0
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -229,7 +256,7 @@ jobs:
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-expect-1-3
@@ -238,7 +265,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-expects
path: tmp/coverage.info
@@ -255,7 +282,12 @@ jobs:
VIRTUAL_TIME: 1
INTER_OP: 1
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -282,12 +314,12 @@ jobs:
CRASHED=$(./script/test check_crash | tail -1)
[[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed."
echo "CRASHED=$CRASHED" >> $GITHUB_ENV
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() }}
with:
name: thread-1-3-posix-pcaps
path: "*.pcap"
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: ${{ failure() && env.CRASHED == '1' }}
with:
name: core-thread-1-3-posix
@@ -296,7 +328,7 @@ jobs:
- name: Generate Coverage
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: cov-thread-1-3-posix
path: tmp/coverage.info
@@ -310,20 +342,25 @@ jobs:
- thread-1-3-posix
runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- - uses: actions/download-artifact@v2
+ - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
path: coverage/
- name: Combine Coverage
run: |
script/test combine_coverage
- name: Upload Coverage
- uses: codecov/codecov-action@v2
+ uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3
with:
files: final.info
fail_ci_if_error: true
@@ -332,7 +369,12 @@ jobs:
needs: upload-coverage
runs-on: ubuntu-20.04
steps:
- - uses: geekyeggo/delete-artifact@1-glob-support
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: geekyeggo/delete-artifact@54ab544f12cdb7b71613a16a2b5a37a9ade990af # v2.0.0
with:
name: cov-*
useGlob: true
diff --git a/.github/workflows/size.yml b/.github/workflows/size.yml
index 763fb4584ad..71afb0d2b68 100644
--- a/.github/workflows/size.yml
+++ b/.github/workflows/size.yml
@@ -28,22 +28,32 @@
name: Size
-on: [push, pull_request]
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
-jobs:
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+permissions:
+ contents: read
+
+jobs:
size-report:
runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Bootstrap
if: "github.event_name == 'push'"
run: |
diff --git a/.github/workflows/toranj.yml b/.github/workflows/toranj.yml
index 221913fded4..83cf71254f8 100644
--- a/.github/workflows/toranj.yml
+++ b/.github/workflows/toranj.yml
@@ -28,30 +28,42 @@
name: Toranj
-on: [push, pull_request]
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
-jobs:
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+permissions:
+ contents: read
+
+jobs:
toranj-ncp:
name: toranj-ncp-${{ matrix.TORANJ_RADIO }}
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
- TORANJ_RADIO: ['15.4', 'trel', 'multi']
+ TORANJ_RADIO: ['15.4']
env:
COVERAGE: 1
TORANJ_RADIO : ${{ matrix.TORANJ_RADIO }}
+ TORANJ_NCP : 1
+ TORANJ_EVENT_NAME: ${{ github.event_name }}
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -59,45 +71,28 @@ jobs:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
- sudo apt-get --no-install-recommends install -y dbus libdbus-1-dev
- sudo apt-get --no-install-recommends install -y autoconf-archive
- sudo apt-get --no-install-recommends install -y bsdtar
- sudo apt-get --no-install-recommends install -y libtool
- sudo apt-get --no-install-recommends install -y libglib2.0-dev
- sudo apt-get --no-install-recommends install -y libboost-dev libboost-signals-dev
- sudo apt-get --no-install-recommends install -y lcov
-
- script/git-tool clone --depth=1 --branch=master https://github.com/openthread/wpantund.git
- cd wpantund
- ./bootstrap.sh
- ./configure
- sudo make -j2
- sudo make install
- name: Build & Run
run: |
top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh
- - name: Generate Coverage
- if: "matrix.TORANJ_RADIO != 'multi'"
- run: |
- ./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
- if: "matrix.TORANJ_RADIO != 'multi'"
- with:
- name: cov-toranj-ncp-${{ matrix.TORANJ_RADIO }}
- path: tmp/coverage.info
+
toranj-cli:
name: toranj-cli-${{ matrix.TORANJ_RADIO }}
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-20.04
strategy:
matrix:
- TORANJ_RADIO: ['15.4']
+ TORANJ_RADIO: ['15.4', 'trel', 'multi']
env:
COVERAGE: 1
TORANJ_RADIO : ${{ matrix.TORANJ_RADIO }}
TORANJ_CLI: 1
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
@@ -105,7 +100,7 @@ jobs:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
- sudo apt-get --no-install-recommends install -y lcov
+ sudo apt-get --no-install-recommends install -y ninja-build lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build & Run
run: |
@@ -114,32 +109,62 @@ jobs:
if: "matrix.TORANJ_RADIO != 'multi'"
run: |
./script/test generate_coverage gcc
- - uses: actions/upload-artifact@v2
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: "matrix.TORANJ_RADIO != 'multi'"
with:
name: cov-toranj-cli-${{ matrix.TORANJ_RADIO }}
path: tmp/coverage.info
+ toranj-unittest:
+ name: toranj-unittest
+ runs-on: ubuntu-20.04
+ steps:
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ with:
+ submodules: true
+ - name: Bootstrap
+ env:
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
+ run: |
+ sudo dpkg --add-architecture i386
+ sudo apt-get update
+ sudo apt-get --no-install-recommends install -y clang-10 clang++-10 ninja-build python3-setuptools python3-wheel llvm lcov
+ sudo apt-get --no-install-recommends install -y g++-multilib libreadline-dev:i386 libncurses-dev:i386
+ python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
+ - name: Build & Run
+ run: |
+ ./tests/toranj/build.sh cmake
+ ninja test
+
upload-coverage:
needs:
- - toranj-ncp
- toranj-cli
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y lcov
- - uses: actions/download-artifact@v2
+ - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
path: coverage/
- name: Combine Coverage
run: |
script/test combine_coverage
- name: Upload Coverage
- uses: codecov/codecov-action@v2
+ uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3
with:
files: final.info
fail_ci_if_error: true
@@ -148,7 +173,12 @@ jobs:
needs: upload-coverage
runs-on: ubuntu-20.04
steps:
- - uses: geekyeggo/delete-artifact@1-glob-support
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: geekyeggo/delete-artifact@54ab544f12cdb7b71613a16a2b5a37a9ade990af # v2.0.0
with:
name: cov-*
useGlob: true
diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml
new file mode 100644
index 00000000000..a92c629a8ba
--- /dev/null
+++ b/.github/workflows/unit.yml
@@ -0,0 +1,137 @@
+#
+# Copyright (c) 2023, The OpenThread Authors.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the copyright holder nor the
+# names of its contributors may be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+name: Unit
+
+on:
+ push:
+ branches-ignore:
+ - 'dependabot/**'
+ pull_request:
+ branches:
+ - 'main'
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
+
+permissions: # added using https://github.com/step-security/secure-workflows
+ contents: read
+
+jobs:
+
+ tcplp-buffering:
+ runs-on: ubuntu-20.04
+ steps:
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ with:
+ submodules: true
+ - name: Build
+ run: make -C third_party/tcplp/lib/test/
+ - name: Run
+ run: third_party/tcplp/lib/test/test_all
+
+ unit-tests:
+ runs-on: ubuntu-20.04
+ env:
+ COVERAGE: 1
+ steps:
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ with:
+ submodules: true
+ - name: Bootstrap
+ run: |
+ sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
+ sudo apt-get --no-install-recommends install -y ninja-build lcov
+ - name: Build Simulation
+ run: ./script/cmake-build simulation
+ - name: Test Simulation
+ run: cd build/simulation && ninja test
+ - name: Build POSIX
+ run: ./script/cmake-build posix
+ - name: Test POSIX
+ run: cd build/posix && ninja test
+ - name: Generate Coverage
+ run: |
+ ./script/test generate_coverage gcc
+ - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
+ with:
+ name: cov-unit-tests
+ path: tmp/coverage.info
+
+
+ upload-coverage:
+ needs: unit-tests
+ runs-on: ubuntu-20.04
+ steps:
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ with:
+ submodules: true
+ - name: Bootstrap
+ run: |
+ sudo apt-get --no-install-recommends install -y lcov
+ - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
+ with:
+ path: coverage/
+ - name: Combine Coverage
+ run: |
+ script/test combine_coverage
+ - name: Upload Coverage
+ uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3
+ with:
+ files: final.info
+ fail_ci_if_error: true
+
+ delete-coverage-artifacts:
+ needs: upload-coverage
+ runs-on: ubuntu-20.04
+ steps:
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: geekyeggo/delete-artifact@54ab544f12cdb7b71613a16a2b5a37a9ade990af # v2.0.0
+ with:
+ name: cov-*
+ useGlob: true
diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml
index 37b110ca8ed..47828d36b46 100644
--- a/.github/workflows/version.yml
+++ b/.github/workflows/version.yml
@@ -28,21 +28,28 @@
name: API Version
-on: [pull_request]
+on:
+ pull_request:
+ branches:
+ - 'main'
-jobs:
- cancel-previous-runs:
- runs-on: ubuntu-20.04
- steps:
- - uses: rokroskar/workflow-run-cleanup-action@master
- env:
- GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- if: "github.ref != 'refs/heads/main'"
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }}
+ cancel-in-progress: true
+
+permissions: # added using https://github.com/step-security/secure-workflows
+ contents: read
+jobs:
api-version:
runs-on: ubuntu-20.04
steps:
- - uses: actions/checkout@v2
+ - name: Harden Runner
+ uses: step-security/harden-runner@6b3083af2869dc3314a0257a42f4af696cc79ba3 # v2.3.1
+ with:
+ egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
+
+ - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
submodules: true
- name: Check
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 642332f5e72..15659e86c5e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,7 @@ file(READ .default-version OT_DEFAULT_VERSION)
string(STRIP ${OT_DEFAULT_VERSION} OT_DEFAULT_VERSION)
project(openthread VERSION ${OT_DEFAULT_VERSION})
+include(CTest)
option(OT_BUILD_EXECUTABLES "Build executables" ON)
option(OT_COVERAGE "enable coverage" OFF)
@@ -40,6 +41,9 @@ set(OT_EXTERNAL_MBEDTLS "" CACHE STRING "Specify external mbedtls library")
option(OT_MBEDTLS_THREADING "enable mbedtls threading" OFF)
add_library(ot-config INTERFACE)
+add_library(ot-config-ftd INTERFACE)
+add_library(ot-config-mtd INTERFACE)
+add_library(ot-config-radio INTERFACE)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 99)
@@ -103,13 +107,15 @@ endif()
message(STATUS "Package Version: ${OT_PACKAGE_VERSION}")
set(OT_THREAD_VERSION "1.3" CACHE STRING "Thread version chosen by the user at configure time")
-set_property(CACHE OT_THREAD_VERSION PROPERTY STRINGS "1.1" "1.2" "1.3")
+set_property(CACHE OT_THREAD_VERSION PROPERTY STRINGS "1.1" "1.2" "1.3" "1.3.1")
if(${OT_THREAD_VERSION} EQUAL "1.1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_1")
elseif(${OT_THREAD_VERSION} EQUAL "1.2")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_2")
elseif(${OT_THREAD_VERSION} EQUAL "1.3")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_3")
+elseif(${OT_THREAD_VERSION} EQUAL "1.3.1")
+ target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_3_1")
else()
message(FATAL_ERROR "Thread version unknown: ${OT_THREAD_VERSION}")
endif()
@@ -169,6 +175,7 @@ list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_SOURCE_DIR}/include)
if(OT_PLATFORM STREQUAL "posix")
target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/src/posix/platform)
+ target_compile_definitions(ot-config INTERFACE OPENTHREAD_PLATFORM_POSIX=1)
add_subdirectory("${PROJECT_SOURCE_DIR}/src/posix/platform")
elseif(OT_PLATFORM STREQUAL "external")
# skip in this case
@@ -201,11 +208,8 @@ endif()
add_subdirectory(src)
add_subdirectory(third_party EXCLUDE_FROM_ALL)
-if(OT_PLATFORM STREQUAL "simulation")
- enable_testing()
-endif()
-
add_subdirectory(tests)
+add_subdirectory(tools)
add_custom_target(print-ot-config ALL
COMMAND ${CMAKE_COMMAND}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 2e99d4d4596..ae564f22725 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -109,7 +109,7 @@ This will open up a text editor where you can specify which commits to squash.
#### Coding Conventions and Style
-OpenThread uses and enforces the [OpenThread Coding Conventions and Style](STYLE_GUIDE.md) on all code, except for code located in [third_party](third_party). Use `script/make-pretty` and `script/make-pretty check` to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v9.0.0](https://releases.llvm.org/download.html#9.0.0) for C/C++ and [yapf v0.31.0](https://github.com/google/yapf) for Python.
+OpenThread uses and enforces the [OpenThread Coding Conventions and Style](STYLE_GUIDE.md) on all code, except for code located in [third_party](third_party). Use `script/make-pretty` and `script/make-pretty check` to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v14.0.0](https://releases.llvm.org/download.html#14.0.0) for C/C++ and [yapf v0.31.0](https://github.com/google/yapf) for Python.
As part of the cleanup process, you should also run `script/make-pretty check` to ensure that your code passes the baseline code style checks.
diff --git a/NOTICE b/NOTICE
index 94a2d719f96..04cdb0a7d7e 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,5 +1,5 @@
-OpenThread is an open source implementation of the Thread 1.2.0 Final Specification.
-The Thread 1.2.0 Final Specification is promulgated by the Thread Group. The Thread
+OpenThread is an open source implementation of the Thread 1.3.0 Final Specification.
+The Thread 1.3.0 Final Specification is promulgated by the Thread Group. The Thread
Group is a non-profit organization formed for the purposes of defining one or
more specifications, best practices, reference architectures, implementation
guidelines and certification programs to promote the availability of compliant
@@ -7,10 +7,10 @@ implementations of the Thread protocol. Information on becoming a Member, includ
information about the benefits thereof, can be found at http://threadgroup.org.
OpenThread is not affiliated with or endorsed by the Thread Group. Implementation
-of this OpenThread code does not assure compliance with the Thread 1.2.0 Final
+of this OpenThread code does not assure compliance with the Thread 1.3.0 Final
Specification and does not convey the right to identify any final product as Thread
certified. Members of the Thread Group may hold patents and other intellectual
-property rights relating to the Thread 1.2.0 Final Specification, ownership and
+property rights relating to the Thread 1.3.0 Final Specification, ownership and
licenses of which are subject to the Thread Group’s IP Policies, and not this license.
The included copyright to the OpenThread code is subject to the license in the
diff --git a/README.md b/README.md
index 65745884572..0c4a4f58aec 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[![OpenThread][ot-logo]][ot-repo] [![Build][ot-gh-action-build-svg]][ot-gh-action-build] [![Simulation][ot-gh-action-simulation-svg]][ot-gh-action-simulation] [![Docker][ot-gh-action-docker-svg]][ot-gh-action-docker] [![Language grade: C/C++][ot-lgtm-svg]][ot-lgtm] [![Coverage Status][ot-codecov-svg]][ot-codecov]
+[![OpenThread][ot-logo]][ot-repo] [![Build][ot-gh-action-build-svg]][ot-gh-action-build] [![Simulation][ot-gh-action-simulation-svg]][ot-gh-action-simulation] [![Docker][ot-gh-action-docker-svg]][ot-gh-action-docker] [![Coverage Status][ot-codecov-svg]][ot-codecov]
---
@@ -10,7 +10,7 @@ OpenThread released by Google is... 














+



















# Getting started
@@ -54,10 +52,6 @@ We would love for you to contribute to OpenThread and help make it even better t
Contributors are required to abide by our [Code of Conduct](https://github.com/openthread/openthread/blob/main/CODE_OF_CONDUCT.md) and [Coding Conventions and Style Guide](https://github.com/openthread/openthread/blob/main/STYLE_GUIDE.md).
-# Versioning
-
-OpenThread follows the [Semantic Versioning guidelines](http://semver.org/) for release cycle transparency and to maintain backwards compatibility. OpenThread's versioning is independent of the Thread protocol specification version but will clearly indicate which version of the specification it currently supports.
-
# License
OpenThread is released under the [BSD 3-Clause license](https://github.com/openthread/openthread/blob/main/LICENSE). See the [`LICENSE`](https://github.com/openthread/openthread/blob/main/LICENSE) file for more information.
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 00000000000..455cf9a4629
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1 @@
+To report a security issue, please use [https://g.co/vulnz](https://g.co/vulnz). We use g.co/vulnz for our intake, and do coordination and disclosure here on GitHub (including using GitHub Security Advisory). The Google Security Team will respond within 5 working days of your report on g.co/vulnz.
diff --git a/STYLE_GUIDE.md b/STYLE_GUIDE.md
index d8ea62496dd..c409c32bd52 100644
--- a/STYLE_GUIDE.md
+++ b/STYLE_GUIDE.md
@@ -116,7 +116,7 @@
- OpenThread uses `script/make-pretty` to reformat code and enforce code format and style. `script/make-pretty check` build target is included in OpenThread's continuous integration and must pass before a pull request is merged.
-- `script/make-pretty` requires [clang-format v9.0.0](https://releases.llvm.org/download.html#9.0.0) for C/C++ and [yapf v0.31.0](https://github.com/google/yapf) for Python.
+- `script/make-pretty` requires [clang-format v14.0.0](https://releases.llvm.org/download.html#14.0.0) for C/C++ and [yapf v0.31.0](https://github.com/google/yapf) for Python.
### File Names
diff --git a/configure.ac b/configure.ac
index 8c0c7fccacf..dedd85dda0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -804,14 +804,14 @@ AC_MSG_CHECKING([whether to build examples])
AC_ARG_WITH(examples,
[AS_HELP_STRING([--with-examples=TARGET],
- [Build example applications for one of: simulation, cc2538 @<:@default=no@:>@.
+ [Build example applications for one of: simulation @<:@default=no@:>@.
Note that building example applications also builds the associated OpenThread platform libraries
and any third_party libraries needed to support the examples.])],
[
case "${with_examples}" in
no)
;;
- simulation|cc2538)
+ simulation)
;;
*)
AC_MSG_RESULT(ERROR)
@@ -824,7 +824,6 @@ AC_ARG_WITH(examples,
AM_CONDITIONAL([OPENTHREAD_ENABLE_EXAMPLES], [test ${with_examples} != "no"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_SIMULATION],[test "${with_examples}" = "simulation"])
-AM_CONDITIONAL([OPENTHREAD_EXAMPLES_CC2538], [test "${with_examples}" = "cc2538"])
AM_COND_IF([OPENTHREAD_EXAMPLES_SIMULATION], CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_SIMULATION=1", CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_SIMULATION=0")
@@ -845,11 +844,11 @@ AC_MSG_CHECKING([whether to build platform libraries])
AC_ARG_WITH(platform,
[AS_HELP_STRING([--with-platform=TARGET],
- [Build OpenThread platform libraries for one of: cc2538, posix, simulation @<:@default=simulation@:>@.])],
+ [Build OpenThread platform libraries for one of: posix, simulation @<:@default=simulation@:>@.])],
[
# Make sure the given target is valid.
case "${with_platform}" in
- no|cc2538|posix|simulation)
+ no|posix|simulation)
;;
*)
AC_MSG_RESULT(ERROR)
@@ -880,7 +879,6 @@ AM_CONDITIONAL([OPENTHREAD_ENABLE_PLATFORM], [test ${with_platform} != "no"])
OPENTHREAD_ENABLE_PLATFORM=${with_platform}
-AM_CONDITIONAL([OPENTHREAD_PLATFORM_CC2538], [test "${with_platform}" = "cc2538"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_POSIX], [test "${with_platform}" = "posix"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_SIMULATION],[test "${with_platform}" = "simulation"])
@@ -1023,7 +1021,6 @@ examples/apps/Makefile
examples/apps/cli/Makefile
examples/apps/ncp/Makefile
examples/platforms/Makefile
-examples/platforms/cc2538/Makefile
examples/platforms/simulation/Makefile
examples/platforms/utils/Makefile
tools/Makefile
@@ -1032,9 +1029,6 @@ tools/harness-thci/Makefile
tools/spi-hdlc-adapter/Makefile
tests/Makefile
tests/fuzz/Makefile
-tests/scripts/Makefile
-tests/scripts/thread-cert/Makefile
-tests/unit/Makefile
doc/Makefile
])
diff --git a/doc/images/ot-contrib-amazon.png b/doc/images/ot-contrib-amazon.png
new file mode 100644
index 00000000000..ac236ee757b
Binary files /dev/null and b/doc/images/ot-contrib-amazon.png differ
diff --git a/doc/images/ot-contrib-eero.png b/doc/images/ot-contrib-eero.png
new file mode 100644
index 00000000000..317f20c0bc4
Binary files /dev/null and b/doc/images/ot-contrib-eero.png differ
diff --git a/doc/images/ot-contrib-mmb-networks.png b/doc/images/ot-contrib-mmb-networks.png
new file mode 100644
index 00000000000..e0f7dd5d4cb
Binary files /dev/null and b/doc/images/ot-contrib-mmb-networks.png differ
diff --git a/doc/images/ot-contrib-nabu-casa.png b/doc/images/ot-contrib-nabu-casa.png
new file mode 100644
index 00000000000..f3b637beb3b
Binary files /dev/null and b/doc/images/ot-contrib-nabu-casa.png differ
diff --git a/doc/images/ot-contrib-nanoleaf.png b/doc/images/ot-contrib-nanoleaf.png
new file mode 100644
index 00000000000..ca18d20aaa1
Binary files /dev/null and b/doc/images/ot-contrib-nanoleaf.png differ
diff --git a/doc/images/ot-contrib-qorvo.png b/doc/images/ot-contrib-qorvo.png
index f6815fc809f..5a9fc4854ca 100644
Binary files a/doc/images/ot-contrib-qorvo.png and b/doc/images/ot-contrib-qorvo.png differ
diff --git a/doc/ot_api_doc.h b/doc/ot_api_doc.h
index 3d58b682bbd..58e09a95412 100644
--- a/doc/ot_api_doc.h
+++ b/doc/ot_api_doc.h
@@ -53,7 +53,7 @@
* @defgroup api-net IPv6 Networking
* @{
*
- * @defgroup api-dns DNSv6
+ * @defgroup api-dns DNS
* @defgroup api-dnssd-server DNS-SD Server
* @defgroup api-icmp6 ICMPv6
* @defgroup api-ip6 IPv6
@@ -109,6 +109,7 @@
* @brief This module includes functions for all Thread roles.
* @defgroup api-joiner Joiner
* @defgroup api-operational-dataset Operational Dataset
+ * @brief Includes functions for the Operational Dataset API.
* @defgroup api-thread-router Router/Leader
* @brief This module includes functions for Thread Routers and Leaders.
* @defgroup api-server Server
@@ -138,6 +139,7 @@
* @defgroup api-history-tracker History Tracker
* @defgroup api-jam-detection Jam Detection
* @defgroup api-logging Logging - Thread Stack
+ * @defgroup api-mesh-diag Mesh Diagnostics
* @defgroup api-ncp Network Co-Processor
* @defgroup api-network-time Network Time Synchronization
* @defgroup api-random-group Random Number Generator
@@ -166,6 +168,7 @@
*
* @defgroup plat-alarm Alarm
* @defgroup plat-crypto Crypto - Platform
+ * @defgroup plat-dns DNS - Platform
* @defgroup plat-entropy Entropy
* @defgroup plat-factory-diagnostics Factory Diagnostics - Platform
* @defgroup plat-logging Logging - Platform
diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake
index 521b7fa5ca9..6afef68f928 100644
--- a/etc/cmake/options.cmake
+++ b/etc/cmake/options.cmake
@@ -34,57 +34,194 @@ option(OT_FTD "enable FTD" ON)
option(OT_MTD "enable MTD" ON)
option(OT_RCP "enable RCP" ON)
-option(OT_ANYCAST_LOCATOR "enable anycast locator support")
-if(OT_ANYCAST_LOCATOR)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE=1")
-endif()
+option(OT_LINKER_MAP "generate .map files for example apps" ON)
+
+message(STATUS OT_APP_CLI=${OT_APP_CLI})
+message(STATUS OT_APP_NCP=${OT_APP_NCP})
+message(STATUS OT_APP_RCP=${OT_APP_RCP})
+message(STATUS OT_FTD=${OT_FTD})
+message(STATUS OT_MTD=${OT_MTD})
+message(STATUS OT_RCP=${OT_RCP})
+
+set(OT_CONFIG_VALUES
+ ""
+ "ON"
+ "OFF"
+)
+
+macro(ot_option name ot_config description)
+ # Declare an OT cmake config with `name` mapping to OPENTHREAD_CONFIG
+ # `ot_config`. Parameter `description` provides the help string for this
+ # OT cmake config. There is an optional last parameter which if provided
+ # determines the default value for the cmake config. If not provided
+ # empty string is used which will be treated as "not specified". In this
+ # case, the variable `name` would still be false but the related
+ # OPENTHREAD_CONFIG is not added in `ot-config`.
+
+ if (${ARGC} GREATER 3)
+ set(${name} ${ARGN} CACHE STRING "enable ${description}")
+ else()
+ set(${name} "" CACHE STRING "enable ${description}")
+ endif()
-option(OT_ASSERT "enable assert function OT_ASSERT()" ON)
-if(OT_ASSERT)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ASSERT_ENABLE=1")
-else()
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ASSERT_ENABLE=0")
-endif()
+ set_property(CACHE ${name} PROPERTY STRINGS ${OT_CONFIG_VALUES})
+
+ string(COMPARE EQUAL "${${name}}" "" is_empty)
+ if (is_empty)
+ message(STATUS "${name}=\"\"")
+ elseif (${name})
+ message(STATUS "${name}=ON --> ${ot_config}=1")
+ target_compile_definitions(ot-config INTERFACE "${ot_config}=1")
+ else()
+ message(STATUS "${name}=OFF --> ${ot_config}=0")
+ target_compile_definitions(ot-config INTERFACE "${ot_config}=0")
+ endif()
+endmacro()
+
+ot_option(OT_15_4 OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE "802.15.4 radio link")
+ot_option(OT_ANDROID_NDK OPENTHREAD_CONFIG_ANDROID_NDK_ENABLE "enable android NDK")
+ot_option(OT_ANYCAST_LOCATOR OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE "anycast locator")
+ot_option(OT_ASSERT OPENTHREAD_CONFIG_ASSERT_ENABLE "assert function OT_ASSERT()")
+ot_option(OT_BACKBONE_ROUTER OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE "backbone router functionality")
+ot_option(OT_BACKBONE_ROUTER_DUA_NDPROXYING OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE "BBR DUA ND Proxy")
+ot_option(OT_BACKBONE_ROUTER_MULTICAST_ROUTING OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE "BBR MR")
+ot_option(OT_BORDER_AGENT OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE "border agent")
+ot_option(OT_BORDER_AGENT_ID OPENTHREAD_CONFIG_BORDER_AGENT_ID_ENABLE "create and save border agent ID")
+ot_option(OT_BORDER_ROUTER OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE "border router")
+ot_option(OT_BORDER_ROUTING OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE "border routing")
+ot_option(OT_BORDER_ROUTING_COUNTERS OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE "border routing counters")
+ot_option(OT_CHANNEL_MANAGER OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE "channel manager")
+ot_option(OT_CHANNEL_MONITOR OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE "channel monitor")
+ot_option(OT_COAP OPENTHREAD_CONFIG_COAP_API_ENABLE "coap api")
+ot_option(OT_COAP_BLOCK OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE "coap block-wise transfer (RFC7959)")
+ot_option(OT_COAP_OBSERVE OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE "coap observe (RFC7641)")
+ot_option(OT_COAPS OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE "secure coap")
+ot_option(OT_COMMISSIONER OPENTHREAD_CONFIG_COMMISSIONER_ENABLE "commissioner")
+ot_option(OT_CSL_AUTO_SYNC OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE "data polling based on csl")
+ot_option(OT_CSL_DEBUG OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE "csl debug")
+ot_option(OT_CSL_RECEIVER OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE "csl receiver")
+ot_option(OT_DATASET_UPDATER OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE "dataset updater")
+ot_option(OT_DHCP6_CLIENT OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE "DHCP6 client")
+ot_option(OT_DHCP6_SERVER OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE "DHCP6 server")
+ot_option(OT_DIAGNOSTIC OPENTHREAD_CONFIG_DIAG_ENABLE "diagnostic")
+ot_option(OT_DNS_CLIENT OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE "DNS client")
+ot_option(OT_DNS_CLIENT_OVER_TCP OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE "Enable dns query over tcp")
+ot_option(OT_DNS_DSO OPENTHREAD_CONFIG_DNS_DSO_ENABLE "DNS Stateful Operations (DSO)")
+ot_option(OT_DNS_UPSTREAM_QUERY OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE "Allow sending DNS queries to upstream")
+ot_option(OT_DNSSD_SERVER OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE "DNS-SD server")
+ot_option(OT_DUA OPENTHREAD_CONFIG_DUA_ENABLE "Domain Unicast Address (DUA)")
+ot_option(OT_ECDSA OPENTHREAD_CONFIG_ECDSA_ENABLE "ECDSA")
+ot_option(OT_EXTERNAL_HEAP OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE "external heap")
+ot_option(OT_FIREWALL OPENTHREAD_POSIX_CONFIG_FIREWALL_ENABLE "firewall")
+ot_option(OT_HISTORY_TRACKER OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE "history tracker")
+ot_option(OT_IP6_FRAGM OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE "ipv6 fragmentation")
+ot_option(OT_JAM_DETECTION OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE "jam detection")
+ot_option(OT_JOINER OPENTHREAD_CONFIG_JOINER_ENABLE "joiner")
+ot_option(OT_LINK_METRICS_INITIATOR OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE "link metrics initiator")
+ot_option(OT_LINK_METRICS_SUBJECT OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE "link metrics subject")
+ot_option(OT_LINK_RAW OPENTHREAD_CONFIG_LINK_RAW_ENABLE "link raw service")
+ot_option(OT_LOG_LEVEL_DYNAMIC OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE "dynamic log level control")
+ot_option(OT_MAC_FILTER OPENTHREAD_CONFIG_MAC_FILTER_ENABLE "mac filter")
+ot_option(OT_MESH_DIAG OPENTHREAD_CONFIG_MESH_DIAG_ENABLE "mesh diag")
+ot_option(OT_MESSAGE_USE_HEAP OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE "heap allocator for message buffers")
+ot_option(OT_MLE_LONG_ROUTES OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE "MLE long routes extension (experimental)")
+ot_option(OT_MLR OPENTHREAD_CONFIG_MLR_ENABLE "Multicast Listener Registration (MLR)")
+ot_option(OT_MULTIPLE_INSTANCE OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE "multiple instances")
+ot_option(OT_NAT64_BORDER_ROUTING OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE "border routing NAT64")
+ot_option(OT_NAT64_TRANSLATOR OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE "NAT64 translator support")
+ot_option(OT_NEIGHBOR_DISCOVERY_AGENT OPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE "neighbor discovery agent")
+ot_option(OT_NETDATA_PUBLISHER OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE "Network Data publisher")
+ot_option(OT_NETDIAG_CLIENT OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE "Network Diagnostic client")
+ot_option(OT_OTNS OPENTHREAD_CONFIG_OTNS_ENABLE "OTNS")
+ot_option(OT_PING_SENDER OPENTHREAD_CONFIG_PING_SENDER_ENABLE "ping sender" ${OT_APP_CLI})
+ot_option(OT_PLATFORM_NETIF OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE "platform netif")
+ot_option(OT_PLATFORM_UDP OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE "platform UDP")
+ot_option(OT_REFERENCE_DEVICE OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE "test harness reference device")
+ot_option(OT_SERVICE OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE "Network Data service")
+ot_option(OT_SETTINGS_RAM OPENTHREAD_SETTINGS_RAM "volatile-only storage of settings")
+ot_option(OT_SLAAC OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE "SLAAC address")
+ot_option(OT_SNTP_CLIENT OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE "SNTP client")
+ot_option(OT_SRP_CLIENT OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE "SRP client")
+ot_option(OT_SRP_SERVER OPENTHREAD_CONFIG_SRP_SERVER_ENABLE "SRP server")
+ot_option(OT_TCP OPENTHREAD_CONFIG_TCP_ENABLE "TCP")
+ot_option(OT_TIME_SYNC OPENTHREAD_CONFIG_TIME_SYNC_ENABLE "time synchronization service")
+ot_option(OT_TREL OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE "TREL radio link for Thread over Infrastructure feature")
+ot_option(OT_TX_BEACON_PAYLOAD OPENTHREAD_CONFIG_MAC_OUTGOING_BEACON_PAYLOAD_ENABLE "tx beacon payload")
+ot_option(OT_UDP_FORWARD OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE "UDP forward")
+ot_option(OT_UPTIME OPENTHREAD_CONFIG_UPTIME_ENABLE "uptime")
-option(OT_BACKBONE_ROUTER "enable backbone router functionality")
-if(OT_BACKBONE_ROUTER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1")
- set(OT_BACKBONE_ROUTER_DUA_NDPROXYING ON CACHE BOOL "Enable DUA NDProxying by default")
- set(OT_BACKBONE_ROUTER_MULTICAST_ROUTING ON CACHE BOOL "Enable Multicast Routing by default")
-endif()
+option(OT_DOC "Build OpenThread documentation")
-option(OT_BACKBONE_ROUTER_DUA_NDPROXYING "enable Backbone Router DUA ND Proxying functionality" OFF)
-if(OT_BACKBONE_ROUTER_DUA_NDPROXYING)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE=1")
-else()
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE=0")
+option(OT_FULL_LOGS "enable full logs")
+if(OT_FULL_LOGS)
+ if(NOT OT_LOG_LEVEL)
+ message(STATUS "OT_FULL_LOGS=ON --> Setting LOG_LEVEL to DEBG")
+ target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG")
+ endif()
+ target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1")
endif()
-option(OT_BACKBONE_ROUTER_MULTICAST_ROUTING "enable Backbone Router Multicast Routing functionality" OFF)
-if(OT_BACKBONE_ROUTER_MULTICAST_ROUTING)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE=1")
+set(OT_VENDOR_NAME "" CACHE STRING "set the vendor name config")
+set_property(CACHE OT_VENDOR_NAME PROPERTY STRINGS ${OT_VENDOR_NAME_VALUES})
+string(COMPARE EQUAL "${OT_VENDOR_NAME}" "" is_empty)
+if (is_empty)
+ message(STATUS "OT_VENDOR_NAME=\"\"")
else()
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE=0")
+ message(STATUS "OT_VENDOR_NAME=\"${OT_VENDOR_NAME}\" --> OPENTHREAD_CONFIG_NET_DIAG_VENDOR_NAME=\"${OT_VENDOR_NAME}\"")
+ target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_NET_DIAG_VENDOR_NAME=\"${OT_VENDOR_NAME}\"")
endif()
-option(OT_BORDER_AGENT "enable border agent support")
-if(OT_BORDER_AGENT)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1")
+set(OT_VENDOR_MODEL "" CACHE STRING "set the vendor model config")
+set_property(CACHE OT_VENDOR_MODEL PROPERTY STRINGS ${OT_VENDOR_MODEL_VALUES})
+string(COMPARE EQUAL "${OT_VENDOR_MODEL}" "" is_empty)
+if (is_empty)
+ message(STATUS "OT_VENDOR_MODEL=\"\"")
+else()
+ message(STATUS "OT_VENDOR_MODEL=\"${OT_VENDOR_MODEL}\" --> OPENTHREAD_CONFIG_NET_DIAG_VENDOR_MODEL=\"${OT_VENDOR_MODEL}\"")
+ target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_NET_DIAG_VENDOR_MODEL=\"${OT_VENDOR_MODEL}\"")
endif()
-option(OT_BORDER_ROUTER "enable border router support")
-if(OT_BORDER_ROUTER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1")
+set(OT_VENDOR_SW_VERSION "" CACHE STRING "set the vendor sw version config")
+set_property(CACHE OT_VENDOR_SW_VERSION PROPERTY STRINGS ${OT_VENDOR_SW_VERSION_VALUES})
+string(COMPARE EQUAL "${OT_VENDOR_SW_VERSION}" "" is_empty)
+if (is_empty)
+ message(STATUS "OT_VENDOR_SW_VERSION=\"\"")
+else()
+ message(STATUS "OT_VENDOR_SW_VERSION=\"${OT_VENDOR_SW_VERSION}\" --> OPENTHREAD_CONFIG_NET_DIAG_VENDOR_SW_VERSION=\"${OT_VENDOR_SW_VERSION}\"")
+ target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_NET_DIAG_VENDOR_SW_VERSION=\"${OT_VENDOR_SW_VERSION}\"")
+endif()
+
+set(OT_POWER_SUPPLY "" CACHE STRING "set the device power supply config")
+set(OT_POWER_SUPPLY_VALUES
+ ""
+ "BATTERY"
+ "EXTERNAL"
+ "EXTERNAL_STABLE"
+ "EXTERNAL_UNSTABLE"
+)
+set_property(CACHE OT_POWER_SUPPLY PROPERTY STRINGS ${OT_POWER_SUPPLY_VALUES})
+string(COMPARE EQUAL "${OT_POWER_SUPPLY}" "" is_empty)
+if (is_empty)
+ message(STATUS "OT_POWER_SUPPLY=\"\"")
+else()
+ message(STATUS "OT_POWER_SUPPLY=${OT_POWER_SUPPLY} --> OPENTHREAD_CONFIG_DEVICE_POWER_SUPPLY=OT_POWER_SUPPLY_${OT_POWER_SUPPLY}")
+ target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DEVICE_POWER_SUPPLY=OT_POWER_SUPPLY_${OT_POWER_SUPPLY}")
endif()
-option(OT_BORDER_ROUTING "enable border routing support")
-if(OT_BORDER_ROUTING)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE=1")
+set(OT_MLE_MAX_CHILDREN "" CACHE STRING "set maximum number of children")
+if(OT_MLE_MAX_CHILDREN MATCHES "^[0-9]+$")
+ message(STATUS "OT_MLE_MAX_CHILDREN=${OT_MLE_MAX_CHILDREN}")
+ target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_MAX_CHILDREN=${OT_MLE_MAX_CHILDREN}")
+elseif(NOT OT_MLE_MAX_CHILDREN STREQUAL "")
+ message(FATAL_ERROR "Invalid maximum number of children: ${OT_MLE_MAX_CHILDREN}")
endif()
-option(OT_BORDER_ROUTING_NAT64 "enable border routing NAT64 support")
-if(OT_BORDER_ROUTING_NAT64)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE=1")
+set(OT_RCP_RESTORATION_MAX_COUNT "0" CACHE STRING "set max RCP restoration count")
+if(OT_RCP_RESTORATION_MAX_COUNT MATCHES "^[0-9]+$")
+ message(STATUS "OT_RCP_RESTORATION_MAX_COUNT=${OT_RCP_RESTORATION_MAX_COUNT}")
+ target_compile_definitions(ot-config INTERFACE "OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT=${OT_RCP_RESTORATION_MAX_COUNT}")
+else()
+ message(FATAL_ERROR "Invalid max RCP restoration count: ${OT_RCP_RESTORATION_MAX_COUNT}")
endif()
if(NOT OT_EXTERNAL_MBEDTLS)
@@ -102,307 +239,21 @@ else()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=0")
endif()
-option(OT_CHANNEL_MANAGER "enable channel manager support")
-if(OT_CHANNEL_MANAGER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1")
-endif()
-
-option(OT_CHANNEL_MONITOR "enable channel monitor support")
-if(OT_CHANNEL_MONITOR)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1")
-endif()
-
-option(OT_CHILD_SUPERVISION "enable child supervision support")
-if(OT_CHILD_SUPERVISION)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1")
-endif()
-
-option(OT_COAP "enable coap api support")
-if(OT_COAP)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_API_ENABLE=1")
-endif()
-
-option(OT_COAPS "enable secure coap api support")
-if(OT_COAPS)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1")
-endif()
-
-option(OT_COAP_BLOCK "enable coap block-wise transfer (RFC7959) api support")
-if(OT_COAP_BLOCK)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE=1")
-endif()
-
-option(OT_COAP_OBSERVE "enable coap observe (RFC7641) api support")
-if(OT_COAP_OBSERVE)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE=1")
-endif()
-
-option(OT_COMMISSIONER "enable commissioner support")
-if(OT_COMMISSIONER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1")
-endif()
-
-option(OT_CSL_RECEIVER "enable csl receiver")
-if(OT_CSL_RECEIVER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1")
-endif()
-
-option(OT_CSL_AUTO_SYNC "enable data polling based on csl config" ${OT_CSL_RECEIVER})
-if(OT_CSL_AUTO_SYNC)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE=1")
-else()
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_AUTO_SYNC_ENABLE=0")
-endif()
-
-option(OT_CSL_DEBUG "enable csl debug")
-if(OT_CSL_DEBUG)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE=1")
-endif()
-
-option(OT_DATASET_UPDATER "enable dataset updater support")
-if(OT_DATASET_UPDATER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE=1")
-endif()
-
-option(OT_DHCP6_CLIENT "enable DHCP6 client support")
-if(OT_DHCP6_CLIENT)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1")
-endif()
-
-option(OT_DHCP6_SERVER "enable DHCP6 server support")
-if(OT_DHCP6_SERVER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1")
-endif()
-
-option(OT_DIAGNOSTIC "enable diagnostic support")
-if(OT_DIAGNOSTIC)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DIAG_ENABLE=1")
-endif()
-
-option(OT_DNS_CLIENT "enable DNS client support")
-if(OT_DNS_CLIENT)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1")
-endif()
-
-option(OT_DNS_DSO "enable DNS Stateful Operations (DSO) support")
-if(OT_DNS_DSO)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNS_DSO_ENABLE=1")
-endif()
-
-option(OT_DNSSD_SERVER "enable DNS-SD server support")
-if(OT_DNSSD_SERVER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE=1")
-endif()
-
-option(OT_DOC "Build OpenThread documentation")
-
-option(OT_ECDSA "enable ECDSA support")
-if(OT_ECDSA)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ECDSA_ENABLE=1")
-endif()
-
-option(OT_SRP_CLIENT "enable SRP client support")
-if (OT_SRP_CLIENT)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE=1")
-endif()
-
-option(OT_DUA "enable Domain Unicast Address feature for Thread 1.2")
-if(OT_DUA)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DUA_ENABLE=1")
-endif()
-
-option(OT_MESSAGE_USE_HEAP "enable heap allocator for message buffers")
-if(OT_MESSAGE_USE_HEAP)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE=1")
-endif()
-
-option(OT_MLR "enable Multicast Listener Registration feature for Thread 1.2")
-if(OT_MLR)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLR_ENABLE=1")
-endif()
-
-option(OT_EXTERNAL_HEAP "enable external heap support")
-if(OT_EXTERNAL_HEAP)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1")
-endif()
-
-option(OT_HISTORY_TRACKER "enable history tracker support")
-if(OT_HISTORY_TRACKER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE=1")
-endif()
-
-option(OT_IP6_FRAGM "enable ipv6 fragmentation support")
-if(OT_IP6_FRAGM)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE=1")
-endif()
-
-option(OT_JAM_DETECTION "enable jam detection support")
-if(OT_JAM_DETECTION)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1")
-endif()
-
-option(OT_JOINER "enable joiner support")
-if(OT_JOINER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_JOINER_ENABLE=1")
-endif()
-
-option(OT_LEGACY "enable legacy network support")
-if(OT_LEGACY)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LEGACY_ENABLE=1")
-endif()
-
-option(OT_LINK_RAW "enable link raw service")
-if(OT_LINK_RAW)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LINK_RAW_ENABLE=1")
-endif()
-
-option(OT_LINK_METRICS_INITIATOR "enable link metrics initiator")
-if (OT_LINK_METRICS_INITIATOR)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE=1")
-endif()
-
-option(OT_LINK_METRICS_SUBJECT "enable link metrics subject")
-if (OT_LINK_METRICS_SUBJECT)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE=1")
-endif()
-
-option(OT_LOG_LEVEL_DYNAMIC "enable dynamic log level control")
-if(OT_LOG_LEVEL_DYNAMIC)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1")
-endif()
-
-option(OT_MAC_FILTER "enable mac filter support")
-if(OT_MAC_FILTER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1")
-endif()
-
-option(OT_MLE_LONG_ROUTES "enable MLE long routes extension (experimental, breaks Thread conformance)")
-if(OT_MLE_LONG_ROUTES)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE=1")
-endif()
-
-option(OT_MTD_NETDIAG "enable TMF network diagnostics on MTDs")
-if(OT_MTD_NETDIAG)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1")
-endif()
-
-option(OT_MULTIPLE_INSTANCE "enable multiple instances")
-if(OT_MULTIPLE_INSTANCE)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE=1")
-endif()
-
-option(OT_NEIGHBOR_DISCOVERY_AGENT "enable neighbor discovery agent support")
-if(OT_NEIGHBOR_DISCOVERY_AGENT)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE=1")
-endif()
-
-option(OT_NETDATA_PUBLISHER "enable Thread Network Data publisher")
-if(OT_NETDATA_PUBLISHER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE=1")
-endif()
-
-option(OT_PING_SENDER "enable ping sender support" ${OT_APP_CLI})
-if(OT_PING_SENDER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PING_SENDER_ENABLE=1")
-endif()
-
-option(OT_PLATFORM_NETIF "enable platform netif support")
-if(OT_PLATFORM_NETIF)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE=1")
-endif()
-
-option(OT_PLATFORM_UDP "enable platform UDP support")
-if(OT_PLATFORM_UDP)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1")
-endif()
-
if(OT_POSIX_SETTINGS_PATH)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_POSIX_SETTINGS_PATH=${OT_POSIX_SETTINGS_PATH}")
endif()
-option(OT_REFERENCE_DEVICE "enable Thread Test Harness reference device support")
-if(OT_REFERENCE_DEVICE)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=1")
-endif()
-
-option(OT_SERVICE "enable support for injecting Service entries into the Thread Network Data")
-if(OT_SERVICE)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1")
-endif()
-
-option(OT_SETTINGS_RAM "enable volatile-only storage of settings")
-if(OT_SETTINGS_RAM)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_SETTINGS_RAM=1")
-endif()
-
-option(OT_SLAAC "enable support for adding of auto-configured SLAAC addresses by OpenThread")
-if(OT_SLAAC)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1")
-endif()
-
-option(OT_SNTP_CLIENT "enable SNTP Client support")
-if(OT_SNTP_CLIENT)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1")
-endif()
-
-option(OT_SRP_SERVER "enable SRP server")
-if (OT_SRP_SERVER)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SRP_SERVER_ENABLE=1")
-endif()
-
-option(OT_TIME_SYNC "enable the time synchronization service feature")
-if(OT_TIME_SYNC)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1")
-endif()
+#-----------------------------------------------------------------------------------------------------------------------
+# Check removed/replaced options
-option(OT_TREL "enable TREL radio link for Thread over Infrastructure feature")
-if (OT_TREL)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1")
-endif()
-
-option(OT_TX_BEACON_PAYLOAD "enable Thread beacon payload in outgoing beacons")
-if (OT_TX_BEACON_PAYLOAD)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_OUTGOING_BEACON_PAYLOAD_ENABLE=1")
-endif()
-
-option(OT_UDP_FORWARD "enable UDP forward support")
-if(OT_UDP_FORWARD)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1")
-endif()
-
-option(OT_UPTIME "enable support for tracking OpenThread instance's uptime")
-if(OT_UPTIME)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_UPTIME_ENABLE=1")
-endif()
-
-option(OT_FIREWALL "enable firewall")
-if (OT_FIREWALL)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_POSIX_CONFIG_FIREWALL_ENABLE=1")
-endif()
-
-option(OT_FULL_LOGS "enable full logs")
-if(OT_FULL_LOGS)
- if(NOT OT_LOG_LEVEL)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG")
+macro(ot_removed_option name error)
+ # This macro checks for a remove option and emits an error
+ # if the option is set.
+ get_property(is_set CACHE ${name} PROPERTY VALUE SET)
+ if (is_set)
+ message(FATAL_ERROR "Removed option ${name} is set - ${error}")
endif()
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1")
-endif()
-
-option(OT_OTNS "enable OTNS support")
-if(OT_OTNS)
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_OTNS_ENABLE=1")
-endif()
+endmacro()
-set(OT_RCP_RESTORATION_MAX_COUNT "0" CACHE STRING "set max RCP restoration count")
-if(OT_RCP_RESTORATION_MAX_COUNT MATCHES "^[0-9]+$")
- target_compile_definitions(ot-config INTERFACE "OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT=${OT_RCP_RESTORATION_MAX_COUNT}")
-else()
- message(FATAL_ERROR "Invalid max RCP restoration count: ${OT_RCP_RESTORATION_MAX_COUNT}")
-endif()
-
-option(OT_EXCLUDE_TCPLP_LIB "exclude TCPlp library from build")
-
-# Checks
-if(OT_PLATFORM_UDP AND OT_UDP_FORWARD)
- message(FATAL_ERROR "OT_PLATFORM_UDP and OT_UDP_FORWARD are exclusive")
-endif()
+ot_removed_option(OT_MTD_NETDIAG "- Use OT_NETDIAG_CLIENT instead - note that server function is always supported")
+ot_removed_option(OT_EXCLUDE_TCPLP_LIB "- Use OT_TCP instead, OT_EXCLUDE_TCPLP_LIB is deprecated")
diff --git a/etc/docker/environment/Dockerfile b/etc/docker/environment/Dockerfile
index 3c297de3620..a7c38f86904 100644
--- a/etc/docker/environment/Dockerfile
+++ b/etc/docker/environment/Dockerfile
@@ -1,5 +1,5 @@
# Ubuntu image with tools required to build OpenThread
-FROM ubuntu:18.04
+FROM ubuntu:22.04
ENV DEBIAN_FRONTEND noninteractive
ENV LANG en_US.UTF-8
@@ -9,6 +9,7 @@ RUN set -x \
&& apt-get install -y locales \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
&& apt-get --no-install-recommends install -fy \
+ bzip2 \
git \
ninja-build \
python3 \
@@ -20,6 +21,7 @@ RUN set -x \
inetutils-ping \
ca-certificates \
&& update-ca-certificates \
+ && python3 -m pip install -U pip \
&& python3 -m pip install -U cmake \
&& python3 -m pip install wheel
diff --git a/etc/gn/openthread.gni b/etc/gn/openthread.gni
index fe494b08ea6..9bbb543d257 100644
--- a/etc/gn/openthread.gni
+++ b/etc/gn/openthread.gni
@@ -84,6 +84,9 @@ if (openthread_enable_core_config_args) {
# Enable border agent support
openthread_config_border_agent_enable = false
+ # Enable border agent ID
+ openthread_config_border_agent_id_enable = false
+
# Enable border router support
openthread_config_border_router_enable = false
@@ -174,8 +177,8 @@ if (openthread_enable_core_config_args) {
# Enable MLE long routes extension (experimental, breaks Thread conformance]
openthread_config_mle_long_routes_enable = false
- # Enable TMF network diagnostics on MTDs
- openthread_config_tmf_network_diag_mtd_enable = false
+ # Enable TMF network diagnostics client
+ openthread_config_tmf_netdiag_client_enable = false
# Enable multiple instances
openthread_config_multiple_instance_enable = false
diff --git a/examples/Makefile-cc2538 b/examples/Makefile-cc2538
deleted file mode 100644
index 99d895a53a6..00000000000
--- a/examples/Makefile-cc2538
+++ /dev/null
@@ -1,309 +0,0 @@
-#
-# Copyright (c) 2016, The OpenThread Authors.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. Neither the name of the copyright holder nor the
-# names of its contributors may be used to endorse or promote products
-# derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-
-.NOTPARALLEL:
-
-AR = arm-none-eabi-ar
-CCAS = arm-none-eabi-as
-CPP = arm-none-eabi-cpp
-CC = arm-none-eabi-gcc
-CXX = arm-none-eabi-g++
-LD = arm-none-eabi-ld
-STRIP = arm-none-eabi-strip
-NM = arm-none-eabi-nm
-RANLIB = arm-none-eabi-ranlib
-OBJCOPY = arm-none-eabi-objcopy
-
-BuildJobs ?= 10
-
-configure_OPTIONS = \
- --enable-cli \
- --enable-ftd \
- --enable-mtd \
- --enable-ncp \
- --enable-radio-only \
- --enable-linker-map \
- --with-examples=cc2538 \
- $(NULL)
-
-TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
-AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
-
-CC2538_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-cc2538-config.h\"'
-CC2538_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-cc2538-config-check.h\"'
-CC2538_CONFIG_FILE_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/cc2538/
-
-COMMONCFLAGS := \
- -fdata-sections \
- -ffunction-sections \
- -Os \
- -g \
- $(CC2538_CONFIG_FILE_CPPFLAGS) \
- $(NULL)
-
-include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
-
-# Optional CC2592 options, first and foremost, whether to enable support for it
-# at all.
-ifeq ($(CC2592),1)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2538_WITH_CC2592=1
-
-# If the PA_EN is on another port C pin, specify it with CC2592_PA_PIN.
-ifneq ($(CC2592_PA_EN),)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_PA_EN_PIN=$(CC2592_PA_EN)
-endif
-
-# If the LNA_EN is on another port C pin, specify it with CC2592_LNA_PIN.
-ifneq ($(CC2592_LNA_EN),)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_LNA_EN_PIN=$(CC2592_LNA_EN)
-endif
-
-# If we're not using HGM, set CC2538_USE_HGM to 0.
-ifeq ($(CC2592_USE_HGM),0)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_USE_HGM=0
-else # CC2592_USE_HGM=1
-
-# HGM in use, if not on port D, specify the port here (A, B or C) with CC2592_HGM_PORT.
-ifneq ($(CC2592_HGM_PORT),)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_HGM_PORT=GPIO_$(CC2592_HGM_PORT)_BASE
-endif
-
-# If HGM is not at pin 2, specify which pin here with CC2592_HGM_PIN.
-ifneq ($(CC2592_HGM_PIN),)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_HGM_PIN=$(CC2592_HGM_PIN)
-endif
-
-# If we want it off by default, specify CC2592_HGM_DEFAULT_STATE=0
-ifeq ($(CC2592_HGM_DEFAULT_STATE),0)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2592_HGM_DEFAULT_STATE=false
-endif
-
-endif # CC2592_USE_HGM
-
-endif # CC2592
-
-ifneq ($(CC2538_RECEIVE_SENSITIVITY),)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2538_RECEIVE_SENSITIVITY=$(CC2538_RECEIVE_SENSITIVITY)
-endif
-
-ifneq ($(CC2538_RSSI_OFFSET),)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_CC2538_RSSI_OFFSET=$(CC2538_RSSI_OFFSET)
-endif
-
-CPPFLAGS += \
- $(COMMONCFLAGS) \
- $(target_CPPFLAGS) \
- $(NULL)
-
-CFLAGS += \
- $(COMMONCFLAGS) \
- $(target_CFLAGS) \
- $(NULL)
-
-CXXFLAGS += \
- $(COMMONCFLAGS) \
- $(target_CXXFLAGS) \
- -fno-exceptions \
- -fno-rtti \
- $(NULL)
-
-LDFLAGS += \
- $(COMMONCFLAGS) \
- $(target_LDFLAGS) \
- -nostartfiles \
- -specs=nano.specs \
- -specs=nosys.specs \
- -Wl,--gc-sections \
- $(NULL)
-
-ECHO := @echo
-MAKE := make
-MKDIR_P := mkdir -p
-LN_S := ln -s
-RM_F := rm -f
-
-INSTALL := /usr/bin/install
-INSTALLFLAGS := -p
-
-BuildPath = build
-TopBuildDir = $(BuildPath)
-AbsTopBuildDir = $(PWD)/$(TopBuildDir)
-
-ResultPath = output
-TopResultDir = $(ResultPath)
-AbsTopResultDir = $(PWD)/$(TopResultDir)
-
-TargetTuple = cc2538
-
-ARCHS = cortex-m3
-
-TopTargetLibDir = $(TopResultDir)/$(TargetTuple)/lib
-
-ifndef BuildJobs
-BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
-endif
-JOBSFLAG := -j$(BuildJobs)
-
-#
-# configure-arch
-#
-# Configure OpenThread for the specified architecture.
-#
-# arch - The architecture to configure.
-#
-define configure-arch
-$(ECHO) " CONFIG $(TargetTuple)..."
-(cd $(BuildPath)/$(TargetTuple) && $(AbsTopSourceDir)/configure \
-INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
-CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \
---host=arm-none-eabi \
---prefix=/ \
---exec-prefix=/$(TargetTuple) \
-$(configure_OPTIONS))
-endef # configure-arch
-
-#
-# build-arch
-#
-# Build the OpenThread intermediate build products for the specified
-# architecture.
-#
-# arch - The architecture to build.
-#
-define build-arch
-$(ECHO) " BUILD $(TargetTuple)"
-$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
-all
-endef # build-arch
-
-#
-# stage-arch
-#
-# Stage (install) the OpenThread final build products for the specified
-# architecture.
-#
-# arch - The architecture to stage.
-#
-define stage-arch
-$(ECHO) " STAGE $(TargetTuple)"
-$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
-DESTDIR=$(AbsTopResultDir) \
-install
-endef # stage-arch
-
-#
-# ARCH_template
-#
-# Define macros, targets and rules to configure, build, and stage the
-# OpenThread for a single architecture.
-#
-# arch - The architecture to instantiate the template for.
-#
-define ARCH_template
-CONFIGURE_TARGETS += configure-$(1)
-BUILD_TARGETS += do-build-$(1)
-STAGE_TARGETS += stage-$(1)
-BUILD_DIRS += $(BuildPath)/$(TargetTuple)
-DIRECTORIES += $(BuildPath)/$(TargetTuple)
-
-configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
-configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
-configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
-configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)
-
-configure-$(1): $(BuildPath)/$(TargetTuple)/config.status
-
-$(BuildPath)/$(TargetTuple)/config.status: | $(BuildPath)/$(TargetTuple)
- $$(call configure-arch,$(1))
-
-do-build-$(1): configure-$(1)
-
-do-build-$(1):
- +$$(call build-arch,$(1))
-
-stage-$(1): do-build-$(1)
-
-stage-$(1): | $(TopResultDir)
- $$(call stage-arch,$(1))
-
-$(1): stage-$(1)
-endef # ARCH_template
-
-.DEFAULT_GOAL := all
-
-all: stage
-
-#
-# cortex-m3
-#
-
-cortex-m3_target_ABI = cortex-m3
-cortex-m3_target_CPPFLAGS = -mcpu=cortex-m3 -mfloat-abi=soft -mthumb
-cortex-m3_target_CFLAGS = -mcpu=cortex-m3 -mfloat-abi=soft -mthumb
-cortex-m3_target_CXXFLAGS = -mcpu=cortex-m3 -mfloat-abi=soft -mthumb
-cortex-m3_target_LDFLAGS = -mcpu=cortex-m3 -mfloat-abi=soft -mthumb
-
-# Instantiate an architecture-specific build template for each target
-# architecture.
-
-$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))
-
-#
-# Common / Finalization
-#
-
-configure: $(CONFIGURE_TARGETS)
-
-build: $(BUILD_TARGETS)
-
-stage: $(STAGE_TARGETS)
-
-DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
-
-CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
-
-all: stage
-
-$(DIRECTORIES):
- $(ECHO) " MKDIR $@"
- @$(MKDIR_P) "$@"
-
-clean:
- $(ECHO) " CLEAN"
- @$(RM_F) -r $(CLEAN_DIRS)
-
-help:
- $(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
- $(ECHO) "architectures: "
- $(ECHO) ""
- $(ECHO) " $(ARCHS)"
- $(ECHO) ""
- $(ECHO) "To build only a particular architecture, specify: "
- $(ECHO) ""
- $(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) "
- $(ECHO) ""
diff --git a/examples/Makefile-simulation b/examples/Makefile-simulation
index f16ce89736f..72894fb4703 100644
--- a/examples/Makefile-simulation
+++ b/examples/Makefile-simulation
@@ -45,7 +45,6 @@ COAPS ?= 1
COMMISSIONER ?= 1
CHANNEL_MANAGER ?= 1
CHANNEL_MONITOR ?= 1
-CHILD_SUPERVISION ?= 1
DATASET_UPDATER ?= 1
DHCP6_CLIENT ?= 1
DHCP6_SERVER ?= 1
@@ -58,12 +57,11 @@ HISTORY_TRACKER ?= 1
IP6_FRAGM ?= 1
JAM_DETECTION ?= 1
JOINER ?= 1
-LEGACY ?= 1
LINK_RAW ?= 1
MAC_FILTER ?= 1
-MTD_NETDIAG ?= 1
NEIGHBOR_DISCOVERY_AGENT ?= 1
NETDATA_PUBLISHER ?= 1
+NETDIAG_CLIENT ?= 1
PING_SENDER ?= 1
REFERENCE_DEVICE ?= 1
SERVICE ?= 1
diff --git a/examples/README.md b/examples/README.md
index 2d0f5d5efdf..a7d1acd4f90 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -6,17 +6,16 @@ This page lists the available common switches with description. Unless stated ot
| Makefile switch | CMake switch | Description |
| --- | --- | --- |
+| | OT_15_4 | Enables 802.15.4 radio link. |
| ANYCAST_LOCATOR | OT_ANYCAST_LOCATOR | Enables anycast locator functionality. |
| BACKBONE_ROUTER | OT_BACKBONE_ROUTER | Enables Backbone Router functionality for Thread 1.2. |
| BIG_ENDIAN | OT_BIG_ENDIAN | Allows the host platform to use big-endian byte order. |
| BORDER_AGENT | OT_BORDER_AGENT | Enables support for border agent. In most cases, enable this switch if you are building On-mesh Commissioner or Border Router with External Commissioning support. |
| BORDER_ROUTER | OT_BORDER_ROUTER | Enables support for Border Router. This switch is usually combined with the BORDER_AGENT and UDP_FORWARD (or PLATFORM_UDP in case of RCP design) switches to build Border Router device. |
| BORDER_ROUTING | OT_BORDER_ROUTING | Enables bi-directional border routing between Thread and Infrastructure networks for Border Router. |
-| BORDER_ROUTING_NAT64 | OT_BORDER_ROUTING_NAT64 | Enables NAT64 border routing support for Border Router. |
| BUILTIN_MBEDTLS_MANAGEMENT | OT_BUILTIN_MBEDTLS_MANAGEMENT | Enables the built-in mbedTLS management. Enable this switch if the external mbedTLS is used, but mbedTLS memory allocation and debug config should be managed internally by OpenThread. |
| CHANNEL_MANAGER | OT_CHANNEL_MANAGER | Enables support for channel manager. Enable this switch on devices that are supposed to request a Thread network channel change. This switch should be used only with an FTD build. |
| CHANNEL_MONITOR | OT_CHANNEL_MONITOR | Enables support for channel monitor. Enable this switch on devices that are supposed to determine the cleaner channels. |
-| CHILD_SUPERVISION | OT_CHILD_SUPERVISION | Enables support for [child supervision](https://openthread.io/guides/build/features/child-supervision). Enable this switch on a parent or child node with custom OpenThread application that manages the supervision, checks timeout intervals, and verifies connectivity between parent and child. |
| COAP | OT_COAP | Enables support for the CoAP API. Enable this switch if you want to control Constrained Application Protocol communication. |
| COAP_OBSERVE | OT_COAP_OBSERVE | Enables support for CoAP Observe (RFC7641) API. |
| COAPS | OT_COAPS | Enables support for the secure CoAP API. Enable this switch if you want to control Constrained Application Protocol Secure (CoAP over DTLS) communication. |
@@ -35,26 +34,27 @@ This page lists the available common switches with description. Unless stated ot
| DEBUG_UART_LOG | not implemented | Enables the log output for the debug UART. Requires OPENTHREAD_CONFIG_ENABLE_DEBUG_UART to be enabled. |
| DNS_CLIENT | OT_DNS_CLIENT | Enables support for DNS client. Enable this switch on a device that sends a DNS query for AAAA (IPv6) record. |
| DNS_DSO | OT_DNS_DSO | Enables support for DNS Stateful Operations (DSO). |
+| DNS_UPSTREAM_QUERY | OT_DNS_UPSTREAM_QUERY | Enables forwarding DNS queries to upstream DNS server. |
| DNSSD_SERVER | OT_DNSSD_SERVER | Enables support for DNS-SD server. DNS-SD server use service information from local SRP server to resolve DNS-SD query questions. |
| DUA | OT_DUA | Enables the Domain Unicast Address feature for Thread 1.2. |
| DYNAMIC_LOG_LEVEL | not implemented | Enables the dynamic log level feature. Enable this switch if OpenThread log level is required to be set at runtime. See [Logging guide](https://openthread.io/guides/build/logs) to learn more. |
| ECDSA | OT_ECDSA | Enables support for Elliptic Curve Digital Signature Algorithm. Enable this switch if ECDSA digital signature is used by application. |
-| EXCLUDE_TCPLP_LIB | OT_EXCLUDE_TCPLP_LIB | Exclude TCPlp library from the build. |
| EXTERNAL_HEAP | OT_EXTERNAL_HEAP | Enables support for external heap. Enable this switch if the platform uses its own heap. Make sure to specify the external heap Calloc and Free functions to be used by the OpenThread stack. |
| FULL_LOGS | OT_FULL_LOGS | Enables all log levels and regions. This switch sets the log level to OT_LOG_LEVEL_DEBG and turns on all region flags. See [Logging guide](https://openthread.io/guides/build/logs) to learn more. |
| HISTORY_TRACKER | OT_HISTORY_TRACKER | Enables support for History Tracker. |
| IP6_FRAGM | OT_IP6_FRAGM | Enables support for IPv6 fragmentation. |
| JAM_DETECTION | OT_JAM_DETECTION | Enables support for [Jam Detection](https://openthread.io/guides/build/features/jam-detection). Enable this switch if a device requires the ability to detect signal jamming on a specific channel. |
| JOINER | OT_JOINER | Enables [support for Joiner](https://openthread.io/reference/group/api-joiner). Enable this switch on a device that has to be commissioned to join the network. |
-| LEGACY | OT_LEGACY | Enables support for legacy network. |
| LINK_RAW | OT_LINK_RAW | Enables the Link Raw service. |
| LOG_OUTPUT | not implemented | Defines if the LOG output is to be created and where it goes. There are several options available: `NONE`, `DEBUG_UART`, `APP`, `PLATFORM_DEFINED` (default). See [Logging guide](https://openthread.io/guides/build/logs) to learn more. |
| MAC_FILTER | OT_MAC_FILTER | Enables support for the MAC filter. |
| MLE_LONG_ROUTES | OT_MLE_LONG_ROUTES | Enables the MLE long routes extension. **Note: Enabling this feature breaks conformance to the Thread Specification.** |
| MLR | OT_MLR | Enables Multicast Listener Registration feature for Thread 1.2. |
-| MTD_NETDIAG | OT_MTD_NETDIAG | Enables the TMF network diagnostics on MTDs. |
| MULTIPLE_INSTANCE | OT_MULTIPLE_INSTANCE | Enables multiple OpenThread instances. |
+| NAT64_BORDER_ROUTING | OT_NAT64_BORDER_ROUTING | Enables NAT64 border routing support for Border Router. |
+| NAT64_TRANSLATOR | OT_NAT64_TRANSLATOR | Enables NAT64 translator for Border Router. |
| NETDATA_PUBLISHER | OT_NETDATA_PUBLISHER | Enables support for Thread Network Data publisher. |
+| NETDIAG_CLIENT | OT_NETDIAG_CLIENT | Enables Network Diagnostics client functionality. |
| PING_SENDER | OT_PING_SENDER | Enables support for ping sender. |
| OTNS | OT_OTNS | Enables support for [OpenThread Network Simulator](https://github.com/openthread/ot-ns). Enable this switch if you are building OpenThread for OpenThread Network Simulator. |
| PLATFORM_UDP | OT_PLATFORM_UDP | Enables platform UDP support. |
@@ -66,8 +66,15 @@ This page lists the available common switches with description. Unless stated ot
| SPINEL_ENCRYPTER_LIBS | not implemented | Specifies library files (absolute paths) for implementing the NCP Spinel Encrypter. |
| SRP_CLIENT | OT_SRP_CLIENT | Enable support for SRP client. |
| SRP_SERVER | OT_SRP_SERVER | Enable support for SRP server. |
+| TCP | OT_TCP | Enable support for TCP (based on TCPlp). |
| THREAD_VERSION | OT_THREAD_VERSION | Enables the chosen Thread version (1.1 / 1.2 (default)). For example, set to `1.1` for Thread 1.1. |
-| TIME_SYNC | OT_TIME_SYNC | Enables the time synchronization service feature. **Note: Enabling this feature breaks conformance to the Thread Specification.** | |
+| TIME_SYNC | OT_TIME_SYNC | Enables the time synchronization service feature. **Note: Enabling this feature breaks conformance to the Thread Specification.** |
| TREL | OT_TREL | Enables TREL radio link for Thread over Infrastructure feature. |
-| UDP_FORWARD | OT_UDP_FORWARD | Enables support for UDP forward. | Enable this switch on the Border Router device (running on the NCP design) with External Commissioning support to service Thread Commissioner packets on the NCP side. |
+| UDP_FORWARD | OT_UDP_FORWARD | Enables support for UDP forward. Enable this switch on the Border Router device (running on the NCP design) with External Commissioning support to service Thread Commissioner packets on the NCP side. |
| UPTIME | OT_UPTIME | Enables support for tracking OpenThread instance's uptime. |
+
+Removed or replaced switches:
+
+| Makefile switch | CMake switch | Description |
+| --- | --- | --- |
+| MTD_NETDIAG | OT_MTD_NETDIAG | Use NEDIAG_CLIENT to enable client functionality. Server functionality is always supported. |
diff --git a/examples/apps/cli/cli_uart.cpp b/examples/apps/cli/cli_uart.cpp
index b7fa5028d1d..81f05f825ec 100644
--- a/examples/apps/cli/cli_uart.cpp
+++ b/examples/apps/cli/cli_uart.cpp
@@ -137,7 +137,7 @@ static void ReceiveTask(const uint8_t *aBuf, uint16_t aBufLength)
static const char sEraseString[] = {'\b', ' ', '\b'};
static const char CRNL[] = {'\r', '\n'};
static uint8_t sLastChar = '\0';
- const uint8_t * end;
+ const uint8_t *end;
end = aBuf + aBufLength;
@@ -368,15 +368,9 @@ static int CliUartOutput(void *aContext, const char *aFormat, va_list aArguments
return rval;
}
-void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength)
-{
- ReceiveTask(aBuf, aBufLength);
-}
+void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength) { ReceiveTask(aBuf, aBufLength); }
-void otPlatUartSendDone(void)
-{
- SendDoneTask();
-}
+void otPlatUartSendDone(void) { SendDoneTask(); }
extern "C" void otAppCliInit(otInstance *aInstance)
{
diff --git a/examples/apps/cli/ftd.cmake b/examples/apps/cli/ftd.cmake
index f5a2870f838..9ed9be18c3b 100644
--- a/examples/apps/cli/ftd.cmake
+++ b/examples/apps/cli/ftd.cmake
@@ -44,8 +44,17 @@ target_link_libraries(ot-cli-ftd PRIVATE
${OT_PLATFORM_LIB_FTD}
openthread-cli-ftd
${OT_MBEDTLS}
+ ot-config-ftd
ot-config
)
+if(OT_LINKER_MAP)
+ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
+ target_link_libraries(ot-cli-ftd PRIVATE -Wl,-map,ot-cli-ftd.map)
+ else()
+ target_link_libraries(ot-cli-ftd PRIVATE -Wl,-Map=ot-cli-ftd.map)
+ endif()
+endif()
+
install(TARGETS ot-cli-ftd
DESTINATION bin)
diff --git a/examples/apps/cli/main.c b/examples/apps/cli/main.c
index 165f32f9395..cc52d9ab7eb 100644
--- a/examples/apps/cli/main.c
+++ b/examples/apps/cli/main.c
@@ -50,24 +50,15 @@
extern void otAppCliInit(otInstance *aInstance);
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
-void *otPlatCAlloc(size_t aNum, size_t aSize)
-{
- return calloc(aNum, aSize);
-}
+OT_TOOL_WEAK void *otPlatCAlloc(size_t aNum, size_t aSize) { return calloc(aNum, aSize); }
-void otPlatFree(void *aPtr)
-{
- free(aPtr);
-}
+OT_TOOL_WEAK void otPlatFree(void *aPtr) { free(aPtr); }
#endif
-void otTaskletsSignalPending(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-}
+void otTaskletsSignalPending(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); }
#if OPENTHREAD_POSIX && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
-static void ProcessExit(void *aContext, uint8_t aArgsLength, char *aArgs[])
+static otError ProcessExit(void *aContext, uint8_t aArgsLength, char *aArgs[])
{
OT_UNUSED_VARIABLE(aContext);
OT_UNUSED_VARIABLE(aArgsLength);
@@ -75,8 +66,32 @@ static void ProcessExit(void *aContext, uint8_t aArgsLength, char *aArgs[])
exit(EXIT_SUCCESS);
}
-static const otCliCommand kCommands[] = {{"exit", ProcessExit}};
+
+#if OPENTHREAD_EXAMPLES_SIMULATION
+extern otError ProcessNodeIdFilter(void *aContext, uint8_t aArgsLength, char *aArgs[]);
+#endif
+
+static const otCliCommand kCommands[] = {
+ {"exit", ProcessExit},
+#if OPENTHREAD_EXAMPLES_SIMULATION
+ /*
+ * The CLI command `nodeidfilter` only works for simulation in real time.
+ *
+ * It can be used either as an allow list or a deny list. Once the filter is cleared, the first `nodeidfilter allow`
+ * or `nodeidfilter deny` will determine whether it is set up as an allow or deny list. Subsequent calls should
+ * use the same sub-command to add new node IDs, e.g., if we first call `nodeidfilter allow` (which sets the filter
+ * up as an allow list), a subsequent `nodeidfilter deny` will result in `InvalidState` error.
+ *
+ * The usage of the command `nodeidfilter`:
+ * - `nodeidfilter deny ` : It denies the connection to a specified node (use as deny-list).
+ * - `nodeidfilter allow : It allows the connection to a specified node (use as allow-list).
+ * - `nodeidfilter clear` : It restores the filter state to default.
+ * - `nodeidfilter` : Outputs filter mode (allow-list or deny-list) and filtered node IDs.
+ */
+ {"nodeidfilter", ProcessNodeIdFilter},
#endif
+};
+#endif // OPENTHREAD_POSIX && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
int main(int argc, char *argv[])
{
@@ -111,7 +126,7 @@ int main(int argc, char *argv[])
otAppCliInit(instance);
#if OPENTHREAD_POSIX && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
- otCliSetUserCommands(kCommands, OT_ARRAY_LENGTH(kCommands), instance);
+ IgnoreError(otCliSetUserCommands(kCommands, OT_ARRAY_LENGTH(kCommands), instance));
#endif
while (!otSysPseudoResetWasRequested())
diff --git a/examples/apps/cli/mtd.cmake b/examples/apps/cli/mtd.cmake
index 7b71883bb82..786f741610d 100644
--- a/examples/apps/cli/mtd.cmake
+++ b/examples/apps/cli/mtd.cmake
@@ -44,8 +44,17 @@ target_link_libraries(ot-cli-mtd PRIVATE
${OT_PLATFORM_LIB_MTD}
openthread-cli-mtd
${OT_MBEDTLS}
+ ot-config-mtd
ot-config
)
+if(OT_LINKER_MAP)
+ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
+ target_link_libraries(ot-cli-mtd PRIVATE -Wl,-map,ot-cli-mtd.map)
+ else()
+ target_link_libraries(ot-cli-mtd PRIVATE -Wl,-Map=ot-cli-mtd.map)
+ endif()
+endif()
+
install(TARGETS ot-cli-mtd
DESTINATION bin)
diff --git a/examples/apps/cli/radio.cmake b/examples/apps/cli/radio.cmake
index 4302adca547..b2fe5d96861 100644
--- a/examples/apps/cli/radio.cmake
+++ b/examples/apps/cli/radio.cmake
@@ -48,9 +48,18 @@ target_link_libraries(ot-cli-radio PRIVATE
${OT_PLATFORM_LIB_RCP}
openthread-cli-radio
${OT_MBEDTLS_RCP}
+ ot-config-radio
ot-config
)
+if(OT_LINKER_MAP)
+ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
+ target_link_libraries(ot-cli-radio PRIVATE -Wl,-map,ot-cli-radio.map)
+ else()
+ target_link_libraries(ot-cli-radio PRIVATE -Wl,-Map=ot-cli-radio.map)
+ endif()
+endif()
+
install(TARGETS ot-cli-radio
DESTINATION bin
)
diff --git a/examples/apps/ncp/ftd.cmake b/examples/apps/ncp/ftd.cmake
index c7d0bbf5d1a..a7ffa51ad54 100644
--- a/examples/apps/ncp/ftd.cmake
+++ b/examples/apps/ncp/ftd.cmake
@@ -44,7 +44,16 @@ target_link_libraries(ot-ncp-ftd PRIVATE
${OT_PLATFORM_LIB_FTD}
openthread-ncp-ftd
${OT_MBEDTLS}
+ ot-config-ftd
ot-config
)
+if(OT_LINKER_MAP)
+ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
+ target_link_libraries(ot-ncp-ftd PRIVATE -Wl,-map,ot-ncp-ftd.map)
+ else()
+ target_link_libraries(ot-ncp-ftd PRIVATE -Wl,-Map=ot-ncp-ftd.map)
+ endif()
+endif()
+
install(TARGETS ot-ncp-ftd DESTINATION bin)
diff --git a/examples/apps/ncp/main.c b/examples/apps/ncp/main.c
index af50d145d0c..9c21c57bb90 100644
--- a/examples/apps/ncp/main.c
+++ b/examples/apps/ncp/main.c
@@ -46,21 +46,12 @@
extern void otAppNcpInit(otInstance *aInstance);
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
-void *otPlatCAlloc(size_t aNum, size_t aSize)
-{
- return calloc(aNum, aSize);
-}
+OT_TOOL_WEAK void *otPlatCAlloc(size_t aNum, size_t aSize) { return calloc(aNum, aSize); }
-void otPlatFree(void *aPtr)
-{
- free(aPtr);
-}
+OT_TOOL_WEAK void otPlatFree(void *aPtr) { free(aPtr); }
#endif
-void otTaskletsSignalPending(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-}
+void otTaskletsSignalPending(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); }
int main(int argc, char *argv[])
{
diff --git a/examples/apps/ncp/mtd.cmake b/examples/apps/ncp/mtd.cmake
index 61380c3b55c..2fecbacc0bc 100644
--- a/examples/apps/ncp/mtd.cmake
+++ b/examples/apps/ncp/mtd.cmake
@@ -44,7 +44,16 @@ target_link_libraries(ot-ncp-mtd PRIVATE
${OT_PLATFORM_LIB_MTD}
openthread-ncp-mtd
${OT_MBEDTLS}
+ ot-config-mtd
ot-config
)
+if(OT_LINKER_MAP)
+ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
+ target_link_libraries(ot-ncp-mtd PRIVATE -Wl,-map,ot-ncp-mtd.map)
+ else()
+ target_link_libraries(ot-ncp-mtd PRIVATE -Wl,-Map=ot-ncp-mtd.map)
+ endif()
+endif()
+
install(TARGETS ot-ncp-mtd DESTINATION bin)
diff --git a/examples/apps/ncp/ncp.c b/examples/apps/ncp/ncp.c
index ee7ccf7d175..df6529a3aca 100644
--- a/examples/apps/ncp/ncp.c
+++ b/examples/apps/ncp/ncp.c
@@ -37,15 +37,9 @@
#if !OPENTHREAD_CONFIG_NCP_SPI_ENABLE
#include "utils/uart.h"
-void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength)
-{
- otNcpHdlcReceive(aBuf, aBufLength);
-}
+void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength) { otNcpHdlcReceive(aBuf, aBufLength); }
-void otPlatUartSendDone(void)
-{
- otNcpHdlcSendDone();
-}
+void otPlatUartSendDone(void) { otNcpHdlcSendDone(); }
#endif
#if !OPENTHREAD_ENABLE_NCP_VENDOR_HOOK
diff --git a/examples/apps/ncp/rcp.cmake b/examples/apps/ncp/rcp.cmake
index 7ba3b97253f..0f8be335ab2 100644
--- a/examples/apps/ncp/rcp.cmake
+++ b/examples/apps/ncp/rcp.cmake
@@ -43,7 +43,16 @@ target_link_libraries(ot-rcp PRIVATE
openthread-radio
${OT_PLATFORM_LIB_RCP}
openthread-rcp
+ ot-config-radio
ot-config
)
+if(OT_LINKER_MAP)
+ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang")
+ target_link_libraries(ot-rcp PRIVATE -Wl,-map,ot-rcp.map)
+ else()
+ target_link_libraries(ot-rcp PRIVATE -Wl,-Map=ot-rcp.map)
+ endif()
+endif()
+
install(TARGETS ot-rcp DESTINATION bin)
diff --git a/examples/common-switches.mk b/examples/common-switches.mk
index ac05ccd6cdf..36ff95726db 100644
--- a/examples/common-switches.mk
+++ b/examples/common-switches.mk
@@ -34,7 +34,6 @@ BIG_ENDIAN ?= 0
BORDER_AGENT ?= 0
BORDER_ROUTER ?= 0
BORDER_ROUTING ?= 0
-BORDER_ROUTING_NAT64 ?= 0
COAP ?= 0
COAP_BLOCK ?= 0
COAP_OBSERVE ?= 0
@@ -43,7 +42,6 @@ COMMISSIONER ?= 0
COVERAGE ?= 0
CHANNEL_MANAGER ?= 0
CHANNEL_MONITOR ?= 0
-CHILD_SUPERVISION ?= 0
DATASET_UPDATER ?= 0
DEBUG ?= 0
DHCP6_CLIENT ?= 0
@@ -53,6 +51,7 @@ DISABLE_DOC ?= 0
DISABLE_TOOLS ?= 0
DNS_CLIENT ?= 0
DNS_DSO ?= 0
+DNS_UPSTREAM_QUERY ?= 0
DNSSD_SERVER ?= 0
DUA ?= 0
DYNAMIC_LOG_LEVEL ?= 0
@@ -62,19 +61,22 @@ HISTORY_TRACKER ?= 0
IP6_FRAGM ?= 0
JAM_DETECTION ?= 0
JOINER ?= 0
-LEGACY ?= 0
ifeq ($(REFERENCE_DEVICE),1)
LOG_OUTPUT ?= APP
endif
LINK_RAW ?= 0
MAC_FILTER ?= 0
+MESH_DIAG ?= 0
MESSAGE_USE_HEAP ?= 0
MLE_LONG_ROUTES ?= 0
MLR ?= 0
MTD_NETDIAG ?= 0
MULTIPLE_INSTANCE ?= 0
+NAT64_BORDER_ROUTING ?= 0
+NAT64_TRANSLATOR ?= 0
NEIGHBOR_DISCOVERY_AGENT ?= 0
NETDATA_PUBLISHER ?= 0
+NETDIAG_CLIENT ?= 0
OTNS ?= 0
PING_SENDER ?= 1
PLATFORM_UDP ?= 0
@@ -86,6 +88,7 @@ SLAAC ?= 1
SNTP_CLIENT ?= 0
SRP_CLIENT ?= 0
SRP_SERVER ?= 0
+TCP ?= 0
THREAD_VERSION ?= 1.3
TIME_SYNC ?= 0
TREL ?= 0
@@ -117,8 +120,12 @@ ifeq ($(BORDER_ROUTING),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE=1
endif
-ifeq ($(BORDER_ROUTING_NAT64),1)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE=1
+ifeq ($(NAT64_BORDER_ROUTING),1)
+COMMONCFLAGS += -DOPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE=1
+endif
+
+ifeq ($(NAT64_TRANSLATOR),1)
+COMMONCFLAGS += -DOPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE=1
endif
ifeq ($(COAP),1)
@@ -153,10 +160,6 @@ ifeq ($(CHANNEL_MONITOR),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1
endif
-ifeq ($(CHILD_SUPERVISION),1)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1
-endif
-
ifeq ($(CSL_RECEIVER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1
endif
@@ -207,6 +210,10 @@ ifeq ($(DNS_DSO),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DNS_DSO_ENABLE=1
endif
+ifeq ($(DNS_UPSTREAM_QUERY), 1)
+COMMONCFLAGS += -DOPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE=1
+endif
+
ifeq ($(DNSSD_SERVER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE=1
endif
@@ -243,10 +250,6 @@ ifeq ($(JOINER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_JOINER_ENABLE=1
endif
-ifeq ($(LEGACY),1)
-COMMONCFLAGS += -DOPENTHREAD_CONFIG_LEGACY_ENABLE=1
-endif
-
ifeq ($(LINK_RAW),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_LINK_RAW_ENABLE=1
endif
@@ -267,6 +270,10 @@ ifeq ($(MAC_FILTER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1
endif
+ifeq ($(MESH_DIAG),1)
+COMMONCFLAGS += -DOPENTHREAD_CONFIG_MESH_DIAG_ENABLE=1
+endif
+
ifeq ($(MESSAGE_USE_HEAP),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE=1
endif
@@ -280,6 +287,9 @@ ifeq ($(MLR),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MLR_ENABLE=1
endif
+# This config is removed but we still check and add the
+# `OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE` so to
+# get an error during build if `MTD_NETDIAG` is used.
ifeq ($(MTD_NETDIAG),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1
endif
@@ -296,6 +306,10 @@ ifeq ($(NETDATA_PUBLISHER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE=1
endif
+ifeq ($(NETDIAG_CLIENT),1)
+COMMONCFLAGS += -DOPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE=1
+endif
+
ifeq ($(PING_SENDER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_PING_SENDER_ENABLE=1
endif
@@ -329,12 +343,18 @@ ifeq ($(SRP_SERVER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_SRP_SERVER_ENABLE=1
endif
+ifeq ($(TCP),1)
+COMMONCFLAGS += -DOPENTHREAD_CONFIG_TCP_ENABLE=1
+endif
+
ifeq ($(THREAD_VERSION),1.1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_THREAD_VERSION=2
else ifeq ($(THREAD_VERSION),1.2)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_THREAD_VERSION=3
else ifeq ($(THREAD_VERSION),1.3)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_THREAD_VERSION=4
+else ifeq ($(THREAD_VERSION),1.3.1)
+COMMONCFLAGS += -DOPENTHREAD_CONFIG_THREAD_VERSION=5
endif
ifeq ($(TIME_SYNC),1)
diff --git a/examples/platforms/Makefile.am b/examples/platforms/Makefile.am
index e7bd3ed6c2e..7f86919d855 100644
--- a/examples/platforms/Makefile.am
+++ b/examples/platforms/Makefile.am
@@ -30,6 +30,7 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
EXTRA_DIST = \
cc1352 \
+ cc2538 \
cc2652 \
efr32 \
gp712 \
@@ -45,7 +46,6 @@ EXTRA_DIST = \
# Always package (e.g. for 'make dist') these subdirectories.
DIST_SUBDIRS = \
- cc2538 \
simulation \
utils \
$(NULL)
@@ -56,10 +56,6 @@ SUBDIRS = \
utils \
$(NULL)
-if OPENTHREAD_PLATFORM_CC2538
-SUBDIRS += cc2538
-endif
-
if OPENTHREAD_PLATFORM_SIMULATION
SUBDIRS += simulation
endif
diff --git a/examples/platforms/Makefile.platform.am b/examples/platforms/Makefile.platform.am
index 8ab6520e2d3..71b82b0c2a7 100644
--- a/examples/platforms/Makefile.platform.am
+++ b/examples/platforms/Makefile.platform.am
@@ -41,10 +41,6 @@ LDFLAGS_COMMON = $(NULL)
SOURCES_COMMON = $(NULL)
LIBTOOLFLAGS_COMMON = --preserve-dup-deps
-if OPENTHREAD_EXAMPLES_CC2538
-include $(top_srcdir)/examples/platforms/cc2538/Makefile.platform.am
-endif
-
if OPENTHREAD_EXAMPLES_SIMULATION
include $(top_srcdir)/examples/platforms/simulation/Makefile.platform.am
endif
diff --git a/examples/platforms/cc2538/Makefile.am b/examples/platforms/cc2538/Makefile.am
deleted file mode 100644
index fb802f21183..00000000000
--- a/examples/platforms/cc2538/Makefile.am
+++ /dev/null
@@ -1,69 +0,0 @@
-#
-# Copyright (c) 2016, The OpenThread Authors.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. Neither the name of the copyright holder nor the
-# names of its contributors may be used to endorse or promote products
-# derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-
-include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
-
-# Do not enable -Wcast-align for this platform
-override CFLAGS := $(filter-out -Wcast-align,$(CFLAGS))
-override CXXFLAGS := $(filter-out -Wcast-align,$(CXXFLAGS))
-
-lib_LIBRARIES = libopenthread-cc2538.a
-
-libopenthread_cc2538_a_CPPFLAGS = \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/examples/platforms \
- -I$(top_srcdir)/src/core \
- $(NULL)
-
-PLATFORM_SOURCES = \
- alarm.c \
- cc2538-reg.h \
- diag.c \
- entropy.c \
- flash.c \
- misc.c \
- openthread-core-cc2538-config.h \
- openthread-core-cc2538-config-check.h \
- platform-cc2538.h \
- radio.c \
- rom-utility.h \
- startup-gcc.c \
- system.c \
- logging.c \
- uart.c \
- $(NULL)
-
-libopenthread_cc2538_a_SOURCES = \
- $(PLATFORM_SOURCES) \
- $(NULL)
-
-Dash = -
-libopenthread_cc2538_a_LIBADD = \
- $(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
-
-include $(abs_top_nlbuild_autotools_dir)/automake/post.am
diff --git a/examples/platforms/cc2538/README.md b/examples/platforms/cc2538/README.md
index 91d5b7afbbb..d6674dde27d 100644
--- a/examples/platforms/cc2538/README.md
+++ b/examples/platforms/cc2538/README.md
@@ -1,112 +1 @@
-# OpenThread on CC2538 Example
-
-This directory contains example platform drivers for the [Texas Instruments CC2538][cc2538].
-
-[cc2538]: http://www.ti.com/product/CC2538
-
-The example platform drivers are intended to present the minimal code necessary to support OpenThread. As a result, the example platform drivers do not necessarily highlight the platform's full capabilities.
-
-## Toolchain
-
-Download and install the [GNU toolchain for ARM Cortex-M][gnu-toolchain].
-
-[gnu-toolchain]: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm
-
-In a Bash terminal, follow these instructions to install the GNU toolchain and other dependencies.
-
-```bash
-$ cd
-$ ./script/bootstrap
-```
-
-## Building
-
-In a Bash terminal, follow these instructions to build the cc2538 examples.
-
-```bash
-$ cd
-$ ./bootstrap
-$ make -f examples/Makefile-cc2538
-```
-
-### CC2592 support
-
-If your board has a CC2592 range extender front-end IC connected to the CC2538 (e.g. the CC2538-CC2592 EM reference design), you need to initialise this part before reception of radio traffic will work.
-
-Support is enabled in OpenThread by building with `CC2592=1`:
-
-```bash
-$ make -f examples/Makefile-cc2538 CC2592=1
-```
-
-The default settings should work for any design following the integration advice given in TI's application report ["AN130 - Using CC2592 Front End With CC2538"](http://www.ti.com/lit/pdf/swra447).
-
-Additional settings can be customised:
-
-- `CC2592_PA_EN`: This specifies which pin (on port C of the CC2538) connects to the CC2592's `PA_EN` pin. The default is `3` (PC3).
-- `CC2592_LNA_EN`: This specifies which pin (on port C of the CC2538) connects to the CC2592's `LNA_EN` pin. The default is `2` (PC2).
-- `CC2592_USE_HGM`: This defines whether the HGM pin of the CC2592 is under GPIO control or not. If not, it is assumed that the HGM pin is tied to a power rail.
-- `CC2592_HGM_PORT`: The HGM pin can be connected to any free GPIO. TI recommend using PD2, however if you've used a pin on another GPIO port, you may specify that port (`A`, `B` or `C`) here.
-- `CC2592_HGM_PORT`: The HGM pin can be connected to any free GPIO. TI recommend using PD2, however if you've used a pin on another GPIO port, you may specify that port (`A`, `B` or `C`) here. Default is `D`.
-- `CC2592_HGM_PIN`: The HGM pin can be connected to any free GPIO. TI recommend using PD2, however if you've used a pin on another GPIO pin, you can specify the pin here. Default is `2`.
-- `CC2592_HGM_DEFAULT_STATE`: By default, HGM is enabled at power-on, but you may want to have it default to off, specify `CC2592_HGM_DEFAULT_STATE=0` to do so.
-- `CC2538_RECEIVE_SENSITIVITY`: If you have tied the HGM pin to a power rail, this allows you to calibrate the RSSI values according to the new receive sensitivity. This has no effect if `CC2592_USE_HGM=1` (the default).
-- `CC2538_RSSI_OFFSET`: If you have tied the HGM pin to a power rail, this allows you to calibrate the RSSI values according to the new RSSI offset. This has no effect if `CC2592_USE_HGM=1` (the default).
-
-## Flash Binaries
-
-If the build completed successfully, the `elf` files may be found in `/output/cc2538/bin`.
-
-To flash the images with [Flash Programmer 2][ti-flash-programmer-2], the files must have the `*.elf` extension.
-
-```bash
-$ cd /output/cc2538/bin
-$ cp ot-cli ot-cli.elf
-```
-
-To load the images with the [serial bootloader][ti-cc2538-bootloader], the images must be converted to `bin`. This is done using `arm-none-eabi-objcopy`
-
-```bash
-$ cd /output/cc2538/bin
-$ arm-none-eabi-objcopy -O binary ot-cli ot-cli.bin
-```
-
-The [cc2538-bsl.py script][cc2538-bsl-tool] provides a convenient method for flashing a CC2538 via the UART. To enter the bootloader backdoor for flashing, hold down SELECT for CC2538DK (corresponds to logic '0') while you press the Reset button.
-
-[ti-flash-programmer-2]: http://www.ti.com/tool/flash-programmer
-[ti-cc2538-bootloader]: http://www.ti.com/lit/an/swra466a/swra466a.pdf
-[cc2538-bsl-tool]: https://github.com/JelmerT/cc2538-bsl
-
-## Interact
-
-1. Open terminal to `/dev/ttyUSB1` (serial port settings: 115200 8-N-1).
-2. Type `help` for list of commands.
-
-```bash
-> help
-help
-channel
-childtimeout
-contextreusedelay
-extaddr
-extpanid
-ipaddr
-keysequence
-leaderweight
-mode
-netdata register
-networkidtimeout
-networkkey
-networkname
-panid
-ping
-prefix
-releaserouterid
-rloc16
-route
-routerupgradethreshold
-scan
-start
-state
-stop
-```
+The OpenThread on CC2538 example has moved to https://github.com/openthread/ot-cc2538
diff --git a/examples/platforms/cc2538/alarm.c b/examples/platforms/cc2538/alarm.c
deleted file mode 100644
index 7deefda0c79..00000000000
--- a/examples/platforms/cc2538/alarm.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file
- * This file implements the OpenThread platform abstraction for the alarm.
- *
- */
-
-#include
-#include
-
-#include
-#include
-#include
-
-#include "platform-cc2538.h"
-
-enum
-{
- kSystemClock = 32000000, ///< MHz
- kTicksPerSec = 1000, ///< Ticks per second
-};
-
-static uint32_t sCounter = 0;
-static uint32_t sAlarmT0 = 0;
-static uint32_t sAlarmDt = 0;
-static bool sIsRunning = false;
-
-static uint8_t sTimersIsRunning = 0;
-static uint32_t sTimersExpireAt[OT_CC2538_TIMERS_COUNT];
-
-extern void cc2538EnergyScanTimerHandler(void);
-
-void cc2538SetTimer(otCC2538Timer aTimer, uint32_t aDelay)
-{
- sTimersIsRunning |= (1 << aTimer);
- sTimersExpireAt[aTimer] = sCounter + aDelay;
-}
-
-void cc2538AlarmInit(void)
-{
- HWREG(NVIC_ST_RELOAD) = kSystemClock / kTicksPerSec;
- HWREG(NVIC_ST_CTRL) = NVIC_ST_CTRL_CLK_SRC | NVIC_ST_CTRL_INTEN | NVIC_ST_CTRL_ENABLE;
-}
-
-uint32_t otPlatAlarmMilliGetNow(void)
-{
- return sCounter;
-}
-
-void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- sAlarmT0 = t0;
- sAlarmDt = dt;
- sIsRunning = true;
-}
-
-void otPlatAlarmMilliStop(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- sIsRunning = false;
-}
-
-void cc2538AlarmProcess(otInstance *aInstance)
-{
- uint32_t expires;
- bool fire = false;
-
- if (sTimersIsRunning)
- {
- if ((int32_t)(sTimersExpireAt[OT_CC2538_TIMER_ENERGY_SCAN] - sCounter) < 0)
- {
- sTimersIsRunning &= ~(1 << OT_CC2538_TIMER_ENERGY_SCAN);
- cc2538EnergyScanTimerHandler();
- }
- }
-
- if (sIsRunning)
- {
- expires = sAlarmT0 + sAlarmDt;
-
- if (sAlarmT0 <= sCounter)
- {
- if (expires >= sAlarmT0 && expires <= sCounter)
- {
- fire = true;
- }
- }
- else
- {
- if (expires >= sAlarmT0 || expires <= sCounter)
- {
- fire = true;
- }
- }
-
- if (fire)
- {
- sIsRunning = false;
-
-#if OPENTHREAD_CONFIG_DIAG_ENABLE
-
- if (otPlatDiagModeGet())
- {
- otPlatDiagAlarmFired(aInstance);
- }
- else
-#endif
- {
- otPlatAlarmMilliFired(aInstance);
- }
- }
- }
-}
-
-void SysTick_Handler()
-{
- sCounter++;
-}
diff --git a/examples/platforms/cc2538/arm-none-eabi.cmake b/examples/platforms/cc2538/arm-none-eabi.cmake
deleted file mode 100644
index 2e39ec11d47..00000000000
--- a/examples/platforms/cc2538/arm-none-eabi.cmake
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Copyright (c) 2019, The OpenThread Authors.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. Neither the name of the copyright holder nor the
-# names of its contributors may be used to endorse or promote products
-# derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-
-set(CMAKE_SYSTEM_NAME Generic)
-set(CMAKE_SYSTEM_PROCESSOR ARM)
-
-set(CMAKE_C_COMPILER arm-none-eabi-gcc)
-set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
-set(CMAKE_ASM_COMPILER arm-none-eabi-as)
-set(CMAKE_RANLIB arm-none-eabi-ranlib)
-
-set(COMMON_C_FLAGS "-mthumb -fno-builtin -Wall -fdata-sections -ffunction-sections -mabi=aapcs -mcpu=cortex-m3 -mfloat-abi=soft")
-
-set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=gnu99")
-set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti")
-set(CMAKE_ASM_FLAGS_INIT "${COMMON_C_FLAGS}")
-set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs -nostartfiles")
diff --git a/examples/platforms/cc2538/cc2538-reg.h b/examples/platforms/cc2538/cc2538-reg.h
deleted file mode 100644
index 54972fbeabe..00000000000
--- a/examples/platforms/cc2538/cc2538-reg.h
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file
- * This file includes CC2538 register definitions.
- *
- */
-
-#ifndef CC2538_REG_H_
-#define CC2538_REG_H_
-
-#include
-
-// clang-format off
-
-#define HWREG(x) (*((volatile uint32_t *)(x)))
-
-/*!
- * For registers that are arrays of 32-bit integers.
- *
- * @param reg Register address
- * @param idx Register array index
- */
-#define HWREG_ARR(reg, idx) HWREG((reg) + ((idx) << 2))
-
-#define NVIC_ST_CTRL 0xE000E010 // SysTick Control and Status
-#define NVIC_ST_RELOAD 0xE000E014 // SysTick Reload Value Register
-#define NVIC_EN0 0xE000E100 // Interrupt 0-31 Set Enable
-
-#define NVIC_ST_CTRL_COUNT 0x00010000 // Count Flag
-#define NVIC_ST_CTRL_CLK_SRC 0x00000004 // Clock Source
-#define NVIC_ST_CTRL_INTEN 0x00000002 // Interrupt Enable
-#define NVIC_ST_CTRL_ENABLE 0x00000001 // Enable
-
-#define RFCORE_XREG_SRCMATCH_EN 0x00000001 // SRCMATCH.SRC_MATCH_EN(1)
-#define RFCORE_XREG_SRCMATCH_AUTOPEND 0x00000002 // SRCMATCH.AUTOPEND(1)
-#define RFCORE_XREG_SRCMATCH_PEND_DATAREQ_ONLY 0x00000004 // SRCMATCH.PEND_DATAREQ_ONLY(1)
-
-#define RFCORE_XREG_SRCMATCH_ENABLE_STATUS_SIZE 3 // Num of register for source match enable status
-#define RFCORE_XREG_SRCMATCH_SHORT_ENTRIES 24 // 24 short address entries in maximum
-#define RFCORE_XREG_SRCMATCH_EXT_ENTRIES 12 // 12 extended address entries in maximum
-#define RFCORE_XREG_SRCMATCH_SHORT_ENTRY_OFFSET 4 // address offset for one short address entry
-#define RFCORE_XREG_SRCMATCH_EXT_ENTRY_OFFSET 8 // address offset for one extended address entry
-
-#define INT_UART0 21 // UART0 Rx and Tx
-
-#define IEEE_EUI64 0x00280028 // Address of IEEE EUI-64 address
-
-#define RFCORE_FFSM_SRCADDRESS_TABLE 0x40088400 // Source Address Table
-
-#define RFCORE_FFSM_SRCEXTPENDEN0 0x40088590 // Enable/Disable automatic pending per extended address
-#define RFCORE_FFSM_SRCSHORTPENDEN0 0x4008859C // Enable/Disable automatic pending per short address
-#define RFCORE_FFSM_EXT_ADDR0 0x400885A8 // Local address information
-#define RFCORE_FFSM_PAN_ID0 0x400885C8 // Local address information
-#define RFCORE_FFSM_PAN_ID1 0x400885CC // Local address information
-#define RFCORE_FFSM_SHORT_ADDR0 0x400885D0 // Local address information
-#define RFCORE_FFSM_SHORT_ADDR1 0x400885D4 // Local address information
-#define RFCORE_XREG_FRMFILT0 0x40088600 // The frame filtering function
-#define RFCORE_XREG_SRCMATCH 0x40088608 // Source address matching and pending bits
-#define RFCORE_XREG_SRCSHORTEN0 0x4008860C // Short address matching
-#define RFCORE_XREG_SRCEXTEN0 0x40088618 // Extended address matching
-
-#define RFCORE_XREG_FRMCTRL0 0x40088624 // Frame handling
-#define RFCORE_XREG_FRMCTRL1 0x40088628 // Frame handling
-#define RFCORE_XREG_RXENABLE 0x4008862C // RX enabling
-#define RFCORE_XREG_FREQCTRL 0x4008863C // Controls the RF frequency
-#define RFCORE_XREG_TXPOWER 0x40088640 // Controls the output power
-#define RFCORE_XREG_FSMSTAT0 0x40088648 // Radio finite state machine status
-#define RFCORE_XREG_FSMSTAT1 0x4008864C // Radio status register
-#define RFCORE_XREG_FIFOPCTRL 0x40088650 // FIFOP threshold
-#define RFCORE_XREG_CCACTRL0 0x40088658 // CCA threshold
-#define RFCORE_XREG_RSSI 0x40088660 // RSSI status register
-#define RFCORE_XREG_RSSISTAT 0x40088664 // RSSI valid status register
-#define RFCORE_XREG_AGCCTRL1 0x400886C8 // AGC reference level
-#define RFCORE_XREG_RFC_OBS_CTRL 0x400887AC // RF Core observable output
-#define RFCORE_XREG_TXFILTCFG 0x400887E8 // TX filter configuration
-#define RFCORE_XREG_RFRND 0x4008869C // Random data
-#define RFCORE_SFR_RFDATA 0x40088828 // The TX FIFO and RX FIFO
-#define RFCORE_SFR_RFERRF 0x4008882C // RF error interrupt flags
-#define RFCORE_SFR_RFIRQF0 0x40088834 // RF interrupt flags
-#define RFCORE_SFR_RFST 0x40088838 // RF CSMA-CA/strobe processor
-#define CCTEST_OBSSEL 0x44010014 // CCTEST observable output route
-
-#define RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN 0x00000001 // Enables frame filtering
-
-#define RFCORE_XREG_FRMCTRL0_AUTOACK 0x00000020
-#define RFCORE_XREG_FRMCTRL0_ENERGY_SCAN 0x00000010
-#define RFCORE_XREG_FRMCTRL0_AUTOCRC 0x00000040
-#define RFCORE_XREG_FRMCTRL0_INFINITY_RX 0x00000008
-
-#define RFCORE_XREG_FRMCTRL1_PENDING_OR 0x00000004
-
-#define RFCORE_XREG_RFRND_IRND 0x00000001
-
-#define RFCORE_XREG_FSMSTAT0_STATE_MASK 0x0000003F
-#define RFCORE_XREG_FSMSTAT0_CAL_DONE 0x00000080
-#define RFCORE_XREG_FSMSTAT0_CAL_RUN 0x00000040
-
-#define RFCORE_XREG_FSMSTAT0_STATE_IDLE 0x00000000
-#define RFCORE_XREG_FSMSTAT0_STATE_RX_CAL 0x00000002
-#define RFCORE_XREG_FSMSTAT0_STATE_SFD_WAIT0 0x00000003
-#define RFCORE_XREG_FSMSTAT0_STATE_SFD_WAIT1 0x00000004
-#define RFCORE_XREG_FSMSTAT0_STATE_SFD_WAIT2 0x00000005
-#define RFCORE_XREG_FSMSTAT0_STATE_SFD_WAIT3 0x00000006
-#define RFCORE_XREG_FSMSTAT0_STATE_RX0 0x00000007
-#define RFCORE_XREG_FSMSTAT0_STATE_RX1 0x00000008
-#define RFCORE_XREG_FSMSTAT0_STATE_RX2 0x00000009
-#define RFCORE_XREG_FSMSTAT0_STATE_RX3 0x0000000A
-#define RFCORE_XREG_FSMSTAT0_STATE_RX4 0x0000000B
-#define RFCORE_XREG_FSMSTAT0_STATE_RX5 0x0000000C
-#define RFCORE_XREG_FSMSTAT0_STATE_RX6 0x0000000D
-#define RFCORE_XREG_FSMSTAT0_STATE_RX_WAIT 0x0000000E
-#define RFCORE_XREG_FSMSTAT0_STATE_RX_FRST 0x00000010
-#define RFCORE_XREG_FSMSTAT0_STATE_RX_OVER 0x00000011
-#define RFCORE_XREG_FSMSTAT0_STATE_TX_CAL 0x00000020
-#define RFCORE_XREG_FSMSTAT0_STATE_TX0 0x00000022
-#define RFCORE_XREG_FSMSTAT0_STATE_TX1 0x00000023
-#define RFCORE_XREG_FSMSTAT0_STATE_TX2 0x00000024
-#define RFCORE_XREG_FSMSTAT0_STATE_TX3 0x00000025
-#define RFCORE_XREG_FSMSTAT0_STATE_TX4 0x00000026
-#define RFCORE_XREG_FSMSTAT0_STATE_TX_FINAL 0x00000027
-#define RFCORE_XREG_FSMSTAT0_STATE_RXTX_TRANS 0x00000028
-#define RFCORE_XREG_FSMSTAT0_STATE_ACK_CAL 0x00000030
-#define RFCORE_XREG_FSMSTAT0_STATE_ACK0 0x00000031
-#define RFCORE_XREG_FSMSTAT0_STATE_ACK1 0x00000032
-#define RFCORE_XREG_FSMSTAT0_STATE_ACK2 0x00000033
-#define RFCORE_XREG_FSMSTAT0_STATE_ACK3 0x00000034
-#define RFCORE_XREG_FSMSTAT0_STATE_ACK4 0x00000035
-#define RFCORE_XREG_FSMSTAT0_STATE_ACK5 0x00000036
-#define RFCORE_XREG_FSMSTAT0_STATE_ACK_DELAY 0x00000037
-#define RFCORE_XREG_FSMSTAT0_STATE_TX_UNDER 0x00000038
-#define RFCORE_XREG_FSMSTAT0_STATE_TX_DOWN0 0x0000001A
-#define RFCORE_XREG_FSMSTAT0_STATE_TX_DOWN1 0x0000003A
-
-#define RFCORE_XREG_FSMSTAT1_RX_ACTIVE 0x00000001
-#define RFCORE_XREG_FSMSTAT1_TX_ACTIVE 0x00000002
-#define RFCORE_XREG_FSMSTAT1_LOCK_STATUS 0x00000004
-#define RFCORE_XREG_FSMSTAT1_SAMPLED_CCA 0x00000008
-#define RFCORE_XREG_FSMSTAT1_CCA 0x00000010 // Clear channel assessment
-#define RFCORE_XREG_FSMSTAT1_SFD 0x00000020
-#define RFCORE_XREG_FSMSTAT1_FIFOP 0x00000040
-#define RFCORE_XREG_FSMSTAT1_FIFO 0x00000080
-
-#define RFCORE_XREG_RSSISTAT_RSSI_VALID 0x00000001 // RSSI value is valid.
-
-#define RFCORE_XREG_RFC_OBS_POL_INV 0x00000040 // Invert polarity of OBS signal
-#define RFCORE_XREG_RFC_OBS_MUX_ZERO 0x00000000 // Observable = constant zero
-#define RFCORE_XREG_RFC_OBS_MUX_ONE 0x00000001 // Observable = constant one
-#define RFCORE_XREG_RFC_OBS_MUX_SNIFF_DATA 0x00000008 // RFC sniff data
-#define RFCORE_XREG_RFC_OBS_MUX_SNIFF_CLK 0x00000009 // RFC sniff clock
-#define RFCORE_XREG_RFC_OBS_MUX_RSSI_VALID 0x0000000c // RSSI valid
-#define RFCORE_XREG_RFC_OBS_MUX_DEMOD_CCA 0x0000000d // Clear channel assessment
-#define RFCORE_XREG_RFC_OBS_MUX_SAMPLED_CCA 0x0000000e // Sampled CCA signal
-#define RFCORE_XREG_RFC_OBS_MUX_SFD_SYNC 0x0000000f // SFD received or transmitted
-#define RFCORE_XREG_RFC_OBS_MUX_TX_ACTIVE 0x00000010 // Transmitter is active
-#define RFCORE_XREG_RFC_OBS_MUX_RX_ACTIVE 0x00000011 // Receiver is active
-#define RFCORE_XREG_RFC_OBS_MUX_FFCTRL_FIFO 0x00000012 // One or more bytes in FIFO
-#define RFCORE_XREG_RFC_OBS_MUX_FFCTRL_FIFOP 0x00000013 // One or more frames in FIFO
-#define RFCORE_XREG_RFC_OBS_MUX_PACKET_DONE 0x00000014 // Packet received
-#define RFCORE_XREG_RFC_OBS_MUX_RFC_XOR_RAND_IQ 0x00000016 // RAND I ^ RAND Q
-#define RFCORE_XREG_RFC_OBS_MUX_RFC_RAND_Q 0x00000017 // Random data from Q channel
-#define RFCORE_XREG_RFC_OBS_MUX_RFC_RAND_I 0x00000018 // Random data from I channel
-#define RFCORE_XREG_RFC_OBS_MUX_LOCK_STATUS 0x00000019 // PLL is in lock
-#define RFCORE_XREG_RFC_OBS_MUX_PA_PD 0x00000028 // Power amp power down
-#define RFCORE_XREG_RFC_OBS_MUX_LNA_PD 0x0000002a // LNA power down
-
-#define RFCORE_SFR_RFERRF_NLOCK 0x00000001 // Failed to achieve PLL lock.
-#define RFCORE_SFR_RFERRF_RXABO 0x00000002 // RX Aborted.
-#define RFCORE_SFR_RFERRF_RXOVERF 0x00000004 // RX FIFO overflowed.
-#define RFCORE_SFR_RFERRF_RXUNDERF 0x00000008 // RX FIFO underflowed.
-#define RFCORE_SFR_RFERRF_TXOVERF 0x00000010 // TX FIFO overflowed.
-#define RFCORE_SFR_RFERRF_TXUNDERF 0x00000020 // TX FIFO underflowed.
-#define RFCORE_SFR_RFERRF_STROBEERR 0x00000040 // Command Strobe Error.
-
-#define RFCORE_SFR_RFST_INSTR_RXON 0xE3 // Instruction set RX on
-#define RFCORE_SFR_RFST_INSTR_TXON 0xE9 // Instruction set TX on
-#define RFCORE_SFR_RFST_INSTR_RFOFF 0xEF // Instruction set RF off
-#define RFCORE_SFR_RFST_INSTR_FLUSHRX 0xED // Instruction set flush rx buffer
-#define RFCORE_SFR_RFST_INSTR_FLUSHTX 0xEE // Instruction set flush tx buffer
-
-#define CCTEST_OBSSEL_EN 0x00000080 // Enable the OBS output on this pin
-#define CCTEST_OBSSEL_SEL_OBS0 0x00000000 // Route OBS0 to pin
-#define CCTEST_OBSSEL_SEL_OBS1 0x00000001 // Route OBS1 to pin
-#define CCTEST_OBSSEL_SEL_OBS2 0x00000002 // Route OBS2 to pin
-
-#define ANA_REGS_BASE 0x400D6000 // ANA_REGS
-#define ANA_REGS_O_IVCTRL 0x00000004 // Analog control register
-
-#define SYS_CTRL_CLOCK_CTRL 0x400D2000 // The clock control register
-#define SYS_CTRL_SYSDIV_32MHZ 0x00000000 // Sys_div for sysclk 32MHz
-#define SYS_CTRL_CLOCK_CTRL_AMP_DET 0x00200000
-
-#define SYS_CTRL_PWRDBG 0x400D2074
-#define SYS_CTRL_PWRDBG_FORCE_WARM_RESET 0x00000008
-
-#define SYS_CTRL_RCGCUART 0x400D2028
-#define SYS_CTRL_SCGCUART 0x400D202C
-#define SYS_CTRL_DCGCUART 0x400D2030
-#define SYS_CTRL_I_MAP 0x400D2098
-#define SYS_CTRL_RCGCRFC 0x400D20A8
-#define SYS_CTRL_SCGCRFC 0x400D20AC
-#define SYS_CTRL_DCGCRFC 0x400D20B0
-#define SYS_CTRL_EMUOVR 0x400D20B4
-
-#define SYS_CTRL_RCGCRFC_RFC0 0x00000001
-#define SYS_CTRL_SCGCRFC_RFC0 0x00000001
-#define SYS_CTRL_DCGCRFC_RFC0 0x00000001
-
-#define SYS_CTRL_I_MAP_ALTMAP 0x00000001
-
-#define SYS_CTRL_RCGCUART_UART0 0x00000001
-#define SYS_CTRL_SCGCUART_UART0 0x00000001
-#define SYS_CTRL_DCGCUART_UART0 0x00000001
-
-#define SYS_CTRL_RCGCUART_UART1 0x00000002
-#define SYS_CTRL_SCGCUART_UART1 0x00000002
-#define SYS_CTRL_DCGCUART_UART1 0x00000002
-
-#define IOC_PA0_SEL 0x400D4000 // Peripheral select control
-#define IOC_PA1_SEL 0x400D4004 // Peripheral select control
-#define IOC_PA2_SEL 0x400D4008
-#define IOC_PA3_SEL 0x400D400C
-#define IOC_UARTRXD_UART0 0x400D4100
-#define IOC_UARTRXD_UART1 0x400D4108
-
-#define IOC_PA0_OVER 0x400D4080
-#define IOC_PA1_OVER 0x400D4084
-#define IOC_PA2_OVER 0x400D4088
-#define IOC_PA3_OVER 0x400D408C
-
-#define IOC_MUX_OUT_SEL_UART0_TXD 0x00000000
-#define IOC_MUX_OUT_SEL_UART1_TXD 0x00000002
-
-#define IOC_OVERRIDE_OE 0x00000008 // PAD Config Override Output Enable
-#define IOC_OVERRIDE_DIS 0x00000000 // PAD Config Override Disabled
-
-#define IOC_PAD_IN_SEL_PA0 0x00000000 // PA0
-#define IOC_PAD_IN_SEL_PA1 0x00000001 // PA1
-#define IOC_PAD_IN_SEL_PA2 0x00000002 // PA2
-#define IOC_PAD_IN_SEL_PA3 0x00000003 // PA3
-
-#define UART0_BASE 0x4000C000
-#define UART1_BASE 0x4000D000
-#define GPIO_A_BASE 0x400D9000 // GPIO A
-#define GPIO_B_BASE 0x400DA000 // GPIO B
-#define GPIO_C_BASE 0x400DB000 // GPIO C
-#define GPIO_D_BASE 0x400DC000 // GPIO D
-
-#define GPIO_O_DIR 0x00000400
-#define GPIO_O_AFSEL 0x00000420
-
-#define GPIO_PIN(x) (1UL << x) // Arbitrary GPIO pin
-#define GPIO_PIN_0 0x00000001 // GPIO pin 0
-#define GPIO_PIN_1 0x00000002 // GPIO pin 1
-#define GPIO_PIN_2 0x00000004 // GPIO pin 2
-#define GPIO_PIN_3 0x00000008 // GPIO pin 3
-#define GPIO_PIN_4 0x00000010 // GPIO pin 4
-#define GPIO_PIN_5 0x00000020 // GPIO pin 5
-#define GPIO_PIN_6 0x00000040 // GPIO pin 6
-#define GPIO_PIN_7 0x00000080 // GPIO pin 7
-
-#define UART_O_DR 0x00000000 // UART data
-#define UART_O_FR 0x00000018 // UART flag
-#define UART_O_IBRD 0x00000024
-#define UART_O_FBRD 0x00000028
-#define UART_O_LCRH 0x0000002C
-#define UART_O_CTL 0x00000030 // UART control
-#define UART_O_IM 0x00000038 // UART interrupt mask
-#define UART_O_MIS 0x00000040 // UART masked interrupt status
-#define UART_O_ICR 0x00000044 // UART interrupt clear
-#define UART_O_CC 0x00000FC8 // UART clock configuration
-
-#define UART_FR_RXFE 0x00000010 // UART receive FIFO empty
-#define UART_FR_TXFF 0x00000020 // UART transmit FIFO full
-#define UART_FR_RXFF 0x00000040 // UART receive FIFO full
-
-#define UART_CONFIG_WLEN_8 0x00000060 // 8 bit data
-#define UART_CONFIG_STOP_ONE 0x00000000 // One stop bit
-#define UART_CONFIG_PAR_NONE 0x00000000 // No parity
-
-#define UART_CTL_UARTEN 0x00000001 // UART enable
-#define UART_CTL_TXE 0x00000100 // UART transmit enable
-#define UART_CTL_RXE 0x00000200 // UART receive enable
-
-#define UART_IM_RXIM 0x00000010 // UART receive interrupt mask
-#define UART_IM_RTIM 0x00000040 // UART receive time-out interrupt
-
-#define SOC_ADC_ADCCON1 0x400D7000 // ADC Control
-#define SOC_ADC_RNDL 0x400D7014 // RNG low data
-#define SOC_ADC_RNDH 0x400D7018 // RNG high data
-
-#define SOC_ADC_ADCCON1_RCTRL0 0x00000004 // ADCCON1 RCTRL bit 0
-#define SOC_ADC_ADCCON1_RCTRL1 0x00000008 // ADCCON1 RCTRL bit 1
-
-#define FLASH_CTRL_FCTL 0x400D3008 // Flash control
-#define FLASH_CTRL_DIECFG0 0x400D3014 // Flash information
-
-// clang-format on
-
-#endif
diff --git a/examples/platforms/cc2538/cc2538.ld b/examples/platforms/cc2538/cc2538.ld
deleted file mode 100644
index daff1621f24..00000000000
--- a/examples/platforms/cc2538/cc2538.ld
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file
- * GCC linker script for CC2538.
- */
-
-_512k_bytes = (512*1024);
-_256k_bytes = (256*1024);
-_128k_bytes = (128*1024);
-_FLASH_page_size = 2048;
-
-/*
- * Change for your chip, default is 512k chips
- */
-_FLASH_size_bytes = _512k_bytes;
-_FLASH_n_pages = (_FLASH_size_bytes / _FLASH_page_size);
-/* reduce the usable size by: the CCA + settings Page A & B, total 3 pages */
-_FLASH_usable_size = (_FLASH_size_bytes - (3 * _FLASH_page_size));
-_FLASH_start = 0x00200000;
-_FLASH_end = (_FLASH_start + _FLASH_size_bytes);
-
-/*
- * The CCA (Customer Configuration Area) is always the last page.
- * See: http://www.ti.com/lit/ug/swru319c/swru319c.pdf
- * table 8-2 for more details.
- */
-_FLASH_cca_page = (_FLASH_end - (1 * _FLASH_page_size));
-
-/*
- * OpenThread NV storage goes in the settings page.
- * OpenThread requires at least 2 adjacent pages, call them A and B.
- */
-_FLASH_settings_pageB = (_FLASH_end - (2 * _FLASH_page_size));
-_FLASH_settings_pageA = (_FLASH_end - (3 * _FLASH_page_size));
-
-MEMORY
-{
- /* would like to use SYMBOLS (from above)here but we cannot
- * GCC version 4.9 does not support symbolic expressions here.
- * But later versions do support the feature.
- */
- FLASH (rx) : ORIGIN = 0x00200000, LENGTH = 0x0007c000
- FLASH_CCA (rx) : ORIGIN = 0x0027FFD4, LENGTH = 0x2c
- SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
-}
-/*
- * To safty check what would have been the SYMBOL values
- * we use these ASSERTS to verify things are still good.
- */
-ASSERT( _FLASH_start == 0x00200000, "invalid flash start address for cc2538")
-ASSERT( _FLASH_cca_page == 0x0027f800, "invalid cca start address for cc2538")
-ASSERT( _FLASH_usable_size == 0x0007e800, "Invalid usable size for this config")
-
-
-
-ENTRY(flash_cca_lock_page)
-SECTIONS
-{
- .text : ALIGN(4)
- {
- _text = .;
- *(.vectors)
- *(.text*)
- *(.rodata*)
- KEEP(*(.init))
- KEEP(*(.fini))
- _etext = .;
- } > FLASH= 0
-
- .init_array :
- {
- _init_array = .;
- KEEP(*(SORT(.init_array.*)))
- KEEP(*(.init_array*))
- _einit_array = .;
- } > FLASH
-
- .ARM.exidx : ALIGN(4)
- {
- *(.ARM.exidx*)
- } > FLASH
-
- .data : ALIGN(4)
- {
- _data = .;
- *(.data*)
- _edata = .;
- } > SRAM AT > FLASH
- _ldata = LOADADDR(.data);
-
- .bss : ALIGN(4)
- {
- _bss = .;
- *(.bss*)
- *(COMMON)
- _ebss = .;
- } > SRAM
-
- _heap = .;
- end = .;
-
- .stack : ALIGN(4)
- {
- *(.stack)
- } > SRAM
-
- .flashcca :
- {
- KEEP(*(.flash_cca))
- } > FLASH_CCA
-}
diff --git a/examples/platforms/cc2538/entropy.c b/examples/platforms/cc2538/entropy.c
deleted file mode 100644
index 47a31be04d4..00000000000
--- a/examples/platforms/cc2538/entropy.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2019, The OpenThread Authors.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file
- * This file implements an entropy source based on ADC.
- *
- */
-
-#include
-
-#include
-
-#include "platform-cc2538.h"
-#include "utils/code_utils.h"
-
-static void generateRandom(uint8_t *aOutput, uint16_t aOutputLength)
-{
- uint32_t frmctrl0;
-
- HWREG(SOC_ADC_ADCCON1) &= ~(SOC_ADC_ADCCON1_RCTRL1 | SOC_ADC_ADCCON1_RCTRL0);
- HWREG(SYS_CTRL_RCGCRFC) = SYS_CTRL_RCGCRFC_RFC0;
-
- while (HWREG(SYS_CTRL_RCGCRFC) != SYS_CTRL_RCGCRFC_RFC0)
- ;
-
- frmctrl0 = HWREG(RFCORE_XREG_FRMCTRL0);
- HWREG(RFCORE_XREG_FRMCTRL0) = RFCORE_XREG_FRMCTRL0_INFINITY_RX;
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_RXON;
-
- while (!HWREG(RFCORE_XREG_RSSISTAT) & RFCORE_XREG_RSSISTAT_RSSI_VALID)
- ;
-
- for (uint16_t index = 0; index < aOutputLength; index++)
- {
- aOutput[index] = 0;
-
- for (uint8_t offset = 0; offset < 8 * sizeof(uint8_t); offset++)
- {
- aOutput[index] <<= 1;
- aOutput[index] |= (HWREG(RFCORE_XREG_RFRND) & RFCORE_XREG_RFRND_IRND);
- }
- }
-
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_RFOFF;
- HWREG(RFCORE_XREG_FRMCTRL0) = frmctrl0;
-}
-
-void cc2538RandomInit(void)
-{
- uint16_t seed = 0;
-
- while (seed == 0x0000 || seed == 0x8003)
- {
- generateRandom((uint8_t *)&seed, sizeof(seed));
- }
-
- HWREG(SOC_ADC_RNDL) = (seed >> 8) & 0xff;
- HWREG(SOC_ADC_RNDL) = seed & 0xff;
-}
-
-otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
-{
- otError error = OT_ERROR_NONE;
- uint8_t channel = 0;
-
- otEXPECT_ACTION(aOutput, error = OT_ERROR_INVALID_ARGS);
-
- if (sInstance && otPlatRadioIsEnabled(sInstance))
- {
- channel = 11 + (HWREG(RFCORE_XREG_FREQCTRL) - 11) / 5;
- otPlatRadioSleep(sInstance);
- otPlatRadioDisable(sInstance);
- }
-
- generateRandom(aOutput, aOutputLength);
-
- if (channel)
- {
- cc2538RadioInit();
- otPlatRadioEnable(sInstance);
- otPlatRadioReceive(sInstance, channel);
- }
-
-exit:
- return error;
-}
diff --git a/examples/platforms/cc2538/flash.c b/examples/platforms/cc2538/flash.c
deleted file mode 100644
index 04c8a655941..00000000000
--- a/examples/platforms/cc2538/flash.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include
-#include
-#include
-
-#include "platform-cc2538.h"
-#include "rom-utility.h"
-
-#define FLASH_CTRL_FCTL_BUSY 0x00000080
-
-#define FLASH_PAGE_SIZE 2048
-#define FLASH_PAGE_NUM 2
-#define FLASH_SWAP_SIZE (FLASH_PAGE_SIZE * (FLASH_PAGE_NUM / 2))
-
-/* The linker script creates this external symbol */
-extern uint8_t _FLASH_settings_pageA[];
-
-/* Convert a settings offset to the physical address within the flash settings pages */
-static uint32_t flashPhysAddr(uint8_t aSwapIndex, uint32_t aOffset)
-{
- uint32_t address = (uint32_t)(&_FLASH_settings_pageA[0]) + aOffset;
-
- if (aSwapIndex)
- {
- address += FLASH_SWAP_SIZE;
- }
-
- return address;
-}
-
-void otPlatFlashInit(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-}
-
-uint32_t otPlatFlashGetSwapSize(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- return FLASH_SWAP_SIZE;
-}
-
-void otPlatFlashErase(otInstance *aInstance, uint8_t aSwapIndex)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- ROM_PageErase(flashPhysAddr(aSwapIndex, 0), FLASH_PAGE_SIZE);
- while (HWREG(FLASH_CTRL_FCTL) & FLASH_CTRL_FCTL_BUSY)
- {
- }
-}
-
-void otPlatFlashWrite(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, const void *aData, uint32_t aSize)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- uint32_t *data = (uint32_t *)(aData);
-
- for (uint32_t size = 0; size < aSize; size += sizeof(uint32_t), aOffset += sizeof(uint32_t), data++)
- {
- ROM_ProgramFlash(data, flashPhysAddr(aSwapIndex, aOffset), sizeof(uint32_t));
-
- while (HWREG(FLASH_CTRL_FCTL) & FLASH_CTRL_FCTL_BUSY)
- {
- }
- }
-}
-
-void otPlatFlashRead(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, uint8_t *aData, uint32_t aSize)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- memcpy(aData, (void *)flashPhysAddr(aSwapIndex, aOffset), aSize);
-}
diff --git a/examples/platforms/cc2538/openthread-core-cc2538-config.h b/examples/platforms/cc2538/openthread-core-cc2538-config.h
deleted file mode 100644
index 1f262173e18..00000000000
--- a/examples/platforms/cc2538/openthread-core-cc2538-config.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file
- * This file includes cc2538 compile-time configuration constants for OpenThread.
- */
-
-#ifndef OPENTHREAD_CORE_CC2538_CONFIG_H_
-#define OPENTHREAD_CORE_CC2538_CONFIG_H_
-
-/**
- * @def OPENTHREAD_CONFIG_PLATFORM_INFO
- *
- * The platform-specific string to insert into the OpenThread version string.
- *
- */
-#define OPENTHREAD_CONFIG_PLATFORM_INFO "CC2538"
-
-/**
- * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE
- *
- * Define to 1 if you want to enable software ACK timeout logic.
- *
- */
-#define OPENTHREAD_CONFIG_MAC_SOFTWARE_ACK_TIMEOUT_ENABLE 1
-
-/**
- * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE
- *
- * Define to 1 if you want to enable software retransmission logic.
- *
- */
-#define OPENTHREAD_CONFIG_MAC_SOFTWARE_RETRANSMIT_ENABLE 1
-
-/**
- * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE
- *
- * Define to 1 if you want to enable software CSMA-CA backoff logic.
- *
- */
-#define OPENTHREAD_CONFIG_MAC_SOFTWARE_CSMA_BACKOFF_ENABLE 1
-
-/**
- * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE
- *
- * Define to 1 if you want to enable software transmission security logic.
- *
- */
-#define OPENTHREAD_CONFIG_MAC_SOFTWARE_TX_SECURITY_ENABLE 0
-
-/**
- * @def OPENTHREAD_CONFIG_MAC_SOFTWARE_ENERGY_SCAN_ENABLE
- *
- * Define to 1 if you want to enable software energy scanning logic.
- *
- */
-#define OPENTHREAD_CONFIG_MAC_SOFTWARE_ENERGY_SCAN_ENABLE 1
-
-/**
- * @def OPENTHREAD_CONFIG_NCP_HDLC_ENABLE
- *
- * Define to 1 to enable NCP HDLC support.
- *
- */
-#define OPENTHREAD_CONFIG_NCP_HDLC_ENABLE 1
-
-/**
- * @def OPENTHREAD_CONFIG_CC2538_USE_RADIO_RX_INTERRUPT
- *
- * Enable support for using interrupt-driven radio reception. This allows
- * for a single frame to be received whilst the CPU is busy processing some
- * other code.
- *
- * To disable interrupts and just rely on polling, set this to 0.
- *
- */
-#ifndef OPENTHREAD_CONFIG_CC2538_USE_RADIO_RX_INTERRUPT
-#define OPENTHREAD_CONFIG_CC2538_USE_RADIO_RX_INTERRUPT 1
-#endif
-
-/**
- * @def OPENTHREAD_CONFIG_CC2538_WITH_CC2592
- *
- * Enable support for the CC2592 range-extender front-end.
- *
- * This is a feature of the CC2538-CC2592 EM and other peripherals which
- * extends the range of the bare CC2538 to over a kilometre line-of-sight.
- * The CC2592 needs to be wired up to the RF port on the CC2538 in accordance
- * with application note 130 ("Using CC2592 Front End With CC2538", TI doc
- * SWRA447).
- *
- * If you have such a board, change this to 1.
- *
- */
-#ifndef OPENTHREAD_CONFIG_CC2538_WITH_CC2592
-#define OPENTHREAD_CONFIG_CC2538_WITH_CC2592 0
-#endif
-
-/**
- * @def OPENTHREAD_CONFIG_CC2592_PA_EN_PIN
- *
- * Define the pin (on port C) that connects to the CC2592 PA_EN pin.
- *
- * One of the 3 observable channels on the CC2538 radio module will be
- * configured to take the "PA power down" signal from the radio module itself,
- * invert it, and emit it on this GPIO pin. Due to hardware constraints, it
- * may only be connected to a pin on GPIO port C.
- *
- * The default (PC3) is as per TI recommendations in AN130.
- *
- */
-#ifndef OPENTHREAD_CONFIG_CC2592_PA_EN_PIN
-#define OPENTHREAD_CONFIG_CC2592_PA_EN_PIN 3
-#endif
-
-/**
- * @def OPENTHREAD_CONFIG_CC2592_LNA_EN_PIN
- *
- * Define the pin (on port C) that connects to the CC2592 LNA_EN pin.
- *
- * One of the 3 observable channels on the CC2538 radio module will be
- * configured to take the "LNA power down" signal from the radio module itself,
- * invert it, and emit it on this GPIO pin. Due to hardware constraints, it
- * may only be connected to a pin on GPIO port C.
- *
- * The default (PC2) is as per TI recommendations in AN130.
- *
- */
-#ifndef OPENTHREAD_CONFIG_CC2592_LNA_EN_PIN
-#define OPENTHREAD_CONFIG_CC2592_LNA_EN_PIN 2
-#endif
-
-/**
- * @def OPENTHREAD_CONFIG_CC2592_USE_HGM
- *
- * Enable control of the high-gain mode signal.
- *
- * High-gain mode is enabled through the `HGM` pin on the CC2592, which may be
- * connected to any free GPIO pin for software control, or may be linked to
- * VDD or 0V to hard-wire it to a given state.
- *
- * Set this to 0 if you have wired this pin to a power rail, or have a
- * non-standard way of controlling it.
- *
- */
-#ifndef OPENTHREAD_CONFIG_CC2592_USE_HGM
-#define OPENTHREAD_CONFIG_CC2592_USE_HGM 1
-#endif
-
-/**
- * @def OPENTHREAD_CONFIG_CC2538_RECEIVE_SENSITIVITY
- *
- * Set the CC2538 receive sensitivity.
- *
- * A bare CC2538 has a receive sensitivity of -88dBm. The CC2592 changes this
- * to -85 or -81 depending on whether the HGM pin is high or low. If
- * `OPENTHREAD_CONFIG_CC2592_USE_HGM` is 0, then this sets the receive
- * sensitivity.
- *
- */
-#ifndef OPENTHREAD_CONFIG_CC2538_RECEIVE_SENSITIVITY
-#define OPENTHREAD_CONFIG_CC2538_RECEIVE_SENSITIVITY -88
-#endif
-
-/**
- * @def OPENTHREAD_CONFIG_CC2538_RSSI_OFFSET
- *
- * Set the CC2538 RSSI offset. This calibrates the RSSI readings received from
- * the CC2538 radio module to give a reading in dBm.
- *
- * For a standard CC2538 (no front-end), the RSSI offset is 73.
- *
- * For a CC2592 hard-wired in high-gain mode, an offset of 85 should be used;
- * or for low-gain mode, 81. If `OPENTHREAD_CONFIG_CC2592_USE_HGM` is 0, then
- * this calibrates the RSSI value accordingly.
- */
-#ifndef OPENTHREAD_CONFIG_CC2538_RSSI_OFFSET
-#define OPENTHREAD_CONFIG_CC2538_RSSI_OFFSET 73
-#endif
-
-/**
- * @def OPENTHREAD_CONFIG_CC2592_HGM_PORT
- *
- * Define the GPIO port that the HGM pin is connected to. It may be
- * connected to any available GPIO pin.
- *
- * The default (GPIO port D) is as per TI recommendations.
- *
- */
-#ifndef OPENTHREAD_CONFIG_CC2592_HGM_PORT
-#define OPENTHREAD_CONFIG_CC2592_HGM_PORT GPIO_D_BASE
-#endif
-
-/**
- * @def OPENTHREAD_CONFIG_CC2592_HGM_PIN
- *
- * Define the pin on the GPIO port that the HGM pin is connected to. It
- * may be connected to any available GPIO pin.
- *
- * The default (PD2) is as per TI recommendations.
- *
- */
-#ifndef OPENTHREAD_CONFIG_CC2592_HGM_PIN
-#define OPENTHREAD_CONFIG_CC2592_HGM_PIN 2
-#endif
-
-/**
- * @def OPENTHREAD_CONFIG_CC2592_HGM_DEFAULT_STATE
- *
- * Define the default state of the CC2592's HGM pin.
- *
- * The default is to turn high-gain mode on.
- *
- */
-#ifndef OPENTHREAD_CONFIG_CC2592_HGM_DEFAULT_STATE
-#define OPENTHREAD_CONFIG_CC2592_HGM_DEFAULT_STATE true
-#endif
-
-/**
- * @def OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
- *
- * Define to 1 to enable otPlatFlash* APIs to support non-volatile storage.
- *
- * When defined to 1, the platform MUST implement the otPlatFlash* APIs instead of the otPlatSettings* APIs.
- *
- */
-#define OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE 1
-
-#endif // OPENTHREAD_CORE_CC2538_CONFIG_H_
diff --git a/examples/platforms/cc2538/platform-cc2538.h b/examples/platforms/cc2538/platform-cc2538.h
deleted file mode 100644
index f89b01bbb85..00000000000
--- a/examples/platforms/cc2538/platform-cc2538.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file
- * This file includes the platform-specific initializers.
- *
- */
-
-#ifndef PLATFORM_CC2538_H_
-#define PLATFORM_CC2538_H_
-
-#include
-#include
-#include
-#include
-
-#include "cc2538-reg.h"
-
-// Global OpenThread instance structure
-extern otInstance *sInstance;
-
-/**
- * Initialize the debug uart
- */
-void cc2538DebugUartInit(void);
-
-/**
- * This function initializes the alarm service used by OpenThread.
- *
- */
-void cc2538AlarmInit(void);
-
-/**
- * This function performs alarm driver processing.
- *
- * @param[in] aInstance The OpenThread instance structure.
- *
- */
-void cc2538AlarmProcess(otInstance *aInstance);
-
-/**
- * This function initializes the radio service used by OpenThread.
- *
- */
-void cc2538RadioInit(void);
-
-/**
- * This function performs radio driver processing.
- *
- * @param[in] aInstance The OpenThread instance structure.
- *
- */
-void cc2538RadioProcess(otInstance *aInstance);
-
-/**
- * This function initializes the random number service used by OpenThread.
- *
- */
-void cc2538RandomInit(void);
-
-/**
- * This function performs UART driver processing.
- *
- */
-void cc2538UartProcess(void);
-
-#if OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
-/**
- * Change the state of the CC2592 HGM pin.
- *
- * @param aState Whether or not to enable HGM
- */
-void cc2538RadioSetHgm(bool aState);
-
-/**
- * Retrieve the state of the CC2592 HGM pin.
- */
-bool cc2538RadioGetHgm(void);
-#endif // OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
-
-typedef enum
-{
- OT_CC2538_TIMER_ENERGY_SCAN, ///< Internal timer for energy scan
- OT_CC2538_TIMERS_COUNT, ///< Number of internal timers
-} otCC2538Timer;
-
-/**
- * This function sets the internal timer.
- *
- * @param[in] aTimer The timer identifier.
- * @param[in] aDelay The delay to trigger the timer, and must be no more than `INT32_MAX`.
- *
- */
-void cc2538SetTimer(otCC2538Timer aTimer, uint32_t aDelay);
-
-#endif // PLATFORM_CC2538_H_
diff --git a/examples/platforms/cc2538/radio.c b/examples/platforms/cc2538/radio.c
deleted file mode 100644
index 0878f115da0..00000000000
--- a/examples/platforms/cc2538/radio.c
+++ /dev/null
@@ -1,1273 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file
- * This file implements the OpenThread platform abstraction for radio communication.
- *
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#include "platform-cc2538.h"
-#include "utils/code_utils.h"
-
-#define RFCORE_XREG_RFIRQM0 0x4008868C // RF interrupt masks
-#define RFCORE_XREG_RFIRQM1 0x40088690 // RF interrupt masks
-#define RFCORE_XREG_RFERRM 0x40088694 // RF error interrupt mask
-
-#define RFCORE_SFR_RFIRQF0_RXMASKZERO 0x00000080 // RXENABLE is now completely clear
-#define RFCORE_SFR_RFIRQF0_RXPKTDONE 0x00000040 // A complete frame has been received
-#define RFCORE_SFR_RFIRQF0_FRAME_ACCEPTED 0x00000020 // Frame has passed frame filtering
-#define RFCORE_SFR_RFIRQF0_SRC_MATCH_FOUND 0x00000010 // Source match is found
-#define RFCORE_SFR_RFIRQF0_SRC_MATCH_DONE 0x00000008 // Source matching is complete
-#define RFCORE_SFR_RFIRQF0_FIFOP 0x00000004 // The number of bytes in the RX fifo is above threshold
-#define RFCORE_SFR_RFIRQF0_SFD 0x00000002 // SFD has been received or transmitted
-#define RFCORE_SFR_RFIRQF0_ACT_UNUSED 0x00000001 // Reserved
-
-#define RFCORE_XREG_RFIRQM0_RXMASKZERO 0x00000080
-#define RFCORE_XREG_RFIRQM0_RXPKTDONE 0x00000040
-#define RFCORE_XREG_RFIRQM0_FRAME_ACCEPTED 0x00000020
-#define RFCORE_XREG_RFIRQM0_SRC_MATCH_FOUND 0x00000010
-#define RFCORE_XREG_RFIRQM0_SRC_MATCH_DONE 0x00000008
-#define RFCORE_XREG_RFIRQM0_FIFOP 0x00000004
-#define RFCORE_XREG_RFIRQM0_SFD 0x00000002
-#define RFCORE_XREG_RFIRQM0_ACT_UNUSED 0x00000001
-
-#define RFCORE_SFR_RFIRQF1_CSP_WAIT 0x00000020
-#define RFCORE_SFR_RFIRQF1_CSP_STOP 0x00000010
-#define RFCORE_SFR_RFIRQF1_CSP_MANINT 0x00000008
-#define RFCORE_SFR_RFIRQF1_RF_IDLE 0x00000004
-#define RFCORE_SFR_RFIRQF1_TXDONE 0x00000002
-#define RFCORE_SFR_RFIRQF1_TXACKDONE 0x00000001
-
-#define RFCORE_XREG_RFIRQM1_CSP_WAIT 0x00000020
-#define RFCORE_XREG_RFIRQM1_CSP_STOP 0x00000010
-#define RFCORE_XREG_RFIRQM1_CSP_MANINT 0x00000008
-#define RFCORE_XREG_RFIRQM1_RF_IDLE 0x00000004
-#define RFCORE_XREG_RFIRQM1_TXDONE 0x00000002
-#define RFCORE_XREG_RFIRQM1_TXACKDONE 0x00000001
-
-#define RFCORE_XREG_RFERRM_STROBE_ERR 0x00000040
-#define RFCORE_XREG_RFERRM_TXUNDERF 0x00000020
-#define RFCORE_XREG_RFERRM_TXOVERF 0x00000010
-#define RFCORE_XREG_RFERRM_RXUNDERF 0x00000008
-#define RFCORE_XREG_RFERRM_RXOVERF 0x00000004
-#define RFCORE_XREG_RFERRM_RXABO 0x00000002
-#define RFCORE_XREG_RFERRM_NLOCK 0x00000001
-
-enum
-{
- IEEE802154_MIN_LENGTH = 5,
- IEEE802154_MAX_LENGTH = 127,
- IEEE802154_ACK_LENGTH = 5,
- IEEE802154_FRAME_TYPE_MASK = 0x7,
- IEEE802154_FRAME_TYPE_ACK = 0x2,
- IEEE802154_FRAME_PENDING = 1 << 4,
- IEEE802154_ACK_REQUEST = 1 << 5,
- IEEE802154_DSN_OFFSET = 2,
-};
-
-enum
-{
- CC2538_RSSI_OFFSET = OPENTHREAD_CONFIG_CC2538_RSSI_OFFSET,
- // TI AN130 (SWRA447) Table 4 (bottom of page 3)
- CC2592_RSSI_OFFSET_HGM = 85,
- CC2592_RSSI_OFFSET_LGM = 81,
- CC2538_CRC_BIT_MASK = 0x80,
- CC2538_LQI_BIT_MASK = 0x7f,
-};
-
-// All values in dBm
-enum
-{
- CC2538_RECEIVE_SENSITIVITY = OPENTHREAD_CONFIG_CC2538_RECEIVE_SENSITIVITY,
- // TI AN130 (SWRA447) Table 3 (middle of page 3)
- CC2592_RECEIVE_SENSITIVITY_LGM = -99,
- CC2592_RECEIVE_SENSITIVITY_HGM = -101,
-};
-
-typedef struct TxPowerTable
-{
- int8_t mTxPowerVal;
- uint8_t mTxPowerReg;
-} TxPowerTable;
-
-// The transmit power table.
-static const TxPowerTable sTxPowerTable[] = {
-#if OPENTHREAD_CONFIG_CC2538_WITH_CC2592
- // CC2538 using CC2592 PA
- // Values are from AN130 table 6 (page 4)
- {22, 0xFF}, // 22.0dBm =~ 158.5mW
- {21, 0xD5}, // 20.9dBm =~ 123.0mW
- {20, 0xC5}, // 20.1dBm =~ 102.3mW
- {19, 0xB0}, // 19.0dBm =~ 79.4mW
- {18, 0xA1}, // 17.8dBm =~ 60.3mW
- {16, 0x91}, // 16.4dBm =~ 43.7mW
- {15, 0x88}, // 14.9dBm =~ 30.9mW
- {13, 0x72}, // 13.0dBm =~ 20.0mW
- {11, 0x62}, // 11.0dBm =~ 12.6mW
- {10, 0x58}, // 9.5dBm =~ 8.9mW
- {8, 0x42}, // 7.5dBm =~ 5.6mW
-#else
- // CC2538 operating "bare foot"
- // Values are from SmartRF Studio 2.4.0
- {7, 0xFF}, //
- {5, 0xED}, //
- {3, 0xD5}, //
- {1, 0xC5}, //
- {0, 0xB6}, //
- {-1, 0xB0}, //
- {-3, 0xA1}, //
- {-5, 0x91}, //
- {-7, 0x88}, //
- {-9, 0x72}, //
- {-11, 0x62}, //
- {-13, 0x58}, //
- {-15, 0x42}, //
- {-24, 0x00}, //
-#endif
-};
-
-static otRadioFrame sTransmitFrame;
-static otRadioFrame sReceiveFrame;
-static otError sTransmitError;
-static otError sReceiveError;
-
-static uint8_t sTransmitPsdu[IEEE802154_MAX_LENGTH];
-static uint8_t sReceivePsdu[IEEE802154_MAX_LENGTH];
-static uint8_t sChannel = 0;
-static int8_t sTxPower = 0;
-
-static otRadioState sState = OT_RADIO_STATE_DISABLED;
-static bool sIsReceiverEnabled = false;
-
-#if OPENTHREAD_CONFIG_LOG_PLATFORM && OPENTHREAD_CONFIG_CC2538_USE_RADIO_RX_INTERRUPT
-// Debugging _and_ logging are enabled, so if there's a dropped frame
-// we'll need to store the length here as using snprintf from an interrupt
-// handler is not a good idea.
-static uint8_t sDroppedFrameLength = 0;
-#endif
-
-static int8_t cc2538RadioGetRssiOffset(void);
-
-void enableReceiver(void)
-{
- if (!sIsReceiverEnabled)
- {
- otLogInfoPlat("Enabling receiver", NULL);
-
- // flush rxfifo
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
-
- // enable receiver
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_RXON;
- sIsReceiverEnabled = true;
- }
-}
-
-void disableReceiver(void)
-{
- if (sIsReceiverEnabled)
- {
- otLogInfoPlat("Disabling receiver", NULL);
-
- while (HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE)
- ;
-
- // flush rxfifo
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
-
- if (HWREG(RFCORE_XREG_RXENABLE) != 0)
- {
- // disable receiver
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_RFOFF;
- }
-
- sIsReceiverEnabled = false;
- }
-}
-
-void setChannel(uint8_t aChannel)
-{
- if (sChannel != aChannel)
- {
- bool enabled = false;
-
- if (sIsReceiverEnabled)
- {
- disableReceiver();
- enabled = true;
- }
-
- otLogInfoPlat("Channel=%d", aChannel);
-
- HWREG(RFCORE_XREG_FREQCTRL) = 11 + (aChannel - 11) * 5;
- sChannel = aChannel;
-
- if (enabled)
- {
- enableReceiver();
- }
- }
-}
-
-void setTxPower(int8_t aTxPower)
-{
- uint8_t i = 0;
-
- if (sTxPower != aTxPower)
- {
- otLogInfoPlat("TxPower=%d", aTxPower);
-
- for (i = sizeof(sTxPowerTable) / sizeof(TxPowerTable) - 1; i > 0; i--)
- {
- if (aTxPower < sTxPowerTable[i].mTxPowerVal)
- {
- break;
- }
- }
-
- HWREG(RFCORE_XREG_TXPOWER) = sTxPowerTable[i].mTxPowerReg;
- sTxPower = aTxPower;
- }
-}
-
-static bool cc2538SrcMatchEnabled(void)
-{
- return (HWREG(RFCORE_XREG_FRMCTRL1) & RFCORE_XREG_FRMCTRL1_PENDING_OR) == 0;
-}
-
-static bool cc2538GetSrcMatchFoundIntFlag(void)
-{
- bool flag = (HWREG(RFCORE_SFR_RFIRQF0) & RFCORE_SFR_RFIRQF0_SRC_MATCH_FOUND) != 0;
- if (flag)
- {
- HWREG(RFCORE_SFR_RFIRQF0) &= ~RFCORE_SFR_RFIRQF0_SRC_MATCH_FOUND;
- }
- return flag;
-}
-
-void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- // EUI64 is in a mixed-endian format. Split in two halves, each 32-bit
- // half is in little-endian format (machine endian). However, the
- // most significant part of the EUI64 comes first, so we can't cheat
- // with a uint64_t!
- //
- // See https://e2e.ti.com/support/wireless_connectivity/low_power_rf_tools/f/155/p/307344/1072252
-
- volatile uint32_t *eui64 = &HWREG(IEEE_EUI64);
-
- // Read first 32-bits
- uint32_t part = eui64[0];
- for (uint8_t i = 0; i < (OT_EXT_ADDRESS_SIZE / 2); i++)
- {
- aIeeeEui64[3 - i] = part;
- part >>= 8;
- }
-
- // Read the last 32-bits
- part = eui64[1];
- for (uint8_t i = 0; i < (OT_EXT_ADDRESS_SIZE / 2); i++)
- {
- aIeeeEui64[7 - i] = part;
- part >>= 8;
- }
-}
-
-void otPlatRadioSetPanId(otInstance *aInstance, uint16_t aPanid)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otLogInfoPlat("PANID=%X", aPanid);
-
- HWREG(RFCORE_FFSM_PAN_ID0) = aPanid & 0xFF;
- HWREG(RFCORE_FFSM_PAN_ID1) = aPanid >> 8;
-}
-
-void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aAddress)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otLogInfoPlat("ExtAddr=%X%X%X%X%X%X%X%X", aAddress->m8[7], aAddress->m8[6], aAddress->m8[5], aAddress->m8[4],
- aAddress->m8[3], aAddress->m8[2], aAddress->m8[1], aAddress->m8[0]);
-
- for (int i = 0; i < 8; i++)
- {
- ((volatile uint32_t *)RFCORE_FFSM_EXT_ADDR0)[i] = aAddress->m8[i];
- }
-}
-
-void otPlatRadioSetShortAddress(otInstance *aInstance, uint16_t aAddress)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otLogInfoPlat("ShortAddr=%X", aAddress);
-
- HWREG(RFCORE_FFSM_SHORT_ADDR0) = aAddress & 0xFF;
- HWREG(RFCORE_FFSM_SHORT_ADDR1) = aAddress >> 8;
-}
-
-void cc2538RadioInit(void)
-{
- sTransmitFrame.mLength = 0;
- sTransmitFrame.mPsdu = sTransmitPsdu;
- sReceiveFrame.mLength = 0;
- sReceiveFrame.mPsdu = sReceivePsdu;
-
-#if OPENTHREAD_CONFIG_CC2538_USE_RADIO_RX_INTERRUPT
- // Enable interrupts for RX/TX, interrupt 26.
- // That's NVIC index 0 (26 >> 5) bit 26 (26 & 0x1f).
- HWREG(NVIC_EN0 + (0 * 4)) = (1 << 26);
- HWREG(RFCORE_XREG_RFIRQM0) |= RFCORE_XREG_RFIRQM0_RXPKTDONE;
-#endif
-
- // enable clock
- HWREG(SYS_CTRL_RCGCRFC) = SYS_CTRL_RCGCRFC_RFC0;
- HWREG(SYS_CTRL_SCGCRFC) = SYS_CTRL_SCGCRFC_RFC0;
- HWREG(SYS_CTRL_DCGCRFC) = SYS_CTRL_DCGCRFC_RFC0;
-
- // Table 23-7.
- HWREG(RFCORE_XREG_AGCCTRL1) = 0x15;
- HWREG(RFCORE_XREG_TXFILTCFG) = 0x09;
- HWREG(ANA_REGS_BASE + ANA_REGS_O_IVCTRL) = 0x0b;
-
- HWREG(RFCORE_XREG_CCACTRL0) = 0xf8;
- HWREG(RFCORE_XREG_FIFOPCTRL) = IEEE802154_MAX_LENGTH;
-
- HWREG(RFCORE_XREG_FRMCTRL0) = RFCORE_XREG_FRMCTRL0_AUTOCRC | RFCORE_XREG_FRMCTRL0_AUTOACK;
-
- // default: SRCMATCH.SRC_MATCH_EN(1), SRCMATCH.AUTOPEND(1),
- // SRCMATCH.PEND_DATAREQ_ONLY(1), RFCORE_XREG_FRMCTRL1_PENDING_OR(0)
-
- HWREG(RFCORE_XREG_TXPOWER) = sTxPowerTable[0].mTxPowerReg;
- sTxPower = sTxPowerTable[0].mTxPowerVal;
-
-#if OPENTHREAD_CONFIG_CC2538_WITH_CC2592
- // PA_EN pin configuration.
- // Step 1. make it an output
- HWREG(GPIO_C_BASE | GPIO_O_DIR) |= GPIO_PIN(OPENTHREAD_CONFIG_CC2592_PA_EN_PIN);
- // Step 2. Route PA_PD to OBS0 and invert it to produce PA_EN
- HWREG_ARR(RFCORE_XREG_RFC_OBS_CTRL, 0) = RFCORE_XREG_RFC_OBS_POL_INV // Invert the output
- | RFCORE_XREG_RFC_OBS_MUX_PA_PD; // PA "power down" signal
- // Step 3. Connect the selected pin to OBS0 and enable OBS0.
- HWREG_ARR(CCTEST_OBSSEL, OPENTHREAD_CONFIG_CC2592_PA_EN_PIN) = CCTEST_OBSSEL_EN // Enable the output
- | CCTEST_OBSSEL_SEL_OBS0; // Select OBS0
-
- // LNA_EN pin configuration.
- HWREG(GPIO_C_BASE | GPIO_O_DIR) |= GPIO_PIN(OPENTHREAD_CONFIG_CC2592_LNA_EN_PIN);
- HWREG_ARR(RFCORE_XREG_RFC_OBS_CTRL, 1) = RFCORE_XREG_RFC_OBS_POL_INV | RFCORE_XREG_RFC_OBS_MUX_LNA_PD;
- HWREG_ARR(CCTEST_OBSSEL, OPENTHREAD_CONFIG_CC2592_LNA_EN_PIN) = CCTEST_OBSSEL_EN | CCTEST_OBSSEL_SEL_OBS1;
-
-#if OPENTHREAD_CONFIG_CC2592_USE_HGM
- // HGM pin configuration. Set the pin state first so we don't glitch.
- cc2538RadioSetHgm(OPENTHREAD_CONFIG_CC2592_HGM_DEFAULT_STATE);
- HWREG(OPENTHREAD_CONFIG_CC2592_HGM_PORT | GPIO_O_DIR) |= GPIO_PIN(OPENTHREAD_CONFIG_CC2592_HGM_PIN);
-#endif // OPENTHREAD_CONFIG_CC2592_USE_HGM
-#endif // OPENTHREAD_CONFIG_CC2538_WITH_CC2592
-
- otLogInfoPlat("Initialized", NULL);
-}
-
-#if OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
-void cc2538RadioSetHgm(bool aState)
-{
- if (aState)
- {
- HWREG_ARR(OPENTHREAD_CONFIG_CC2592_HGM_PORT, GPIO_PIN(OPENTHREAD_CONFIG_CC2592_HGM_PIN)) =
- GPIO_PIN(OPENTHREAD_CONFIG_CC2592_HGM_PIN);
- }
- else
- {
- HWREG_ARR(OPENTHREAD_CONFIG_CC2592_HGM_PORT, GPIO_PIN(OPENTHREAD_CONFIG_CC2592_HGM_PIN)) = 0;
- }
-}
-
-bool cc2538RadioGetHgm(void)
-{
- if (HWREG_ARR(OPENTHREAD_CONFIG_CC2592_HGM_PORT, GPIO_PIN(OPENTHREAD_CONFIG_CC2592_HGM_PIN)) &
- GPIO_PIN(OPENTHREAD_CONFIG_CC2592_HGM_PIN))
- {
- return true;
- }
- else
- {
- return false;
- }
-}
-#endif // OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
-
-bool otPlatRadioIsEnabled(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- return (sState != OT_RADIO_STATE_DISABLED) ? true : false;
-}
-
-otError otPlatRadioEnable(otInstance *aInstance)
-{
- if (!otPlatRadioIsEnabled(aInstance))
- {
- otLogDebgPlat("State=OT_RADIO_STATE_SLEEP", NULL);
- sState = OT_RADIO_STATE_SLEEP;
- }
-
- return OT_ERROR_NONE;
-}
-
-otError otPlatRadioDisable(otInstance *aInstance)
-{
- if (otPlatRadioIsEnabled(aInstance))
- {
- otLogDebgPlat("State=OT_RADIO_STATE_DISABLED", NULL);
- sState = OT_RADIO_STATE_DISABLED;
- }
-
- return OT_ERROR_NONE;
-}
-
-otError otPlatRadioSleep(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otError error = OT_ERROR_INVALID_STATE;
-
- if (sState == OT_RADIO_STATE_SLEEP || sState == OT_RADIO_STATE_RECEIVE)
- {
- otLogDebgPlat("State=OT_RADIO_STATE_SLEEP", NULL);
- error = OT_ERROR_NONE;
- sState = OT_RADIO_STATE_SLEEP;
- disableReceiver();
- }
-
- return error;
-}
-
-otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otError error = OT_ERROR_INVALID_STATE;
-
- if (sState != OT_RADIO_STATE_DISABLED)
- {
- otLogDebgPlat("State=OT_RADIO_STATE_RECEIVE", NULL);
-
- error = OT_ERROR_NONE;
- sState = OT_RADIO_STATE_RECEIVE;
- setChannel(aChannel);
- sReceiveFrame.mChannel = aChannel;
- enableReceiver();
- }
-
- return error;
-}
-
-static void setupTransmit(otRadioFrame *aFrame)
-{
- int i;
-
- // wait for current TX operation to complete, if any.
- while (HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE)
- ;
-
- // flush txfifo
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHTX;
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHTX;
-
- // frame length
- HWREG(RFCORE_SFR_RFDATA) = aFrame->mLength;
-
- // frame data
- for (i = 0; i < aFrame->mLength; i++)
- {
- HWREG(RFCORE_SFR_RFDATA) = aFrame->mPsdu[i];
- }
-
- setChannel(aFrame->mChannel);
-}
-
-otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otError error = OT_ERROR_INVALID_STATE;
-
- if (sState == OT_RADIO_STATE_RECEIVE)
- {
- int i;
-
- error = OT_ERROR_NONE;
- sState = OT_RADIO_STATE_TRANSMIT;
- sTransmitError = OT_ERROR_NONE;
-
- setupTransmit(aFrame);
-
- // Set up a counter to inform us if we get stuck.
- i = 1000000;
-
- // Wait for radio to enter receive state.
- while ((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_RX_ACTIVE) == 0)
- {
- // Count down the cycles, and emit a message if we get to zero.
- // Ideally, we should never get there!
- if (i)
- {
- i--;
- }
- else
- {
- otLogCritPlat("Radio is stuck!!! FSMSTAT0=0x%08x FSMSTAT1=0x%08x RFERRF=0x%08x",
- HWREG(RFCORE_XREG_FSMSTAT0), HWREG(RFCORE_XREG_FSMSTAT1), HWREG(RFCORE_SFR_RFERRF));
- i = 1000000;
- }
-
- // Ensure we haven't overflowed the RX buffer in the mean time, as this
- // will cause a deadlock here otherwise. Similarly, if we see an aborted
- // RX, handle that here too to prevent deadlock.
- if (HWREG(RFCORE_SFR_RFERRF) & (RFCORE_SFR_RFERRF_RXOVERF | RFCORE_SFR_RFERRF_RXABO))
- {
- if (HWREG(RFCORE_SFR_RFERRF) & RFCORE_SFR_RFERRF_RXOVERF)
- {
- otLogCritPlat("RX Buffer Overflow detected", NULL);
- }
-
- if (HWREG(RFCORE_SFR_RFERRF) & RFCORE_SFR_RFERRF_RXABO)
- {
- otLogCritPlat("Aborted RX detected", NULL);
- }
-
- // Flush the RX buffer
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
- }
-
- // Check for idle state. After flushing the RX buffer, we may wind up here.
- if (!(HWREG(RFCORE_XREG_FSMSTAT1) & (RFCORE_XREG_FSMSTAT1_TX_ACTIVE | RFCORE_XREG_FSMSTAT1_RX_ACTIVE)))
- {
- otLogCritPlat("Idle state detected", NULL);
-
- // In this case, the state of our driver mis-matches our state. So force
- // matters by clearing our channel variable and calling setChannel. This
- // should bring our radio into the RX state, which should allow us to go
- // into TX.
- sChannel = 0;
- setupTransmit(aFrame);
- }
- }
-
- // wait for valid rssi
- while ((HWREG(RFCORE_XREG_RSSISTAT) & RFCORE_XREG_RSSISTAT_RSSI_VALID) == 0)
- ;
-
- otEXPECT_ACTION(((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_CCA) &&
- !((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_SFD))),
- sTransmitError = OT_ERROR_CHANNEL_ACCESS_FAILURE);
-
- // begin transmit
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_TXON;
-
- otPlatRadioTxStarted(aInstance, aFrame);
-
- while (HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_TX_ACTIVE)
- ;
-
- otLogDebgPlat("Transmitted %d bytes", aFrame->mLength);
- }
-
-exit:
- return error;
-}
-
-otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- return &sTransmitFrame;
-}
-
-int8_t otPlatRadioGetRssi(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- int8_t rssi = OT_RADIO_RSSI_INVALID;
-
- if ((HWREG(RFCORE_XREG_RSSISTAT) & RFCORE_XREG_RSSISTAT_RSSI_VALID) != 0)
- {
- rssi = HWREG(RFCORE_XREG_RSSI) & 0xff;
-
- if (rssi > cc2538RadioGetRssiOffset() - 128)
- {
- rssi -= cc2538RadioGetRssiOffset();
- }
- else
- {
- rssi = -128;
- }
- }
-
- return rssi;
-}
-
-otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- return OT_RADIO_CAPS_ENERGY_SCAN;
-}
-
-static bool cc2538RadioGetPromiscuous(void)
-{
- return (HWREG(RFCORE_XREG_FRMFILT0) & RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN) == 0;
-}
-
-bool otPlatRadioGetPromiscuous(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- return cc2538RadioGetPromiscuous();
-}
-
-static int8_t cc2538RadioGetRssiOffset(void)
-{
-#if OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
- if (cc2538RadioGetHgm())
- {
- return CC2592_RSSI_OFFSET_HGM;
- }
- else
- {
- return CC2592_RSSI_OFFSET_LGM;
- }
-#else // OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
- return CC2538_RSSI_OFFSET;
-#endif // OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
-}
-
-void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otLogInfoPlat("PromiscuousMode=%d", aEnable ? 1 : 0);
-
- if (aEnable)
- {
- HWREG(RFCORE_XREG_FRMFILT0) &= ~RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN;
- }
- else
- {
- HWREG(RFCORE_XREG_FRMFILT0) |= RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN;
- }
-}
-
-static void readFrame(void)
-{
- uint8_t length;
- uint8_t crcCorr;
- int i;
-
- /*
- * There is already a frame present in the buffer, return early so
- * we do not overwrite it (hopefully we'll catch it on the next run).
- */
- otEXPECT(sReceiveFrame.mLength == 0);
-
- otEXPECT(sState == OT_RADIO_STATE_RECEIVE || sState == OT_RADIO_STATE_TRANSMIT);
- otEXPECT((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_FIFOP) != 0);
-
- // read length
- length = HWREG(RFCORE_SFR_RFDATA);
- otEXPECT(IEEE802154_MIN_LENGTH <= length && length <= IEEE802154_MAX_LENGTH);
-
-#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
-#error Time sync requires the timestamp of SFD rather than that of rx done!
-#else
- // Timestamp
- if (cc2538RadioGetPromiscuous())
-#endif
- {
- // The current driver only supports milliseconds resolution.
- sReceiveFrame.mInfo.mRxInfo.mTimestamp = otPlatAlarmMilliGetNow() * 1000;
- }
-
- // read psdu
- for (i = 0; i < length - 2; i++)
- {
- sReceiveFrame.mPsdu[i] = HWREG(RFCORE_SFR_RFDATA);
- }
-
- sReceiveFrame.mInfo.mRxInfo.mRssi = (int8_t)HWREG(RFCORE_SFR_RFDATA) - cc2538RadioGetRssiOffset();
- crcCorr = HWREG(RFCORE_SFR_RFDATA);
-
- if (crcCorr & CC2538_CRC_BIT_MASK)
- {
- sReceiveFrame.mLength = length;
- sReceiveFrame.mInfo.mRxInfo.mLqi = crcCorr & CC2538_LQI_BIT_MASK;
-
- if (length > IEEE802154_ACK_LENGTH)
- {
- // Set ACK FP flag for the received frame according to whether SRC_MATCH_FOUND was triggered just before
- // if SRC MATCH is not enabled, SRC_MATCH_FOUND is not triggered and all ACK FP is always set
- sReceiveFrame.mInfo.mRxInfo.mAckedWithFramePending =
- cc2538SrcMatchEnabled() ? cc2538GetSrcMatchFoundIntFlag() : true;
- }
- }
- else
- {
- // resets rxfifo
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
-#if OPENTHREAD_CONFIG_LOG_PLATFORM && OPENTHREAD_CONFIG_CC2538_USE_RADIO_RX_INTERRUPT
- // Debugging _and_ logging are enabled, it may not be safe to do
- // logging if we're in the interrupt context, so just stash the
- // length and do the logging later.
- sDroppedFrameLength = length;
-#else
- otLogDebgPlat("Dropping %d received bytes (Invalid CRC)", length);
-#endif
- }
-
- // check for rxfifo overflow
- if ((HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_FIFOP) != 0 &&
- (HWREG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_FIFO) == 0)
- {
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
- HWREG(RFCORE_SFR_RFST) = RFCORE_SFR_RFST_INSTR_FLUSHRX;
- }
-
-exit:
- return;
-}
-
-void cc2538RadioProcess(otInstance *aInstance)
-{
-#if OPENTHREAD_CONFIG_CC2538_USE_RADIO_RX_INTERRUPT
- // Disable the receive interrupt so that sReceiveFrame doesn't get
- // blatted by the interrupt handler while we're polling.
- HWREG(RFCORE_XREG_RFIRQM0) &= ~RFCORE_XREG_RFIRQM0_RXPKTDONE;
-#endif
-
- readFrame();
-
-#if OPENTHREAD_CONFIG_LOG_PLATFORM && OPENTHREAD_CONFIG_CC2538_USE_RADIO_RX_INTERRUPT
- if (sDroppedFrameLength != 0)
- {
- otLogDebgPlat("Dropping %d received bytes (Invalid CRC)", sDroppedFrameLength);
- sDroppedFrameLength = 0;
- }
-#endif
-
- if ((sState == OT_RADIO_STATE_RECEIVE && sReceiveFrame.mLength > 0) ||
- (sState == OT_RADIO_STATE_TRANSMIT && sReceiveFrame.mLength > IEEE802154_ACK_LENGTH))
- {
-#if OPENTHREAD_CONFIG_DIAG_ENABLE
-
- if (otPlatDiagModeGet())
- {
- otPlatDiagRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError);
- }
- else
-#endif
- {
- // signal MAC layer for each received frame if promiscuous is enabled
- // otherwise only signal MAC layer for non-ACK frame
- if (((HWREG(RFCORE_XREG_FRMFILT0) & RFCORE_XREG_FRMFILT0_FRAME_FILTER_EN) == 0) ||
- (sReceiveFrame.mLength > IEEE802154_ACK_LENGTH))
- {
- otLogDebgPlat("Received %d bytes", sReceiveFrame.mLength);
- otPlatRadioReceiveDone(aInstance, &sReceiveFrame, sReceiveError);
- }
- }
- }
-
- if (sState == OT_RADIO_STATE_TRANSMIT)
- {
- if (sTransmitError != OT_ERROR_NONE || (sTransmitFrame.mPsdu[0] & IEEE802154_ACK_REQUEST) == 0)
- {
- if (sTransmitError != OT_ERROR_NONE)
- {
- otLogDebgPlat("Transmit failed ErrorCode=%d", sTransmitError);
- }
-
- sState = OT_RADIO_STATE_RECEIVE;
-
-#if OPENTHREAD_CONFIG_DIAG_ENABLE
-
- if (otPlatDiagModeGet())
- {
- otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame, sTransmitError);
- }
- else
-#endif
- {
- otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL, sTransmitError);
- }
- }
- else if (sReceiveFrame.mLength == IEEE802154_ACK_LENGTH &&
- (sReceiveFrame.mPsdu[0] & IEEE802154_FRAME_TYPE_MASK) == IEEE802154_FRAME_TYPE_ACK &&
- (sReceiveFrame.mPsdu[IEEE802154_DSN_OFFSET] == sTransmitFrame.mPsdu[IEEE802154_DSN_OFFSET]))
- {
- sState = OT_RADIO_STATE_RECEIVE;
-
- otPlatRadioTxDone(aInstance, &sTransmitFrame, &sReceiveFrame, sTransmitError);
- }
- }
-
- sReceiveFrame.mLength = 0;
-
-#if OPENTHREAD_CONFIG_CC2538_USE_RADIO_RX_INTERRUPT
- // Turn the receive interrupt handler back on now the buffer is clear.
- HWREG(RFCORE_XREG_RFIRQM0) |= RFCORE_XREG_RFIRQM0_RXPKTDONE;
-#endif
-}
-
-void RFCoreRxTxIntHandler(void)
-{
-#if OPENTHREAD_CONFIG_CC2538_USE_RADIO_RX_INTERRUPT
- if (HWREG(RFCORE_SFR_RFIRQF0) & RFCORE_SFR_RFIRQF0_RXPKTDONE)
- {
- readFrame();
-
- if (sReceiveFrame.mLength > 0)
- {
- // A frame has been received, disable the interrupt handler
- // until the main loop has dealt with this previous frame,
- // otherwise we might overwrite it whilst it is being read.
- HWREG(RFCORE_XREG_RFIRQM0) &= ~RFCORE_XREG_RFIRQM0_RXPKTDONE;
- }
- }
-#endif
-
- HWREG(RFCORE_SFR_RFIRQF0) = 0;
-}
-
-void RFCoreErrIntHandler(void)
-{
- HWREG(RFCORE_SFR_RFERRF) = 0;
-}
-
-uint32_t getSrcMatchEntriesEnableStatus(bool aShort)
-{
- uint32_t status = 0;
- uint32_t *addr = aShort ? (uint32_t *)RFCORE_XREG_SRCSHORTEN0 : (uint32_t *)RFCORE_XREG_SRCEXTEN0;
-
- for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_ENABLE_STATUS_SIZE; i++)
- {
- status |= HWREG(addr++) << (i * 8);
- }
-
- return status;
-}
-
-int8_t findSrcMatchShortEntry(uint16_t aShortAddress)
-{
- int8_t entry = -1;
- uint16_t shortAddr;
- uint32_t bitMask;
- uint32_t *addr = NULL;
- uint32_t status = getSrcMatchEntriesEnableStatus(true);
-
- for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_SHORT_ENTRIES; i++)
- {
- bitMask = 0x00000001 << i;
-
- if ((status & bitMask) == 0)
- {
- continue;
- }
-
- addr = (uint32_t *)RFCORE_FFSM_SRCADDRESS_TABLE + (i * RFCORE_XREG_SRCMATCH_SHORT_ENTRY_OFFSET);
-
- shortAddr = HWREG(addr + 2);
- shortAddr |= HWREG(addr + 3) << 8;
-
- if ((shortAddr == aShortAddress))
- {
- entry = i;
- break;
- }
- }
-
- return entry;
-}
-
-int8_t findSrcMatchExtEntry(const otExtAddress *aExtAddress)
-{
- int8_t entry = -1;
- uint32_t bitMask;
- uint32_t *addr = NULL;
- uint32_t status = getSrcMatchEntriesEnableStatus(false);
-
- for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_EXT_ENTRIES; i++)
- {
- uint8_t j = 0;
- bitMask = 0x00000001 << 2 * i;
-
- if ((status & bitMask) == 0)
- {
- continue;
- }
-
- addr = (uint32_t *)RFCORE_FFSM_SRCADDRESS_TABLE + (i * RFCORE_XREG_SRCMATCH_EXT_ENTRY_OFFSET);
-
- for (j = 0; j < sizeof(otExtAddress); j++)
- {
- if (HWREG(addr + j) != aExtAddress->m8[j])
- {
- break;
- }
- }
-
- if (j == sizeof(otExtAddress))
- {
- entry = i;
- break;
- }
- }
-
- return entry;
-}
-
-void setSrcMatchEntryEnableStatus(bool aShort, uint8_t aEntry, bool aEnable)
-{
- uint8_t entry = aShort ? aEntry : (2 * aEntry);
- uint8_t index = entry / 8;
- uint32_t *addrEn = aShort ? (uint32_t *)RFCORE_XREG_SRCSHORTEN0 : (uint32_t *)RFCORE_XREG_SRCEXTEN0;
- uint32_t *addrAutoPendEn = aShort ? (uint32_t *)RFCORE_FFSM_SRCSHORTPENDEN0 : (uint32_t *)RFCORE_FFSM_SRCEXTPENDEN0;
- uint32_t bitMask = 0x00000001;
-
- if (aEnable)
- {
- HWREG(addrEn + index) |= (bitMask) << (entry % 8);
- HWREG(addrAutoPendEn + index) |= (bitMask) << (entry % 8);
- }
- else
- {
- HWREG(addrEn + index) &= ~((bitMask) << (entry % 8));
- HWREG(addrAutoPendEn + index) &= ~((bitMask) << (entry % 8));
- }
-}
-
-int8_t findSrcMatchAvailEntry(bool aShort)
-{
- int8_t entry = -1;
- uint32_t bitMask;
- uint32_t shortEnableStatus = getSrcMatchEntriesEnableStatus(true);
- uint32_t extEnableStatus = getSrcMatchEntriesEnableStatus(false);
-
- otLogDebgPlat("Short enable status: 0x%x", shortEnableStatus);
- otLogDebgPlat("Ext enable status: 0x%x", extEnableStatus);
-
- if (aShort)
- {
- bitMask = 0x00000001;
-
- for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_SHORT_ENTRIES; i++)
- {
- if ((extEnableStatus & bitMask) == 0)
- {
- if ((shortEnableStatus & bitMask) == 0)
- {
- entry = i;
- break;
- }
- }
-
- if (i % 2 == 1)
- {
- extEnableStatus = extEnableStatus >> 2;
- }
-
- shortEnableStatus = shortEnableStatus >> 1;
- }
- }
- else
- {
- bitMask = 0x00000003;
-
- for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_EXT_ENTRIES; i++)
- {
- if (((extEnableStatus | shortEnableStatus) & bitMask) == 0)
- {
- entry = i;
- break;
- }
-
- extEnableStatus = extEnableStatus >> 2;
- shortEnableStatus = shortEnableStatus >> 2;
- }
- }
-
- return entry;
-}
-
-void cc2538EnergyScanTimerHandler(void)
-{
- int8_t rssi = otPlatRadioGetRssi(sInstance);
-
- disableReceiver();
-
- HWREG(RFCORE_XREG_FRMCTRL0) &= ~RFCORE_XREG_FRMCTRL0_ENERGY_SCAN;
- HWREG(RFCORE_XREG_FREQCTRL) = 11 + (sChannel - 11) * 5;
-
- if (sIsReceiverEnabled)
- {
- enableReceiver();
- }
-
- otPlatRadioEnergyScanDone(sInstance, rssi);
-}
-
-void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otLogInfoPlat("EnableSrcMatch=%d", aEnable ? 1 : 0);
-
- if (aEnable)
- {
- // only set FramePending when ack for data poll if there are queued messages
- // for entries in the source match table.
- HWREG(RFCORE_XREG_FRMCTRL1) &= ~RFCORE_XREG_FRMCTRL1_PENDING_OR;
- }
- else
- {
- // set FramePending for all ack.
- HWREG(RFCORE_XREG_FRMCTRL1) |= RFCORE_XREG_FRMCTRL1_PENDING_OR;
- }
-}
-
-otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otError error = OT_ERROR_NONE;
- int8_t entry = findSrcMatchAvailEntry(true);
- uint32_t *addr = (uint32_t *)RFCORE_FFSM_SRCADDRESS_TABLE;
-
- otLogDebgPlat("Add ShortAddr entry: %d", entry);
-
- otEXPECT_ACTION(entry >= 0, error = OT_ERROR_NO_BUFS);
-
- addr += (entry * RFCORE_XREG_SRCMATCH_SHORT_ENTRY_OFFSET);
-
- HWREG(addr++) = HWREG(RFCORE_FFSM_PAN_ID0);
- HWREG(addr++) = HWREG(RFCORE_FFSM_PAN_ID1);
- HWREG(addr++) = aShortAddress & 0xFF;
- HWREG(addr++) = aShortAddress >> 8;
-
- setSrcMatchEntryEnableStatus(true, (uint8_t)(entry), true);
-
-exit:
- return error;
-}
-
-otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otError error = OT_ERROR_NONE;
- int8_t entry = findSrcMatchAvailEntry(false);
- uint32_t *addr = (uint32_t *)RFCORE_FFSM_SRCADDRESS_TABLE;
-
- otLogDebgPlat("Add ExtAddr entry: %d", entry);
-
- otEXPECT_ACTION(entry >= 0, error = OT_ERROR_NO_BUFS);
-
- addr += (entry * RFCORE_XREG_SRCMATCH_EXT_ENTRY_OFFSET);
-
- for (uint8_t i = 0; i < sizeof(otExtAddress); i++)
- {
- HWREG(addr++) = aExtAddress->m8[i];
- }
-
- setSrcMatchEntryEnableStatus(false, (uint8_t)(entry), true);
-
-exit:
- return error;
-}
-
-otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otError error = OT_ERROR_NONE;
- int8_t entry = findSrcMatchShortEntry(aShortAddress);
-
- otLogDebgPlat("Clear ShortAddr entry: %d", entry);
-
- otEXPECT_ACTION(entry >= 0, error = OT_ERROR_NO_ADDRESS);
-
- setSrcMatchEntryEnableStatus(true, (uint8_t)(entry), false);
-
-exit:
- return error;
-}
-
-otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otError error = OT_ERROR_NONE;
- int8_t entry = findSrcMatchExtEntry(aExtAddress);
-
- otLogDebgPlat("Clear ExtAddr entry: %d", entry);
-
- otEXPECT_ACTION(entry >= 0, error = OT_ERROR_NO_ADDRESS);
-
- setSrcMatchEntryEnableStatus(false, (uint8_t)(entry), false);
-
-exit:
- return error;
-}
-
-void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- uint32_t *addrEn = (uint32_t *)RFCORE_XREG_SRCSHORTEN0;
- uint32_t *addrAutoPendEn = (uint32_t *)RFCORE_FFSM_SRCSHORTPENDEN0;
-
- otLogDebgPlat("Clear ShortAddr entries", NULL);
-
- for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_ENABLE_STATUS_SIZE; i++)
- {
- HWREG(addrEn++) = 0;
- HWREG(addrAutoPendEn++) = 0;
- }
-}
-
-void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- uint32_t *addrEn = (uint32_t *)RFCORE_XREG_SRCEXTEN0;
- uint32_t *addrAutoPendEn = (uint32_t *)RFCORE_FFSM_SRCEXTPENDEN0;
-
- otLogDebgPlat("Clear ExtAddr entries", NULL);
-
- for (uint8_t i = 0; i < RFCORE_XREG_SRCMATCH_ENABLE_STATUS_SIZE; i++)
- {
- HWREG(addrEn++) = 0;
- HWREG(addrAutoPendEn++) = 0;
- }
-}
-
-otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otLogInfoPlat("ScanChannel=%d", aScanChannel);
-
- if (aScanChannel != sChannel)
- {
- if (sIsReceiverEnabled)
- {
- disableReceiver();
- }
-
- HWREG(RFCORE_XREG_FREQCTRL) = 11 + (aScanChannel - 11) * 5;
-
- enableReceiver();
- }
- else if (!sIsReceiverEnabled)
- {
- enableReceiver();
- }
-
- // Collect peak signal strength
- HWREG(RFCORE_XREG_FRMCTRL0) |= RFCORE_XREG_FRMCTRL0_ENERGY_SCAN;
-
- cc2538SetTimer(OT_CC2538_TIMER_ENERGY_SCAN, aScanDuration);
-
- return OT_ERROR_NONE;
-}
-
-otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- otError error = OT_ERROR_NONE;
-
- otEXPECT_ACTION(aPower != NULL, error = OT_ERROR_INVALID_ARGS);
- *aPower = sTxPower;
-
-exit:
- return error;
-}
-
-otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
- setTxPower(aPower);
- return OT_ERROR_NONE;
-}
-
-otError otPlatRadioGetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t *aThreshold)
-{
- OT_UNUSED_VARIABLE(aInstance);
- OT_UNUSED_VARIABLE(aThreshold);
-
- return OT_ERROR_NOT_IMPLEMENTED;
-}
-
-otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aThreshold)
-{
- OT_UNUSED_VARIABLE(aInstance);
- OT_UNUSED_VARIABLE(aThreshold);
-
- return OT_ERROR_NOT_IMPLEMENTED;
-}
-
-int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-
-#if OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
- if (cc2538RadioGetHgm())
- {
- return CC2592_RECEIVE_SENSITIVITY_HGM;
- }
- else
- {
- return CC2592_RECEIVE_SENSITIVITY_LGM;
- }
-#else // OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
- return CC2538_RECEIVE_SENSITIVITY;
-#endif // OPENTHREAD_CONFIG_CC2538_WITH_CC2592 && OPENTHREAD_CONFIG_CC2592_USE_HGM
-}
diff --git a/examples/platforms/cc2538/rom-utility.h b/examples/platforms/cc2538/rom-utility.h
deleted file mode 100644
index d0686efdee7..00000000000
--- a/examples/platforms/cc2538/rom-utility.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ROM_UTILITY_H_
-#define ROM_UTILITY_H_
-
-#define ROM_API_TABLE_ADDR 0x00000048
-
-typedef uint32_t (*volatile FPTR_CRC32_T)(uint8_t * /*pData*/, uint32_t /*byteCount*/);
-typedef uint32_t (*volatile FPTR_GETFLSIZE_T)(void);
-typedef uint32_t (*volatile FPTR_GETCHIPID_T)(void);
-typedef int32_t (*volatile FPTR_PAGEERASE_T)(uint32_t /*FlashAddr*/, uint32_t /*Size*/);
-typedef int32_t (*volatile FPTR_PROGFLASH_T)(uint32_t * /*pRamData*/, uint32_t /*FlashAdr*/, uint32_t /*ByteCount*/);
-typedef void (*volatile FPTR_RESETDEV_T)(void);
-typedef void *(*volatile FPTR_MEMSET_T)(void * /*s*/, int32_t /*c*/, uint32_t /*n*/);
-typedef void *(*volatile FPTR_MEMCPY_T)(void * /*s1*/, const void * /*s2*/, uint32_t /*n*/);
-typedef int32_t (*volatile FPTR_MEMCMP_T)(const void * /*s1*/, const void * /*s2*/, uint32_t /*n*/);
-typedef void *(*volatile FPTR_MEMMOVE_T)(void * /*s1*/, const void * /*s2*/, uint32_t /*n*/);
-
-typedef struct
-{
- FPTR_CRC32_T Crc32;
- FPTR_GETFLSIZE_T GetFlashSize;
- FPTR_GETCHIPID_T GetChipId;
- FPTR_PAGEERASE_T PageErase;
- FPTR_PROGFLASH_T ProgramFlash;
- FPTR_RESETDEV_T ResetDevice;
- FPTR_MEMSET_T memset;
- FPTR_MEMCPY_T memcpy;
- FPTR_MEMCMP_T memcmp;
- FPTR_MEMMOVE_T memmove;
-} ROM_API_T;
-
-// clang-format off
-
-#define P_ROM_API ((ROM_API_T*)ROM_API_TABLE_ADDR)
-
-#define ROM_Crc32(a,b) P_ROM_API->Crc32(a,b)
-#define ROM_GetFlashSize() P_ROM_API->GetFlashSize()
-#define ROM_GetChipId() P_ROM_API->GetChipId()
-#define ROM_PageErase(a,b) P_ROM_API->PageErase(a,b)
-#define ROM_ProgramFlash(a,b,c) P_ROM_API->ProgramFlash(a,b,c)
-#define ROM_ResetDevice() P_ROM_API->ResetDevice()
-#define ROM_Memset(a,b,c) P_ROM_API->memset(a,b,c)
-#define ROM_Memcpy(a,b,c) P_ROM_API->memcpy(a,b,c)
-#define ROM_Memcmp(a,b,c) P_ROM_API->memcmp(a,b,c)
-#define ROM_Memmove(a,b,c) P_ROM_API->memmove(a,b,c)
-
-// clang-format on
-
-#endif // ROM_UTILITY_H_
diff --git a/examples/platforms/cc2538/startup-gcc.c b/examples/platforms/cc2538/startup-gcc.c
deleted file mode 100644
index f174bfa099b..00000000000
--- a/examples/platforms/cc2538/startup-gcc.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file
- * This file implements gcc-specific startup code for the cc2538.
- */
-
-#include
-#include
-
-#include "cc2538-reg.h"
-
-extern uint8_t _ldata;
-extern uint8_t _data;
-extern uint8_t _edata;
-extern uint8_t _bss;
-extern uint8_t _ebss;
-extern uint8_t _init_array;
-extern uint8_t _einit_array;
-
-__extension__ typedef int __guard __attribute__((mode(__DI__)));
-
-int __cxa_guard_acquire(__guard *g)
-{
- return !*(char *)(g);
-}
-
-void __cxa_guard_release(__guard *g)
-{
- *(char *)g = 1;
-}
-
-void __cxa_guard_abort(__guard *g)
-{
- (void)g;
-}
-
-void __cxa_pure_virtual(void)
-{
- while (1)
- ;
-}
-
-void IntDefaultHandler(void);
-void ResetHandler(void);
-
-extern void SysTick_Handler(void);
-extern void UART0IntHandler(void);
-extern void RFCoreRxTxIntHandler(void);
-extern void RFCoreErrIntHandler(void);
-extern void main(void);
-
-static uint64_t stack[640] __attribute__((section(".stack")));
-
-__attribute__((section(".vectors"), used)) void (*const vectors[])(void) = {
- (void (*)(void))((unsigned long)stack + sizeof(stack)), // Initial Stack Pointer
- ResetHandler, // 1 The reset handler
- ResetHandler, // 2 The NMI handler
- IntDefaultHandler, // 3 The hard fault handler
- IntDefaultHandler, // 4 The MPU fault handler
- IntDefaultHandler, // 5 The bus fault handler
- IntDefaultHandler, // 6 The usage fault handler
- 0, // 7 Reserved
- 0, // 8 Reserved
- 0, // 9 Reserved
- 0, // 10 Reserved
- IntDefaultHandler, // 11 SVCall handler
- IntDefaultHandler, // 12 Debug monitor handler
- 0, // 13 Reserved
- IntDefaultHandler, // 14 The PendSV handler
- SysTick_Handler, // 15 The SysTick handler
- IntDefaultHandler, // 16 GPIO Port A
- IntDefaultHandler, // 17 GPIO Port B
- IntDefaultHandler, // 18 GPIO Port C
- IntDefaultHandler, // 19 GPIO Port D
- 0, // 20 none
- UART0IntHandler, // 21 UART0 Rx and Tx
- IntDefaultHandler, // 22 UART1 Rx and Tx
- IntDefaultHandler, // 23 SSI0 Rx and Tx
- IntDefaultHandler, // 24 I2C Master and Slave
- 0, // 25 Reserved
- 0, // 26 Reserved
- 0, // 27 Reserved
- 0, // 28 Reserved
- 0, // 29 Reserved
- IntDefaultHandler, // 30 ADC Sequence 0
- 0, // 31 Reserved
- 0, // 32 Reserved
- 0, // 33 Reserved
- IntDefaultHandler, // 34 Watchdog timer, timer 0
- IntDefaultHandler, // 35 Timer 0 subtimer A
- IntDefaultHandler, // 36 Timer 0 subtimer B
- IntDefaultHandler, // 37 Timer 1 subtimer A
- IntDefaultHandler, // 38 Timer 1 subtimer B
- IntDefaultHandler, // 39 Timer 2 subtimer A
- IntDefaultHandler, // 40 Timer 2 subtimer B
- IntDefaultHandler, // 41 Analog Comparator 0
- RFCoreRxTxIntHandler, // 42 RFCore Rx/Tx
- RFCoreErrIntHandler, // 43 RFCore Error
- IntDefaultHandler, // 44 IcePick
- IntDefaultHandler, // 45 FLASH Control
- IntDefaultHandler, // 46 AES
- IntDefaultHandler, // 47 PKA
- IntDefaultHandler, // 48 Sleep Timer
- IntDefaultHandler, // 49 MacTimer
- IntDefaultHandler, // 50 SSI1 Rx and Tx
- IntDefaultHandler, // 51 Timer 3 subtimer A
- IntDefaultHandler, // 52 Timer 3 subtimer B
- 0, // 53 Reserved
- 0, // 54 Reserved
- 0, // 55 Reserved
- 0, // 56 Reserved
- 0, // 57 Reserved
- 0, // 58 Reserved
- 0, // 59 Reserved
- IntDefaultHandler, // 60 USB 2538
- 0, // 61 Reserved
- IntDefaultHandler, // 62 uDMA
- IntDefaultHandler, // 63 uDMA Error
-};
-
-void IntDefaultHandler(void)
-{
- while (1)
- ;
-}
-
-// clang-format off
-
-#define FLASH_CCA_BOOTLDR_CFG_DISABLE 0xEFFFFFFF ///< Disable backdoor function
-#define FLASH_CCA_BOOTLDR_CFG_ENABLE 0xF0FFFFFF ///< Enable backdoor function
-#define FLASH_CCA_BOOTLDR_CFG_ACTIVE_HIGH 0x08000000 ///< Selected pin on pad A active high
-#define FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_M 0x07000000 ///< Selected pin on pad A mask
-#define FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S 24 ///< Selected pin on pad A shift
-#define FLASH_CCA_IMAGE_VALID 0x00000000 ///< Indicates valid image in flash
-
-#define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN 3 ///< Select Button on SmartRF06 Eval Board
-
-// clang-format on
-
-typedef struct
-{
- uint32_t ui32BootldrCfg;
- uint32_t ui32ImageValid;
- uint32_t ui32ImageVectorAddr;
- uint8_t ui8lock[32];
-} flash_cca_lock_page_t;
-
-__attribute__((__section__(".flashcca"), used)) const flash_cca_lock_page_t flash_cca_lock_page = {
- FLASH_CCA_BOOTLDR_CFG_ENABLE | (FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN << FLASH_CCA_BOOTLDR_CFG_PORT_A_PIN_S),
- FLASH_CCA_IMAGE_VALID,
- (uint32_t)&vectors,
- {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}};
-
-typedef void (*init_fn_t)(void);
-
-void ResetHandler(void)
-{
- HWREG(SYS_CTRL_EMUOVR) = 0xFF;
-
- // configure clocks
- HWREG(SYS_CTRL_CLOCK_CTRL) |= SYS_CTRL_CLOCK_CTRL_AMP_DET;
- HWREG(SYS_CTRL_CLOCK_CTRL) = SYS_CTRL_SYSDIV_32MHZ;
-
- // alternate map
- HWREG(SYS_CTRL_I_MAP) |= SYS_CTRL_I_MAP_ALTMAP;
-
- // copy the data segment initializers from flash to SRAM
- memcpy(&_data, &_ldata, &_edata - &_data);
-
- // zero-fill the bss segment
- memset(&_bss, 0, &_ebss - &_bss);
-
- // C++ runtime initialization (BSS, Data, relocation, etc.)
- init_fn_t *fp;
-
- for (fp = (init_fn_t *)&_init_array; fp < (init_fn_t *)&_einit_array; fp++)
- {
- (*fp)();
- }
-
- // call the application's entry point
- main();
-
- // end here if main() returns
- while (1)
- ;
-}
diff --git a/examples/platforms/cc2538/uart.c b/examples/platforms/cc2538/uart.c
deleted file mode 100644
index 3325c990427..00000000000
--- a/examples/platforms/cc2538/uart.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @file
- * This file implements the OpenThread platform abstraction for UART communication.
- *
- */
-
-#include
-#include
-
-#include
-#include
-#include
-
-#include
-#include
-
-#include "platform-cc2538.h"
-#include "utils/code_utils.h"
-#include "utils/uart.h"
-
-enum
-{
- kPlatformClock = 32000000,
- kBaudRate = 115200,
- kReceiveBufferSize = 128,
-};
-
-extern void UART0IntHandler(void);
-
-static void processReceive(void);
-static void processTransmit(void);
-
-static const uint8_t *sTransmitBuffer = NULL;
-static uint16_t sTransmitLength = 0;
-
-typedef struct RecvBuffer
-{
- // The data buffer
- uint8_t mBuffer[kReceiveBufferSize];
- // The offset of the first item written to the list.
- uint16_t mHead;
- // The offset of the next item to be written to the list.
- uint16_t mTail;
-} RecvBuffer;
-
-static RecvBuffer sReceive;
-
-static void enable_uart_clocks(void)
-{
- static int uart_clocks_done = 0;
-
- if (uart_clocks_done)
- {
- return;
- }
-
- uart_clocks_done = 1;
-
-#if OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
- HWREG(SYS_CTRL_RCGCUART) = (SYS_CTRL_RCGCUART_UART0 | SYS_CTRL_RCGCUART_UART1);
- HWREG(SYS_CTRL_SCGCUART) = (SYS_CTRL_SCGCUART_UART0 | SYS_CTRL_SCGCUART_UART1);
- HWREG(SYS_CTRL_DCGCUART) = (SYS_CTRL_DCGCUART_UART0 | SYS_CTRL_DCGCUART_UART1);
-#else
- HWREG(SYS_CTRL_RCGCUART) = SYS_CTRL_RCGCUART_UART0;
- HWREG(SYS_CTRL_SCGCUART) = SYS_CTRL_SCGCUART_UART0;
- HWREG(SYS_CTRL_DCGCUART) = SYS_CTRL_DCGCUART_UART0;
-#endif
-}
-
-otError otPlatUartEnable(void)
-{
- uint32_t div;
-
- sReceive.mHead = 0;
- sReceive.mTail = 0;
-
- // clock
- enable_uart_clocks();
-
- HWREG(UART0_BASE + UART_O_CC) = 0;
-
- // tx pin
- HWREG(IOC_PA1_SEL) = IOC_MUX_OUT_SEL_UART0_TXD;
- HWREG(IOC_PA1_OVER) = IOC_OVERRIDE_OE;
- HWREG(GPIO_A_BASE + GPIO_O_AFSEL) |= GPIO_PIN_1;
-
- // rx pin
- HWREG(IOC_UARTRXD_UART0) = IOC_PAD_IN_SEL_PA0;
- HWREG(IOC_PA0_OVER) = IOC_OVERRIDE_DIS;
- HWREG(GPIO_A_BASE + GPIO_O_AFSEL) |= GPIO_PIN_0;
-
- HWREG(UART0_BASE + UART_O_CTL) = 0;
-
- // baud rate
- div = (((kPlatformClock * 8) / kBaudRate) + 1) / 2;
- HWREG(UART0_BASE + UART_O_IBRD) = div / 64;
- HWREG(UART0_BASE + UART_O_FBRD) = div % 64;
- HWREG(UART0_BASE + UART_O_LCRH) = UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE;
-
- // configure interrupts
- HWREG(UART0_BASE + UART_O_IM) |= UART_IM_RXIM | UART_IM_RTIM;
-
- // enable
- HWREG(UART0_BASE + UART_O_CTL) = UART_CTL_UARTEN | UART_CTL_TXE | UART_CTL_RXE;
-
- // enable interrupts
- HWREG(NVIC_EN0) = 1 << ((INT_UART0 - 16) & 31);
-
- return OT_ERROR_NONE;
-}
-
-otError otPlatUartDisable(void)
-{
- return OT_ERROR_NONE;
-}
-
-otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
-{
- otError error = OT_ERROR_NONE;
-
- otEXPECT_ACTION(sTransmitBuffer == NULL, error = OT_ERROR_BUSY);
-
- sTransmitBuffer = aBuf;
- sTransmitLength = aBufLength;
-
-exit:
- return error;
-}
-
-void processReceive(void)
-{
- // Copy tail to prevent multiple reads
- uint16_t tail = sReceive.mTail;
-
- // If the data wraps around, process the first part
- if (sReceive.mHead > tail)
- {
- otPlatUartReceived(sReceive.mBuffer + sReceive.mHead, kReceiveBufferSize - sReceive.mHead);
-
- // Reset the buffer mHead back to zero.
- sReceive.mHead = 0;
- }
-
- // For any data remaining, process it
- if (sReceive.mHead != tail)
- {
- otPlatUartReceived(sReceive.mBuffer + sReceive.mHead, tail - sReceive.mHead);
-
- // Set mHead to the local tail we have cached
- sReceive.mHead = tail;
- }
-}
-
-otError otPlatUartFlush(void)
-{
- otEXPECT(sTransmitBuffer != NULL);
-
- for (; sTransmitLength > 0; sTransmitLength--)
- {
- while (HWREG(UART0_BASE + UART_O_FR) & UART_FR_TXFF)
- ;
-
- HWREG(UART0_BASE + UART_O_DR) = *sTransmitBuffer++;
- }
-
- sTransmitBuffer = NULL;
- return OT_ERROR_NONE;
-
-exit:
- return OT_ERROR_INVALID_STATE;
-}
-
-void processTransmit(void)
-{
- otPlatUartFlush();
- otPlatUartSendDone();
-}
-
-void cc2538UartProcess(void)
-{
- processReceive();
- processTransmit();
-}
-
-void UART0IntHandler(void)
-{
- uint32_t mis;
- uint8_t byte;
-
- mis = HWREG(UART0_BASE + UART_O_MIS);
- HWREG(UART0_BASE + UART_O_ICR) = mis;
-
- if (mis & (UART_IM_RXIM | UART_IM_RTIM))
- {
- while (!(HWREG(UART0_BASE + UART_O_FR) & UART_FR_RXFE))
- {
- byte = HWREG(UART0_BASE + UART_O_DR);
-
- // We can only write if incrementing mTail doesn't equal mHead
- if (sReceive.mHead != (sReceive.mTail + 1) % kReceiveBufferSize)
- {
- sReceive.mBuffer[sReceive.mTail] = byte;
- sReceive.mTail = (sReceive.mTail + 1) % kReceiveBufferSize;
- }
- }
- }
-}
-
-#if OPENTHREAD_CONFIG_ENABLE_DEBUG_UART
-
-int otPlatDebugUart_kbhit(void)
-{
- uint32_t v;
-
- /* get flags */
- v = HWREG(UART1_BASE + UART_O_FR);
-
- /* if FIFO empty we have no data */
- return !(v & UART_FR_RXFE);
-}
-
-int otPlatDebugUart_getc(void)
-{
- int v = 1;
-
- /* if nothing in fifo */
- if (!otPlatDebugUart_kbhit())
- {
- return -1;
- }
-
- /* fetch */
- v = (int)HWREG(UART0_BASE + UART_O_DR);
- v = (v & 0x0ff);
- return v;
-}
-
-void otPlatDebugUart_putchar_raw(int b)
-{
- /* wait till not busy */
- while (HWREG(UART1_BASE + UART_O_FR) & UART_FR_TXFF)
- ;
-
- /* write byte */
- HWREG(UART1_BASE + UART_O_DR) = ((uint32_t)(b & 0x0ff));
-}
-
-void cc2538DebugUartInit(void)
-{
- int32_t a, b;
-
- // clocks
- enable_uart_clocks();
-
- HWREG(UART1_BASE + UART_O_CC) = 0;
-
- // UART1 - tx pin
- // Using an RF06 Evaluation board
- // http://www.ti.com/tool/cc2538dk
- // PA3 => is jumper position RF1.14
- // To use these, you will require a "flying-lead" UART adapter
- HWREG(IOC_PA3_SEL) = IOC_MUX_OUT_SEL_UART1_TXD;
- HWREG(IOC_PA3_OVER) = IOC_OVERRIDE_OE;
- HWREG(GPIO_A_BASE + GPIO_O_AFSEL) |= GPIO_PIN_3;
-
- // UART1 - rx pin we don't really use but we setup anyway
- // PA2 => is jumper position RF1.16
- HWREG(IOC_UARTRXD_UART1) = IOC_PAD_IN_SEL_PA2;
- HWREG(IOC_PA2_OVER) = IOC_OVERRIDE_DIS;
- HWREG(GPIO_A_BASE + GPIO_O_AFSEL) |= GPIO_PIN_2;
-
- HWREG(UART1_BASE + UART_O_CC) = 0;
-
- // baud rate
- b = (((kPlatformClock * 8) / kBaudRate) + 1) / 2;
- a = b / 64;
- b = b % 64;
-
- HWREG(UART1_BASE + UART_O_IBRD) = a;
- HWREG(UART1_BASE + UART_O_FBRD) = b;
- HWREG(UART1_BASE + UART_O_LCRH) = UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE;
-
- /* NOTE:
- * uart1 is not using IRQs it is tx only
- * and we block when writing bytes
- */
- HWREG(UART1_BASE + UART_O_CTL) = UART_CTL_UARTEN | UART_CTL_TXE | UART_CTL_RXE;
-}
-
-#endif
diff --git a/examples/platforms/simulation/alarm.c b/examples/platforms/simulation/alarm.c
index 2795672b694..d826d111d4b 100644
--- a/examples/platforms/simulation/alarm.c
+++ b/examples/platforms/simulation/alarm.c
@@ -162,10 +162,7 @@ uint64_t platformGetNow(void)
}
#endif // defined(CLOCK_MONOTONIC_RAW) || defined(CLOCK_MONOTONIC)
-uint32_t otPlatAlarmMilliGetNow(void)
-{
- return (uint32_t)(platformGetNow() / US_PER_MS);
-}
+uint32_t otPlatAlarmMilliGetNow(void) { return (uint32_t)(platformGetNow() / US_PER_MS); }
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
{
@@ -182,10 +179,7 @@ void otPlatAlarmMilliStop(otInstance *aInstance)
sIsMsRunning = false;
}
-uint32_t otPlatAlarmMicroGetNow(void)
-{
- return (uint32_t)platformGetNow();
-}
+uint32_t otPlatAlarmMicroGetNow(void) { return (uint32_t)platformGetNow(); }
void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
{
@@ -303,14 +297,8 @@ void platformAlarmProcess(otInstance *aInstance)
#endif
}
-uint64_t otPlatTimeGet(void)
-{
- return platformGetNow();
-}
+uint64_t otPlatTimeGet(void) { return platformGetNow(); }
-uint16_t otPlatTimeGetXtalAccuracy(void)
-{
- return 0;
-}
+uint16_t otPlatTimeGetXtalAccuracy(void) { return 0; }
#endif // OPENTHREAD_SIMULATION_VIRTUAL_TIME == 0
diff --git a/examples/platforms/simulation/crypto.c b/examples/platforms/simulation/crypto.c
index 36cf89be6d5..b220f7cb58c 100644
--- a/examples/platforms/simulation/crypto.c
+++ b/examples/platforms/simulation/crypto.c
@@ -38,12 +38,12 @@
// crypto key storage stubs
-otError otPlatCryptoImportKey(otCryptoKeyRef * aKeyRef,
+otError otPlatCryptoImportKey(otCryptoKeyRef *aKeyRef,
otCryptoKeyType aKeyType,
otCryptoKeyAlgorithm aKeyAlgorithm,
int aKeyUsage,
otCryptoKeyStorage aKeyPersistence,
- const uint8_t * aKey,
+ const uint8_t *aKey,
size_t aKeyLen)
{
OT_UNUSED_VARIABLE(aKeyRef);
diff --git a/examples/platforms/simulation/diag.c b/examples/platforms/simulation/diag.c
index ddb8c265959..dcd9f1d9f7a 100644
--- a/examples/platforms/simulation/diag.c
+++ b/examples/platforms/simulation/diag.c
@@ -35,8 +35,11 @@
#include
#include
+#include
#include
+#include "utils/code_utils.h"
+
#if OPENTHREAD_CONFIG_DIAG_ENABLE
/**
@@ -45,36 +48,132 @@
*/
static bool sDiagMode = false;
-void otPlatDiagModeSet(bool aMode)
+enum
+{
+ SIM_GPIO = 0,
+};
+
+static otGpioMode sGpioMode = OT_GPIO_MODE_INPUT;
+static bool sGpioValue = false;
+static uint8_t sRawPowerSetting[OPENTHREAD_CONFIG_POWER_CALIBRATION_RAW_POWER_SETTING_SIZE];
+static uint16_t sRawPowerSettingLength = 0;
+
+void otPlatDiagModeSet(bool aMode) { sDiagMode = aMode; }
+
+bool otPlatDiagModeGet(void) { return sDiagMode; }
+
+void otPlatDiagChannelSet(uint8_t aChannel) { OT_UNUSED_VARIABLE(aChannel); }
+
+void otPlatDiagTxPowerSet(int8_t aTxPower) { OT_UNUSED_VARIABLE(aTxPower); }
+
+void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
{
- sDiagMode = aMode;
+ OT_UNUSED_VARIABLE(aInstance);
+ OT_UNUSED_VARIABLE(aFrame);
+ OT_UNUSED_VARIABLE(aError);
}
-bool otPlatDiagModeGet()
+void otPlatDiagAlarmCallback(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); }
+
+otError otPlatDiagGpioSet(uint32_t aGpio, bool aValue)
{
- return sDiagMode;
+ otError error = OT_ERROR_NONE;
+
+ otEXPECT_ACTION(aGpio == SIM_GPIO, error = OT_ERROR_INVALID_ARGS);
+ sGpioValue = aValue;
+
+exit:
+ return error;
}
-void otPlatDiagChannelSet(uint8_t aChannel)
+otError otPlatDiagGpioGet(uint32_t aGpio, bool *aValue)
{
- OT_UNUSED_VARIABLE(aChannel);
+ otError error = OT_ERROR_NONE;
+
+ otEXPECT_ACTION((aGpio == SIM_GPIO) && (aValue != NULL), error = OT_ERROR_INVALID_ARGS);
+ *aValue = sGpioValue;
+
+exit:
+ return error;
}
-void otPlatDiagTxPowerSet(int8_t aTxPower)
+otError otPlatDiagGpioSetMode(uint32_t aGpio, otGpioMode aMode)
{
- OT_UNUSED_VARIABLE(aTxPower);
+ otError error = OT_ERROR_NONE;
+
+ otEXPECT_ACTION(aGpio == SIM_GPIO, error = OT_ERROR_INVALID_ARGS);
+ sGpioMode = aMode;
+
+exit:
+ return error;
}
-void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otError aError)
+otError otPlatDiagGpioGetMode(uint32_t aGpio, otGpioMode *aMode)
+{
+ otError error = OT_ERROR_NONE;
+
+ otEXPECT_ACTION((aGpio == SIM_GPIO) && (aMode != NULL), error = OT_ERROR_INVALID_ARGS);
+ *aMode = sGpioMode;
+
+exit:
+ return error;
+}
+
+otError otPlatDiagRadioSetRawPowerSetting(otInstance *aInstance,
+ const uint8_t *aRawPowerSetting,
+ uint16_t aRawPowerSettingLength)
{
OT_UNUSED_VARIABLE(aInstance);
- OT_UNUSED_VARIABLE(aFrame);
- OT_UNUSED_VARIABLE(aError);
+ otError error = OT_ERROR_NONE;
+
+ otEXPECT_ACTION((aRawPowerSetting != NULL) && (aRawPowerSettingLength <= sizeof(sRawPowerSetting)),
+ error = OT_ERROR_INVALID_ARGS);
+ memcpy(sRawPowerSetting, aRawPowerSetting, aRawPowerSettingLength);
+ sRawPowerSettingLength = aRawPowerSettingLength;
+
+exit:
+ return error;
}
-void otPlatDiagAlarmCallback(otInstance *aInstance)
+otError otPlatDiagRadioGetRawPowerSetting(otInstance *aInstance,
+ uint8_t *aRawPowerSetting,
+ uint16_t *aRawPowerSettingLength)
{
OT_UNUSED_VARIABLE(aInstance);
+ otError error = OT_ERROR_NONE;
+
+ otEXPECT_ACTION((aRawPowerSetting != NULL) && (aRawPowerSettingLength != NULL), error = OT_ERROR_INVALID_ARGS);
+ otEXPECT_ACTION((sRawPowerSettingLength != 0), error = OT_ERROR_NOT_FOUND);
+ otEXPECT_ACTION((sRawPowerSettingLength <= *aRawPowerSettingLength), error = OT_ERROR_INVALID_ARGS);
+
+ memcpy(aRawPowerSetting, sRawPowerSetting, sRawPowerSettingLength);
+ *aRawPowerSettingLength = sRawPowerSettingLength;
+
+exit:
+ return error;
}
+otError otPlatDiagRadioRawPowerSettingEnable(otInstance *aInstance, bool aEnable)
+{
+ OT_UNUSED_VARIABLE(aInstance);
+ OT_UNUSED_VARIABLE(aEnable);
+
+ return OT_ERROR_NONE;
+}
+
+otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool aEnable)
+{
+ OT_UNUSED_VARIABLE(aInstance);
+ OT_UNUSED_VARIABLE(aEnable);
+
+ return OT_ERROR_NONE;
+}
+
+otError otPlatDiagRadioTransmitStream(otInstance *aInstance, bool aEnable)
+{
+ OT_UNUSED_VARIABLE(aInstance);
+ OT_UNUSED_VARIABLE(aEnable);
+
+ return OT_ERROR_NONE;
+}
#endif // OPENTHREAD_CONFIG_DIAG_ENABLE
diff --git a/examples/platforms/simulation/entropy.c b/examples/platforms/simulation/entropy.c
index bcb04a42011..b567b0b635c 100644
--- a/examples/platforms/simulation/entropy.c
+++ b/examples/platforms/simulation/entropy.c
@@ -93,7 +93,7 @@ otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
#if __SANITIZE_ADDRESS__ == 0
- FILE * file = NULL;
+ FILE *file = NULL;
size_t readLength;
otEXPECT_ACTION(aOutput && aOutputLength, error = OT_ERROR_INVALID_ARGS);
diff --git a/examples/platforms/simulation/infra_if.c b/examples/platforms/simulation/infra_if.c
index b62041b8d6c..1904d75d6ac 100644
--- a/examples/platforms/simulation/infra_if.c
+++ b/examples/platforms/simulation/infra_if.c
@@ -41,7 +41,7 @@ bool otPlatInfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAddres
otError otPlatInfraIfSendIcmp6Nd(uint32_t aInfraIfIndex,
const otIp6Address *aDestAddress,
- const uint8_t * aBuffer,
+ const uint8_t *aBuffer,
uint16_t aBufferLength)
{
OT_UNUSED_VARIABLE(aInfraIfIndex);
@@ -51,4 +51,11 @@ otError otPlatInfraIfSendIcmp6Nd(uint32_t aInfraIfIndex,
return OT_ERROR_FAILED;
}
+
+otError otPlatInfraIfDiscoverNat64Prefix(uint32_t aInfraIfIndex)
+{
+ OT_UNUSED_VARIABLE(aInfraIfIndex);
+
+ return OT_ERROR_FAILED;
+}
#endif
diff --git a/examples/platforms/simulation/logging.c b/examples/platforms/simulation/logging.c
index 8b90c43348a..cce2ad55885 100644
--- a/examples/platforms/simulation/logging.c
+++ b/examples/platforms/simulation/logging.c
@@ -31,6 +31,7 @@
#include
#include
+#include
#include
#include
#include
@@ -44,21 +45,82 @@
#include "utils/code_utils.h"
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
-OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
+
+static FILE *sLogFile = NULL;
+
+void platformLoggingSetFileName(const char *aName)
+{
+ if (sLogFile != NULL)
+ {
+ fclose(sLogFile);
+ }
+
+ sLogFile = fopen(aName, "wt");
+
+ if (sLogFile == NULL)
+ {
+ fprintf(stderr, "Failed to open log file '%s': %s\r\n", aName, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+}
+
+void platformLoggingInit(const char *aName)
+{
+ if (sLogFile == NULL)
+ {
+ openlog(aName, LOG_PID, LOG_USER);
+ setlogmask(setlogmask(0) & LOG_UPTO(LOG_NOTICE));
+ }
+ else
+ {
+ fprintf(sLogFile, "OpenThread logs\r\n");
+ fprintf(sLogFile, "- Program: %s\r\n", aName);
+ fprintf(sLogFile, "- Platform: simulation\r\n");
+ fprintf(sLogFile, "- Node ID: %lu\r\n", (unsigned long)gNodeId);
+ fprintf(sLogFile, "\r\n");
+ }
+}
+
+void platformLoggingDeinit(void)
+{
+ if (sLogFile != NULL)
+ {
+ fclose(sLogFile);
+ sLogFile = NULL;
+ }
+}
+
+void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
OT_UNUSED_VARIABLE(aLogLevel);
OT_UNUSED_VARIABLE(aLogRegion);
- char logString[512];
- int offset;
va_list args;
- offset = snprintf(logString, sizeof(logString), "[%d]", gNodeId);
-
va_start(args, aFormat);
- vsnprintf(&logString[offset], sizeof(logString) - (uint16_t)offset, aFormat, args);
- va_end(args);
- syslog(LOG_CRIT, "%s", logString);
+ if (sLogFile == NULL)
+ {
+ char logString[512];
+ int offset;
+
+ offset = snprintf(logString, sizeof(logString), "[%lu]", (unsigned long)gNodeId);
+
+ vsnprintf(&logString[offset], sizeof(logString) - (uint16_t)offset, aFormat, args);
+ syslog(LOG_CRIT, "%s", logString);
+ }
+ else
+ {
+ vfprintf(sLogFile, aFormat, args);
+ fprintf(sLogFile, "\r\n");
+ }
+
+ va_end(args);
}
-#endif
+
+#else
+
+void platformLoggingInit(const char *aName) { OT_UNUSED_VARIABLE(aName); }
+void platformLoggingDeinit(void) {}
+
+#endif // (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
diff --git a/examples/platforms/simulation/openthread-core-simulation-config.h b/examples/platforms/simulation/openthread-core-simulation-config.h
index 879f069bf9e..f71383008a3 100644
--- a/examples/platforms/simulation/openthread-core-simulation-config.h
+++ b/examples/platforms/simulation/openthread-core-simulation-config.h
@@ -254,4 +254,35 @@
#define OPENTHREAD_CONFIG_SRP_CLIENT_BUFFERS_MAX_SERVICES 20
#endif
+/**
+ * @def OPENTHREAD_CONFIG_DETERMINISTIC_ECDSA_ENABLE
+ *
+ * Define to 1 to generate ECDSA signatures deterministically
+ * according to RFC 6979 instead of randomly.
+ *
+ */
+#ifndef OPENTHREAD_CONFIG_DETERMINISTIC_ECDSA_ENABLE
+#define OPENTHREAD_CONFIG_DETERMINISTIC_ECDSA_ENABLE 1
+#endif
+
+/**
+ * @def OPENTHREAD_CONFIG_POWER_CALIBRATION_ENABLE
+ *
+ * Define as 1 to enable power calibration support.
+ *
+ */
+#ifndef OPENTHREAD_CONFIG_POWER_CALIBRATION_ENABLE
+#define OPENTHREAD_CONFIG_POWER_CALIBRATION_ENABLE 1
+#endif
+
+/**
+ * @def OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE
+ *
+ * Define as 1 to enable platform power calibration support.
+ *
+ */
+#ifndef OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE
+#define OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE 1
+#endif
+
#endif // OPENTHREAD_CORE_SIMULATION_CONFIG_H_
diff --git a/examples/platforms/simulation/platform-simulation.h b/examples/platforms/simulation/platform-simulation.h
index 9379421d46a..0fa32fddc88 100644
--- a/examples/platforms/simulation/platform-simulation.h
+++ b/examples/platforms/simulation/platform-simulation.h
@@ -185,6 +185,28 @@ void platformRadioProcess(otInstance *aInstance, const fd_set *aReadFdSet, const
*/
void platformRandomInit(void);
+/**
+ * This functions set the file name to use for logging.
+ *
+ * @param[in] aName The file name.
+ *
+ */
+void platformLoggingSetFileName(const char *aName);
+
+/**
+ * This function initializes the platform logging service.
+ *
+ * @param[in] aName The log module name to set with syslog.
+ *
+ */
+void platformLoggingInit(const char *aName);
+
+/**
+ * This function finalizes the platform logging service.
+ *
+ */
+void platformLoggingDeinit(void);
+
/**
* This function updates the file descriptor sets with file descriptors used by the UART driver.
*
@@ -232,6 +254,18 @@ void otSimSendUartWriteEvent(const uint8_t *aData, uint16_t aLength);
*/
bool platformRadioIsTransmitPending(void);
+/**
+ * This function parses an environment variable as an unsigned 16-bit integer.
+ *
+ * If the environment variable does not exist, this function does nothing.
+ * If it is not a valid integer, this function will terminate the process with an error message.
+ *
+ * @param[in] aEnvName The name of the environment variable.
+ * @param[out] aValue A pointer to the unsigned 16-bit integer.
+ *
+ */
+void parseFromEnvAsUint16(const char *aEnvName, uint16_t *aValue);
+
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
/**
diff --git a/examples/platforms/simulation/radio.c b/examples/platforms/simulation/radio.c
index 2b627c2f212..9fe37b66c21 100644
--- a/examples/platforms/simulation/radio.c
+++ b/examples/platforms/simulation/radio.c
@@ -31,6 +31,7 @@
#include
#include
+#include
#include
#include
#include
@@ -71,10 +72,12 @@ enum
#if OPENTHREAD_SIMULATION_VIRTUAL_TIME
extern int sSockFd;
+extern uint16_t sPortBase;
extern uint16_t sPortOffset;
#else
static int sTxFd = -1;
static int sRxFd = -1;
+static uint16_t sPortBase = 9000;
static uint16_t sPortOffset = 0;
static uint16_t sPort = 0;
#endif
@@ -166,11 +169,128 @@ static otRadioKeyType sKeyType;
static int8_t GetRssi(uint16_t aChannel);
-static bool IsTimeAfterOrEqual(uint32_t aTimeA, uint32_t aTimeB)
+#if OPENTHREAD_SIMULATION_VIRTUAL_TIME == 0
+
+static enum {
+ kFilterOff,
+ kFilterDenyList,
+ kFilterAllowList,
+} sFilterMode = kFilterOff;
+
+static uint8_t sFilterNodeIdsBitVector[(MAX_NETWORK_SIZE + 7) / 8];
+
+static bool FilterContainsId(uint16_t aNodeId)
+{
+ uint16_t index = aNodeId - 1;
+
+ return (sFilterNodeIdsBitVector[index / 8] & (0x80 >> (index % 8))) != 0;
+}
+
+static bool NodeIdFilterIsConnectable(uint16_t aNodeId)
+{
+ bool isConnectable = true;
+
+ switch (sFilterMode)
+ {
+ case kFilterOff:
+ break;
+ case kFilterDenyList:
+ isConnectable = !FilterContainsId(aNodeId);
+ break;
+ case kFilterAllowList:
+ isConnectable = FilterContainsId(aNodeId);
+ break;
+ }
+
+ return isConnectable;
+}
+
+static void AddNodeIdToFilter(uint16_t aNodeId)
{
- return (aTimeA - aTimeB) < (1U << 31);
+ uint16_t index = aNodeId - 1;
+
+ sFilterNodeIdsBitVector[index / 8] |= 0x80 >> (index % 8);
}
+OT_TOOL_WEAK void otCliOutputFormat(const char *aFmt, ...) { OT_UNUSED_VARIABLE(aFmt); }
+
+otError ProcessNodeIdFilter(void *aContext, uint8_t aArgsLength, char *aArgs[])
+{
+ OT_UNUSED_VARIABLE(aContext);
+
+ otError error = OT_ERROR_NONE;
+ bool deny = false;
+
+ if (aArgsLength == 0)
+ {
+ switch (sFilterMode)
+ {
+ case kFilterOff:
+ otCliOutputFormat("off");
+ break;
+ case kFilterDenyList:
+ otCliOutputFormat("deny-list");
+ break;
+ case kFilterAllowList:
+ otCliOutputFormat("allow-list");
+ break;
+ }
+
+ for (uint16_t nodeId = 0; nodeId <= MAX_NETWORK_SIZE; nodeId++)
+ {
+ if (FilterContainsId(nodeId))
+ {
+ otCliOutputFormat(" %d", nodeId);
+ }
+ }
+
+ otCliOutputFormat("\r\n");
+ }
+ else if (!strcmp(aArgs[0], "clear"))
+ {
+ otEXPECT_ACTION(aArgsLength == 1, error = OT_ERROR_INVALID_ARGS);
+
+ memset(sFilterNodeIdsBitVector, 0, sizeof(sFilterNodeIdsBitVector));
+ sFilterMode = kFilterOff;
+ }
+ else if ((deny = !strcmp(aArgs[0], "deny")) || !strcmp(aArgs[0], "allow"))
+ {
+ uint16_t nodeId;
+ char *endptr;
+
+ otEXPECT_ACTION(aArgsLength == 2, error = OT_ERROR_INVALID_ARGS);
+
+ nodeId = (uint16_t)strtol(aArgs[1], &endptr, 0);
+
+ otEXPECT_ACTION(*endptr == '\0', error = OT_ERROR_INVALID_ARGS);
+ otEXPECT_ACTION(1 <= nodeId && nodeId <= MAX_NETWORK_SIZE, error = OT_ERROR_INVALID_ARGS);
+
+ otEXPECT_ACTION(sFilterMode != (deny ? kFilterAllowList : kFilterDenyList), error = OT_ERROR_INVALID_STATE);
+
+ AddNodeIdToFilter(nodeId);
+ sFilterMode = deny ? kFilterDenyList : kFilterAllowList;
+ }
+ else
+ {
+ error = OT_ERROR_INVALID_COMMAND;
+ }
+
+exit:
+ return error;
+}
+#else
+otError ProcessNodeIdFilter(void *aContext, uint8_t aArgsLength, char *aArgs[])
+{
+ OT_UNUSED_VARIABLE(aContext);
+ OT_UNUSED_VARIABLE(aArgsLength);
+ OT_UNUSED_VARIABLE(aArgs);
+
+ return OT_ERROR_NOT_IMPLEMENTED;
+}
+#endif // OPENTHREAD_SIMULATION_VIRTUAL_TIME == 0
+
+static bool IsTimeAfterOrEqual(uint32_t aTimeA, uint32_t aTimeB) { return (aTimeA - aTimeB) < (1U << 31); }
+
static void ReverseExtAddress(otExtAddress *aReversed, const otExtAddress *aOrigin)
{
for (size_t i = 0; i < sizeof(*aReversed); i++)
@@ -298,7 +418,7 @@ static void initFds(void)
otEXPECT_ACTION((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) != -1, perror("socket(sTxFd)"));
- sPort = (uint16_t)(9000 + sPortOffset + gNodeId);
+ sPort = (uint16_t)(sPortBase + sPortOffset + gNodeId);
sockaddr.sin_family = AF_INET;
sockaddr.sin_port = htons(sPort);
sockaddr.sin_addr.s_addr = inet_addr("127.0.0.1");
@@ -337,7 +457,7 @@ static void initFds(void)
}
sockaddr.sin_family = AF_INET;
- sockaddr.sin_port = htons((uint16_t)(9000 + sPortOffset));
+ sockaddr.sin_port = htons((uint16_t)(sPortBase + sPortOffset));
sockaddr.sin_addr.s_addr = inet_addr(OT_RADIO_GROUP);
otEXPECT_ACTION(bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) != -1, perror("bind(sRxFd)"));
@@ -356,24 +476,10 @@ static void initFds(void)
void platformRadioInit(void)
{
#if OPENTHREAD_SIMULATION_VIRTUAL_TIME == 0
- char *offset;
+ parseFromEnvAsUint16("PORT_BASE", &sPortBase);
- offset = getenv("PORT_OFFSET");
-
- if (offset)
- {
- char *endptr;
-
- sPortOffset = (uint16_t)strtol(offset, &endptr, 0);
-
- if (*endptr != '\0')
- {
- fprintf(stderr, "Invalid PORT_OFFSET: %s\n", offset);
- exit(EXIT_FAILURE);
- }
-
- sPortOffset *= (MAX_NETWORK_SIZE + 1);
- }
+ parseFromEnvAsUint16("PORT_OFFSET", &sPortOffset);
+ sPortOffset *= (MAX_NETWORK_SIZE + 1);
initFds();
#endif // OPENTHREAD_SIMULATION_VIRTUAL_TIME == 0
@@ -737,10 +843,7 @@ void radioSendMessage(otInstance *aInstance)
return;
}
-bool platformRadioIsTransmitPending(void)
-{
- return sState == OT_RADIO_STATE_TRANSMIT && !sTxWait;
-}
+bool platformRadioIsTransmitPending(void) { return sState == OT_RADIO_STATE_TRANSMIT && !sTxWait; }
#if OPENTHREAD_SIMULATION_VIRTUAL_TIME
void platformRadioReceive(otInstance *aInstance, uint8_t *aBuf, uint16_t aBufLength)
@@ -829,7 +932,10 @@ void platformRadioProcess(otInstance *aInstance, const fd_set *aReadFdSet, const
if (rval > 0)
{
- if (sockaddr.sin_port != htons(sPort))
+ uint16_t srcPort = ntohs(sockaddr.sin_port);
+ uint16_t srcNodeId = srcPort - sPortOffset - sPortBase;
+
+ if (NodeIdFilterIsConnectable(srcNodeId) && srcPort != sPort)
{
sReceiveFrame.mLength = (uint16_t)(rval - 1);
@@ -847,7 +953,7 @@ void platformRadioProcess(otInstance *aInstance, const fd_set *aReadFdSet, const
exit(EXIT_FAILURE);
}
}
-#endif
+#endif // OPENTHREAD_SIMULATION_VIRTUAL_TIME == 0
if (platformRadioIsTransmitPending())
{
radioSendMessage(aInstance);
@@ -870,7 +976,7 @@ void radioTransmit(struct RadioMessage *aMessage, const struct otRadioFrame *aFr
sockaddr.sin_family = AF_INET;
inet_pton(AF_INET, OT_RADIO_GROUP, &sockaddr.sin_addr);
- sockaddr.sin_port = htons((uint16_t)(9000 + sPortOffset));
+ sockaddr.sin_port = htons((uint16_t)(sPortBase + sPortOffset));
rval =
sendto(sTxFd, (const char *)aMessage, 1 + aFrame->mLength, 0, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
@@ -1216,7 +1322,7 @@ static uint8_t generateAckIeData(uint8_t *aLinkMetricsIeData, uint8_t aLinkMetri
#endif
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
-otError otPlatRadioEnableCsl(otInstance * aInstance,
+otError otPlatRadioEnableCsl(otInstance *aInstance,
uint32_t aCslPeriod,
otShortAddress aShortAddr,
const otExtAddress *aExtAddr)
@@ -1247,7 +1353,7 @@ uint8_t otPlatRadioGetCslAccuracy(otInstance *aInstance)
}
#endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
-void otPlatRadioSetMacKey(otInstance * aInstance,
+void otPlatRadioSetMacKey(otInstance *aInstance,
uint8_t aKeyIdMode,
uint8_t aKeyId,
const otMacKeyMaterial *aPrevKey,
@@ -1291,10 +1397,10 @@ otError otPlatRadioSetChannelMaxTransmitPower(otInstance *aInstance, uint8_t aCh
}
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_SUBJECT_ENABLE
-otError otPlatRadioConfigureEnhAckProbing(otInstance * aInstance,
+otError otPlatRadioConfigureEnhAckProbing(otInstance *aInstance,
otLinkMetrics aLinkMetrics,
const otShortAddress aShortAddress,
- const otExtAddress * aExtAddress)
+ const otExtAddress *aExtAddress)
{
OT_UNUSED_VARIABLE(aInstance);
@@ -1321,3 +1427,21 @@ otError otPlatRadioGetRegion(otInstance *aInstance, uint16_t *aRegionCode)
exit:
return error;
}
+
+void parseFromEnvAsUint16(const char *aEnvName, uint16_t *aValue)
+{
+ char *env = getenv(aEnvName);
+
+ if (env)
+ {
+ char *endptr;
+
+ *aValue = (uint16_t)strtol(env, &endptr, 0);
+
+ if (*endptr != '\0')
+ {
+ fprintf(stderr, "Invalid %s: %s\n", aEnvName, env);
+ exit(EXIT_FAILURE);
+ }
+ }
+}
diff --git a/examples/platforms/simulation/spi-stubs.c b/examples/platforms/simulation/spi-stubs.c
index 585bca7b006..2643402fc08 100644
--- a/examples/platforms/simulation/spi-stubs.c
+++ b/examples/platforms/simulation/spi-stubs.c
@@ -40,7 +40,7 @@
otError otPlatSpiSlaveEnable(otPlatSpiSlaveTransactionCompleteCallback aCompleteCallback,
otPlatSpiSlaveTransactionProcessCallback aProcessCallback,
- void * aContext)
+ void *aContext)
{
OT_UNUSED_VARIABLE(aCompleteCallback);
OT_UNUSED_VARIABLE(aProcessCallback);
@@ -52,9 +52,7 @@ otError otPlatSpiSlaveEnable(otPlatSpiSlaveTransactionCompleteCallback aComplete
return OT_ERROR_NOT_IMPLEMENTED;
}
-void otPlatSpiSlaveDisable(void)
-{
-}
+void otPlatSpiSlaveDisable(void) {}
otError otPlatSpiSlavePrepareTransaction(uint8_t *aOutputBuf,
uint16_t aOutputBufLen,
@@ -73,9 +71,7 @@ otError otPlatSpiSlavePrepareTransaction(uint8_t *aOutputBuf,
// Uart
-void otPlatUartSendDone(void)
-{
-}
+void otPlatUartSendDone(void) {}
void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength)
{
diff --git a/examples/platforms/simulation/system.c b/examples/platforms/simulation/system.c
index f9282a64a20..0e86aaae439 100644
--- a/examples/platforms/simulation/system.c
+++ b/examples/platforms/simulation/system.c
@@ -44,7 +44,6 @@
#include
#include
#include
-#include
#include
#include
@@ -74,6 +73,7 @@ enum
OT_SIM_OPT_ENABLE_ENERGY_SCAN = 'E',
OT_SIM_OPT_SLEEP_TO_TX = 't',
OT_SIM_OPT_TIME_SPEED = 's',
+ OT_SIM_OPT_LOG_FILE = 'l',
OT_SIM_OPT_UNKNOWN = '?',
};
@@ -86,7 +86,11 @@ static void PrintUsage(const char *aProgramName, int aExitCode)
" -h --help Display this usage information.\n"
" -E --enable-energy-scan Enable energy scan capability.\n"
" -t --sleep-to-tx Let radio support direct transition from sleep to TX with CSMA.\n"
- " -s --time-speed=val Speed up the time in simulation.\n",
+ " -s --time-speed=val Speed up the time in simulation.\n"
+#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
+ " -l --log-file=name File name to write logs.\n"
+#endif
+ ,
aProgramName);
exit(aExitCode);
@@ -94,17 +98,26 @@ static void PrintUsage(const char *aProgramName, int aExitCode)
void otSysInit(int aArgCount, char *aArgVector[])
{
- char * endptr;
+ char *endptr;
uint32_t speedUpFactor = 1;
static const struct option long_options[] = {
{"help", no_argument, 0, OT_SIM_OPT_HELP},
- {"enable-energy-scan", no_argument, 0, OT_SIM_OPT_SLEEP_TO_TX},
+ {"enable-energy-scan", no_argument, 0, OT_SIM_OPT_ENABLE_ENERGY_SCAN},
{"sleep-to-tx", no_argument, 0, OT_SIM_OPT_SLEEP_TO_TX},
{"time-speed", required_argument, 0, OT_SIM_OPT_TIME_SPEED},
+#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
+ {"log-file", required_argument, 0, OT_SIM_OPT_LOG_FILE},
+#endif
{0, 0, 0, 0},
};
+#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
+ static const char options[] = "Ehts:l:";
+#else
+ static const char options[] = "Ehts:";
+#endif
+
if (gPlatformPseudoResetWasRequested)
{
gPlatformPseudoResetWasRequested = false;
@@ -115,7 +128,7 @@ void otSysInit(int aArgCount, char *aArgVector[])
while (true)
{
- int c = getopt_long(aArgCount, aArgVector, "Ehts:", long_options, NULL);
+ int c = getopt_long(aArgCount, aArgVector, options, long_options, NULL);
if (c == -1)
{
@@ -144,6 +157,11 @@ void otSysInit(int aArgCount, char *aArgVector[])
exit(EXIT_FAILURE);
}
break;
+#if OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
+ case OT_SIM_OPT_LOG_FILE:
+ platformLoggingSetFileName(optarg);
+ break;
+#endif
default:
break;
}
@@ -162,12 +180,10 @@ void otSysInit(int aArgCount, char *aArgVector[])
exit(EXIT_FAILURE);
}
- openlog(basename(aArgVector[0]), LOG_PID, LOG_USER);
- setlogmask(setlogmask(0) & LOG_UPTO(LOG_NOTICE));
-
signal(SIGTERM, &handleSignal);
signal(SIGHUP, &handleSignal);
+ platformLoggingInit(basename(aArgVector[0]));
platformAlarmInit(speedUpFactor);
platformRadioInit();
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
@@ -176,10 +192,7 @@ void otSysInit(int aArgCount, char *aArgVector[])
platformRandomInit();
}
-bool otSysPseudoResetWasRequested(void)
-{
- return gPlatformPseudoResetWasRequested;
-}
+bool otSysPseudoResetWasRequested(void) { return gPlatformPseudoResetWasRequested; }
void otSysDeinit(void)
{
@@ -187,6 +200,7 @@ void otSysDeinit(void)
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
platformTrelDeinit();
#endif
+ platformLoggingDeinit();
}
void otSysProcessDrivers(otInstance *aInstance)
diff --git a/examples/platforms/simulation/trel.c b/examples/platforms/simulation/trel.c
index 20c6b305720..3413c9351b8 100644
--- a/examples/platforms/simulation/trel.c
+++ b/examples/platforms/simulation/trel.c
@@ -366,8 +366,8 @@ void otPlatTrelRegisterService(otInstance *aInstance, uint16_t aPort, const uint
#endif
}
-void otPlatTrelSend(otInstance * aInstance,
- const uint8_t * aUdpPayload,
+void otPlatTrelSend(otInstance *aInstance,
+ const uint8_t *aUdpPayload,
uint16_t aUdpPayloadLen,
const otSockAddr *aDestSockAddr)
{
@@ -419,10 +419,7 @@ void platformTrelInit(uint32_t aSpeedUpFactor)
OT_UNUSED_VARIABLE(aSpeedUpFactor);
}
-void platformTrelDeinit(void)
-{
- deinitFds();
-}
+void platformTrelDeinit(void) { deinitFds(); }
void platformTrelUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, struct timeval *aTimeout, int *aMaxFd)
{
diff --git a/examples/platforms/simulation/uart.c b/examples/platforms/simulation/uart.c
index 3bbcface50f..fe3fcebe854 100644
--- a/examples/platforms/simulation/uart.c
+++ b/examples/platforms/simulation/uart.c
@@ -54,15 +54,9 @@ static int s_out_fd;
static struct termios original_stdin_termios;
static struct termios original_stdout_termios;
-static void restore_stdin_termios(void)
-{
- tcsetattr(s_in_fd, TCSAFLUSH, &original_stdin_termios);
-}
+static void restore_stdin_termios(void) { tcsetattr(s_in_fd, TCSAFLUSH, &original_stdin_termios); }
-static void restore_stdout_termios(void)
-{
- tcsetattr(s_out_fd, TCSAFLUSH, &original_stdout_termios);
-}
+static void restore_stdout_termios(void) { tcsetattr(s_out_fd, TCSAFLUSH, &original_stdout_termios); }
void platformUartRestore(void)
{
@@ -241,8 +235,8 @@ void platformUartProcess(void)
ssize_t rval;
const int error_flags = POLLERR | POLLNVAL | POLLHUP;
struct pollfd pollfd[] = {
- {s_in_fd, POLLIN | error_flags, 0},
- {s_out_fd, POLLOUT | error_flags, 0},
+ {s_in_fd, POLLIN | error_flags, 0},
+ {s_out_fd, POLLOUT | error_flags, 0},
};
errno = 0;
diff --git a/examples/platforms/simulation/virtual_time/alarm-sim.c b/examples/platforms/simulation/virtual_time/alarm-sim.c
index 10ebaa56957..7c2cea1e5e8 100644
--- a/examples/platforms/simulation/virtual_time/alarm-sim.c
+++ b/examples/platforms/simulation/virtual_time/alarm-sim.c
@@ -55,20 +55,11 @@ void platformAlarmInit(uint32_t aSpeedUpFactor)
sNow = 0;
}
-uint64_t platformAlarmGetNow(void)
-{
- return sNow;
-}
+uint64_t platformAlarmGetNow(void) { return sNow; }
-void platformAlarmAdvanceNow(uint64_t aDelta)
-{
- sNow += aDelta;
-}
+void platformAlarmAdvanceNow(uint64_t aDelta) { sNow += aDelta; }
-uint32_t otPlatAlarmMilliGetNow(void)
-{
- return (uint32_t)(sNow / US_PER_MS);
-}
+uint32_t otPlatAlarmMilliGetNow(void) { return (uint32_t)(sNow / US_PER_MS); }
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
{
@@ -85,10 +76,7 @@ void otPlatAlarmMilliStop(otInstance *aInstance)
sIsMsRunning = false;
}
-uint32_t otPlatAlarmMicroGetNow(void)
-{
- return (uint32_t)sNow;
-}
+uint32_t otPlatAlarmMicroGetNow(void) { return (uint32_t)sNow; }
void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
{
@@ -186,16 +174,10 @@ void platformAlarmProcess(otInstance *aInstance)
#endif // OPENTHREAD_CONFIG_PLATFORM_USEC_TIMER_ENABLE
}
-uint64_t otPlatTimeGet(void)
-{
- return platformAlarmGetNow();
-}
+uint64_t otPlatTimeGet(void) { return platformAlarmGetNow(); }
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
-uint16_t otPlatTimeGetXtalAccuracy(void)
-{
- return 0;
-}
+uint16_t otPlatTimeGetXtalAccuracy(void) { return 0; }
#endif
#endif // OPENTHREAD_SIMULATION_VIRTUAL_TIME
diff --git a/examples/platforms/simulation/virtual_time/platform-sim.c b/examples/platforms/simulation/virtual_time/platform-sim.c
index fa0dd905599..1c2c8189494 100644
--- a/examples/platforms/simulation/virtual_time/platform-sim.c
+++ b/examples/platforms/simulation/virtual_time/platform-sim.c
@@ -61,6 +61,7 @@ char **gArguments = NULL;
uint64_t sNow = 0; // microseconds
int sSockFd;
+uint16_t sPortBase = 9000;
uint16_t sPortOffset;
static void handleSignal(int aSignal)
@@ -78,7 +79,7 @@ void otSimSendEvent(const struct Event *aEvent)
memset(&sockaddr, 0, sizeof(sockaddr));
sockaddr.sin_family = AF_INET;
inet_pton(AF_INET, "127.0.0.1", &sockaddr.sin_addr);
- sockaddr.sin_port = htons(9000 + sPortOffset);
+ sockaddr.sin_port = htons(sPortBase + sPortOffset);
rval = sendto(sSockFd, aEvent, offsetof(struct Event, mData) + aEvent->mDataLength, 0, (struct sockaddr *)&sockaddr,
sizeof(sockaddr));
@@ -135,19 +136,11 @@ static void platformSendSleepEvent(void)
}
#if OPENTHREAD_SIMULATION_VIRTUAL_TIME_UART
-void platformUartRestore(void)
-{
-}
+void platformUartRestore(void) {}
-otError otPlatUartEnable(void)
-{
- return OT_ERROR_NONE;
-}
+otError otPlatUartEnable(void) { return OT_ERROR_NONE; }
-otError otPlatUartDisable(void)
-{
- return OT_ERROR_NONE;
-}
+otError otPlatUartDisable(void) { return OT_ERROR_NONE; }
otError otPlatUartSend(const uint8_t *aData, uint16_t aLength)
{
@@ -167,37 +160,21 @@ otError otPlatUartSend(const uint8_t *aData, uint16_t aLength)
return error;
}
-otError otPlatUartFlush(void)
-{
- return OT_ERROR_NONE;
-}
+otError otPlatUartFlush(void) { return OT_ERROR_NONE; }
#endif // OPENTHREAD_SIMULATION_VIRTUAL_TIME_UART
static void socket_init(void)
{
struct sockaddr_in sockaddr;
- char * offset;
memset(&sockaddr, 0, sizeof(sockaddr));
sockaddr.sin_family = AF_INET;
- offset = getenv("PORT_OFFSET");
-
- if (offset)
- {
- char *endptr;
-
- sPortOffset = (uint16_t)strtol(offset, &endptr, 0);
-
- if (*endptr != '\0')
- {
- fprintf(stderr, "Invalid PORT_OFFSET: %s\n", offset);
- exit(EXIT_FAILURE);
- }
+ parseFromEnvAsUint16("PORT_BASE", &sPortBase);
- sPortOffset *= (MAX_NETWORK_SIZE + 1);
- }
+ parseFromEnvAsUint16("PORT_OFFSET", &sPortOffset);
+ sPortOffset *= (MAX_NETWORK_SIZE + 1);
- sockaddr.sin_port = htons((uint16_t)(9000 + sPortOffset + gNodeId));
+ sockaddr.sin_port = htons((uint16_t)(sPortBase + sPortOffset + gNodeId));
sockaddr.sin_addr.s_addr = INADDR_ANY;
sSockFd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
@@ -254,15 +231,9 @@ void otSysInit(int argc, char *argv[])
signal(SIGHUP, &handleSignal);
}
-bool otSysPseudoResetWasRequested(void)
-{
- return gPlatformPseudoResetWasRequested;
-}
+bool otSysPseudoResetWasRequested(void) { return gPlatformPseudoResetWasRequested; }
-void otSysDeinit(void)
-{
- close(sSockFd);
-}
+void otSysDeinit(void) { close(sSockFd); }
void otSysProcessDrivers(otInstance *aInstance)
{
diff --git a/examples/platforms/utils/debug_uart.c b/examples/platforms/utils/debug_uart.c
index e1d10bdc93f..169c65ddef3 100644
--- a/examples/platforms/utils/debug_uart.c
+++ b/examples/platforms/utils/debug_uart.c
@@ -103,22 +103,13 @@ void otPlatDebugUart_putchar(int c)
/* provide WEAK stubs for platforms that do not implement all functions */
OT_TOOL_WEAK
-void otPlatDebugUart_putchar_raw(int c)
-{
- OT_UNUSED_VARIABLE(c);
-}
+void otPlatDebugUart_putchar_raw(int c) { OT_UNUSED_VARIABLE(c); }
OT_TOOL_WEAK
-int otPlatDebugUart_kbhit(void)
-{
- return 0; /* nothing */
-}
+int otPlatDebugUart_kbhit(void) { return 0; /* nothing */ }
OT_TOOL_WEAK
-int otPlatDebugUart_getc(void)
-{
- return -1; /* nothing */
-}
+int otPlatDebugUart_getc(void) { return -1; /* nothing */ }
OT_TOOL_WEAK
otError otPlatDebugUart_logfile(const char *filename)
diff --git a/examples/platforms/utils/link_metrics.cpp b/examples/platforms/utils/link_metrics.cpp
index a09fab423b2..84be0d7c377 100644
--- a/examples/platforms/utils/link_metrics.cpp
+++ b/examples/platforms/utils/link_metrics.cpp
@@ -134,7 +134,7 @@ class LinkMetricsDataInfo : public LinkedListEntry, public
otLinkMetrics GetLinkMetrics(void) const { return mLinkMetrics; }
private:
- uint8_t GetLinkMargin(int8_t aRssi) const { return LinkQualityInfo::ConvertRssToLinkMargin(sNoiseFloor, aRssi); }
+ uint8_t GetLinkMargin(int8_t aRssi) const { return ComputeLinkMargin(sNoiseFloor, aRssi); }
bool Matches(const otShortAddress &aShortAddress) const { return mShortAddress == aShortAddress; };
@@ -177,10 +177,7 @@ static inline bool IsLinkMetricsClear(otLinkMetrics aLinkMetrics)
return !aLinkMetrics.mPduCount && !aLinkMetrics.mLqi && !aLinkMetrics.mLinkMargin && !aLinkMetrics.mRssi;
}
-void otLinkMetricsInit(int8_t aNoiseFloor)
-{
- sNoiseFloor = aNoiseFloor;
-}
+void otLinkMetricsInit(int8_t aNoiseFloor) { sNoiseFloor = aNoiseFloor; }
otError otLinkMetricsConfigureEnhAckProbing(otShortAddress aShortAddress,
const otExtAddress *aExtAddress,
diff --git a/examples/platforms/utils/logging_rtt.c b/examples/platforms/utils/logging_rtt.c
index e58db65094f..32d79f5af7c 100644
--- a/examples/platforms/utils/logging_rtt.c
+++ b/examples/platforms/utils/logging_rtt.c
@@ -136,10 +136,7 @@ void utilsLogRttInit(void)
return;
}
-void utilsLogRttDeinit(void)
-{
- sLogInitialized = false;
-}
+void utilsLogRttDeinit(void) { sLogInitialized = false; }
void utilsLogRttOutput(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, va_list ap)
{
diff --git a/examples/platforms/utils/mac_frame.cpp b/examples/platforms/utils/mac_frame.cpp
index de238832ce3..0ae88db3424 100644
--- a/examples/platforms/utils/mac_frame.cpp
+++ b/examples/platforms/utils/mac_frame.cpp
@@ -68,17 +68,17 @@ bool otMacFrameDoesAddrMatch(const otRadioFrame *aFrame,
bool otMacFrameIsAck(const otRadioFrame *aFrame)
{
- return static_cast(aFrame)->GetType() == Mac::Frame::kFcfFrameAck;
+ return static_cast(aFrame)->GetType() == Mac::Frame::kTypeAck;
}
bool otMacFrameIsData(const otRadioFrame *aFrame)
{
- return static_cast(aFrame)->GetType() == Mac::Frame::kFcfFrameData;
+ return static_cast(aFrame)->GetType() == Mac::Frame::kTypeData;
}
bool otMacFrameIsCommand(const otRadioFrame *aFrame)
{
- return static_cast(aFrame)->GetType() == Mac::Frame::kFcfFrameMacCmd;
+ return static_cast(aFrame)->GetType() == Mac::Frame::kTypeMacCmd;
}
bool otMacFrameIsDataRequest(const otRadioFrame *aFrame)
@@ -164,9 +164,9 @@ void otMacFrameGenerateImmAck(const otRadioFrame *aFrame, bool aIsFramePending,
#if OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2
otError otMacFrameGenerateEnhAck(const otRadioFrame *aFrame,
bool aIsFramePending,
- const uint8_t * aIeData,
+ const uint8_t *aIeData,
uint8_t aIeLength,
- otRadioFrame * aAckFrame)
+ otRadioFrame *aAckFrame)
{
assert(aFrame != nullptr && aAckFrame != nullptr);
@@ -206,10 +206,7 @@ uint8_t otMacFrameGetKeyId(otRadioFrame *aFrame)
return keyId;
}
-void otMacFrameSetKeyId(otRadioFrame *aFrame, uint8_t aKeyId)
-{
- static_cast(aFrame)->SetKeyId(aKeyId);
-}
+void otMacFrameSetKeyId(otRadioFrame *aFrame, uint8_t aKeyId) { static_cast(aFrame)->SetKeyId(aKeyId); }
uint32_t otMacFrameGetFrameCounter(otRadioFrame *aFrame)
{
diff --git a/examples/platforms/utils/mac_frame.h b/examples/platforms/utils/mac_frame.h
index 8f0c6794f5a..1853ed1a185 100644
--- a/examples/platforms/utils/mac_frame.h
+++ b/examples/platforms/utils/mac_frame.h
@@ -221,9 +221,9 @@ void otMacFrameGenerateImmAck(const otRadioFrame *aFrame, bool aIsFramePending,
*/
otError otMacFrameGenerateEnhAck(const otRadioFrame *aFrame,
bool aIsFramePending,
- const uint8_t * aIeData,
+ const uint8_t *aIeData,
uint8_t aIeLength,
- otRadioFrame * aAckFrame);
+ otRadioFrame *aAckFrame);
/**
* Set CSL IE content into the frame.
diff --git a/examples/platforms/utils/otns_utils.cpp b/examples/platforms/utils/otns_utils.cpp
index e343503d162..1c8db69c96b 100644
--- a/examples/platforms/utils/otns_utils.cpp
+++ b/examples/platforms/utils/otns_utils.cpp
@@ -43,9 +43,6 @@ using namespace ot;
#if OPENTHREAD_CONFIG_OTNS_ENABLE
OT_TOOL_WEAK
-void otPlatOtnsStatus(const char *aStatus)
-{
- LogAlways("[OTNS] %s", aStatus);
-}
+void otPlatOtnsStatus(const char *aStatus) { LogAlways("[OTNS] %s", aStatus); }
#endif // OPENTHREAD_CONFIG_OTNS_ENABLE
diff --git a/examples/platforms/utils/settings_ram.c b/examples/platforms/utils/settings_ram.c
index fd4abd9327e..d8e7c0fc079 100644
--- a/examples/platforms/utils/settings_ram.c
+++ b/examples/platforms/utils/settings_ram.c
@@ -66,10 +66,7 @@ void otPlatSettingsInit(otInstance *aInstance, const uint16_t *aSensitiveKeys, u
sSettingsBufLength = 0;
}
-void otPlatSettingsDeinit(otInstance *aInstance)
-{
- OT_UNUSED_VARIABLE(aInstance);
-}
+void otPlatSettingsDeinit(otInstance *aInstance) { OT_UNUSED_VARIABLE(aInstance); }
otError otPlatSettingsGet(otInstance *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)
{
@@ -229,9 +226,6 @@ otError otPlatSettingsDelete(otInstance *aInstance, uint16_t aKey, int aIndex)
return error;
}
-void otPlatSettingsWipe(otInstance *aInstance)
-{
- otPlatSettingsInit(aInstance, NULL, 0);
-}
+void otPlatSettingsWipe(otInstance *aInstance) { otPlatSettingsInit(aInstance, NULL, 0); }
#endif // OPENTHREAD_SETTINGS_RAM
diff --git a/examples/platforms/utils/soft_source_match_table.c b/examples/platforms/utils/soft_source_match_table.c
index 458d1b5c509..3d8a8a6c190 100644
--- a/examples/platforms/utils/soft_source_match_table.c
+++ b/examples/platforms/utils/soft_source_match_table.c
@@ -46,10 +46,7 @@
#if RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM || RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
static uint16_t sPanId = 0;
-void utilsSoftSrcMatchSetPanId(uint16_t aPanId)
-{
- sPanId = aPanId;
-}
+void utilsSoftSrcMatchSetPanId(uint16_t aPanId) { sPanId = aPanId; }
#endif // RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM || RADIO_CONFIG_SRC_MATCH_EXT_ENTRY_NUM
#if RADIO_CONFIG_SRC_MATCH_SHORT_ENTRY_NUM
@@ -148,7 +145,7 @@ void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
- otLogDebgPlat("Clear ShortAddr entries", NULL);
+ otLogDebgPlat("Clear ShortAddr entries");
memset(srcMatchShortEntry, 0, sizeof(srcMatchShortEntry));
}
@@ -260,7 +257,7 @@ void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
- otLogDebgPlat("Clear ExtAddr entries", NULL);
+ otLogDebgPlat("Clear ExtAddr entries");
memset(srcMatchExtEntry, 0, sizeof(srcMatchExtEntry));
}
diff --git a/.lgtm.yml b/examples/platforms/zephyr/CMakeLists.txt
similarity index 86%
rename from .lgtm.yml
rename to examples/platforms/zephyr/CMakeLists.txt
index 9051e95d8af..dcdad63b8ce 100644
--- a/.lgtm.yml
+++ b/examples/platforms/zephyr/CMakeLists.txt
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2020, The OpenThread Authors.
+# Copyright (c) 2022, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -26,12 +26,5 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-extraction:
- cpp:
- prepare:
- packages:
- - cmake
- - ninja-build
- index:
- build_command:
- - THREAD_VERSION=1.2 NODE_MODE=rcp OT_NATIVE_IP=1 ./script/test build
+# Intentionally empty, the file is only needed to enable "zephyr" target
+# as OT platform for CMake
diff --git a/examples/platforms/zephyr/README.md b/examples/platforms/zephyr/README.md
new file mode 100644
index 00000000000..b6e9828823d
--- /dev/null
+++ b/examples/platforms/zephyr/README.md
@@ -0,0 +1,3 @@
+The OpenThread stack is integrated with ZephyrOS and nRF Connect SDK.
+
+See the [Zephyr's OpenThread platform](https://github.com/zephyrproject-rtos/zephyr/tree/main/modules/openthread) and [CLI example](https://github.com/nrfconnect/sdk-nrf/tree/main/samples/openthread/cli) for more information about the integration.
diff --git a/include/Makefile.am b/include/Makefile.am
index 722775d8e30..6ce6a7dffe0 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -68,6 +68,7 @@ openthread_headers = \
openthread/link_metrics.h \
openthread/link_raw.h \
openthread/logging.h \
+ openthread/mesh_diag.h \
openthread/message.h \
openthread/multi_radio.h \
openthread/nat64.h \
@@ -102,6 +103,7 @@ ot_platform_headers = \
openthread/platform/crypto.h \
openthread/platform/debug_uart.h \
openthread/platform/diag.h \
+ openthread/platform/dns.h \
openthread/platform/dso_transport.h \
openthread/platform/entropy.h \
openthread/platform/flash.h \
diff --git a/include/openthread/BUILD.gn b/include/openthread/BUILD.gn
index 931c7ac1242..fba1dfe9c93 100644
--- a/include/openthread/BUILD.gn
+++ b/include/openthread/BUILD.gn
@@ -72,6 +72,7 @@ source_set("openthread") {
"link_metrics.h",
"link_raw.h",
"logging.h",
+ "mesh_diag.h",
"message.h",
"multi_radio.h",
"nat64.h",
@@ -86,6 +87,7 @@ source_set("openthread") {
"platform/crypto.h",
"platform/debug_uart.h",
"platform/diag.h",
+ "platform/dns.h",
"platform/dso_transport.h",
"platform/entropy.h",
"platform/flash.h",
diff --git a/include/openthread/backbone_router_ftd.h b/include/openthread/backbone_router_ftd.h
index a6196872589..d4041d68af6 100644
--- a/include/openthread/backbone_router_ftd.h
+++ b/include/openthread/backbone_router_ftd.h
@@ -64,7 +64,14 @@ typedef enum
} otBackboneRouterState;
/**
- * This function enables or disables Backbone functionality.
+ * Enables or disables Backbone functionality.
+ *
+ * If enabled, a Server Data Request message `SRV_DATA.ntf` is triggered for the attached
+ * device if there is no Backbone Router Service in the Thread Network Data.
+ *
+ * If disabled, `SRV_DATA.ntf` is triggered if the Backbone Router is in the Primary state.
+ *
+ * Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is enabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aEnable TRUE to enable Backbone functionality, FALSE otherwise.
@@ -78,7 +85,7 @@ typedef enum
void otBackboneRouterSetEnabled(otInstance *aInstance, bool aEnable);
/**
- * This function gets the Backbone Router state.
+ * Gets the Backbone Router #otBackboneRouterState.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -95,7 +102,9 @@ void otBackboneRouterSetEnabled(otInstance *aInstance, bool aEnable);
otBackboneRouterState otBackboneRouterGetState(otInstance *aInstance);
/**
- * This function gets the local Backbone Router configuration.
+ * Gets the local Backbone Router configuration.
+ *
+ * Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is enabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aConfig A pointer where to put local Backbone Router configuration.
@@ -110,7 +119,12 @@ otBackboneRouterState otBackboneRouterGetState(otInstance *aInstance);
void otBackboneRouterGetConfig(otInstance *aInstance, otBackboneRouterConfig *aConfig);
/**
- * This function sets the local Backbone Router configuration.
+ * Sets the local Backbone Router configuration #otBackboneRouterConfig.
+ *
+ * A Server Data Request message `SRV_DATA.ntf` is initiated automatically if BBR Dataset changes for Primary
+ * Backbone Router.
+ *
+ * Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is enabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aConfig A pointer to the Backbone Router configuration to take effect.
@@ -127,7 +141,11 @@ void otBackboneRouterGetConfig(otInstance *aInstance, otBackboneRouterConfig *aC
otError otBackboneRouterSetConfig(otInstance *aInstance, const otBackboneRouterConfig *aConfig);
/**
- * This function explicitly registers local Backbone Router configuration.
+ * Explicitly registers local Backbone Router configuration.
+ *
+ * A Server Data Request message `SRV_DATA.ntf` is triggered for the attached device.
+ *
+ * Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is enabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -189,15 +207,16 @@ otError otBackboneRouterGetDomainPrefix(otInstance *aInstance, otBorderRouterCon
*
*
*/
-void otBackboneRouterConfigNextDuaRegistrationResponse(otInstance * aInstance,
+void otBackboneRouterConfigNextDuaRegistrationResponse(otInstance *aInstance,
const otIp6InterfaceIdentifier *aMlIid,
uint8_t aStatus);
/**
- * This method configures response status for next Multicast Listener Registration.
+ * Configures the response status for the next Multicast Listener Registration.
*
- * Note: available only when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled.
- * Only used for test and certification.
+ * Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE`,
+ * `OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE`, and
+ * `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` are enabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aStatus The status to respond.
@@ -223,9 +242,9 @@ typedef enum
* @param[in] aAddress The IPv6 multicast address of the Multicast Listener.
*
*/
-typedef void (*otBackboneRouterMulticastListenerCallback)(void * aContext,
+typedef void (*otBackboneRouterMulticastListenerCallback)(void *aContext,
otBackboneRouterMulticastListenerEvent aEvent,
- const otIp6Address * aAddress);
+ const otIp6Address *aAddress);
/**
* This method sets the Backbone Router Multicast Listener callback.
@@ -235,15 +254,16 @@ typedef void (*otBackboneRouterMulticastListenerCallback)(void *
* @param[in] aContext A user context pointer.
*
*/
-void otBackboneRouterSetMulticastListenerCallback(otInstance * aInstance,
+void otBackboneRouterSetMulticastListenerCallback(otInstance *aInstance,
otBackboneRouterMulticastListenerCallback aCallback,
- void * aContext);
+ void *aContext);
/**
- * This method clears the Multicast Listeners.
+ * Clears the Multicast Listeners.
*
- * Note: available only when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled.
- * Only used for test and certification.
+ * Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE`,
+ * `OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE`, and
+ * `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` are enabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -254,10 +274,13 @@ void otBackboneRouterSetMulticastListenerCallback(otInstance *
void otBackboneRouterMulticastListenerClear(otInstance *aInstance);
/**
- * This method adds a Multicast Listener.
+ * Adds a Multicast Listener with a timeout value, in seconds.
*
- * Note: available only when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled.
- * Only used for test and certification.
+ * Pass `0` to use the default MLR timeout.
+ *
+ * Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE`,
+ * `OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE`, and
+ * `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` are enabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aAddress The Multicast Listener address.
@@ -306,9 +329,9 @@ typedef struct otBackboneRouterMulticastListenerInfo
* @sa otBackboneRouterMulticastListenerAdd
*
*/
-otError otBackboneRouterMulticastListenerGetNext(otInstance * aInstance,
+otError otBackboneRouterMulticastListenerGetNext(otInstance *aInstance,
otBackboneRouterMulticastListenerIterator *aIterator,
- otBackboneRouterMulticastListenerInfo * aListenerInfo);
+ otBackboneRouterMulticastListenerInfo *aListenerInfo);
/**
* Represents the ND Proxy events.
@@ -331,9 +354,9 @@ typedef enum
* `OT_BACKBONE_ROUTER_NDPROXY_CLEARED`.
*
*/
-typedef void (*otBackboneRouterNdProxyCallback)(void * aContext,
+typedef void (*otBackboneRouterNdProxyCallback)(void *aContext,
otBackboneRouterNdProxyEvent aEvent,
- const otIp6Address * aDua);
+ const otIp6Address *aDua);
/**
* This method sets the Backbone Router ND Proxy callback.
@@ -343,9 +366,9 @@ typedef void (*otBackboneRouterNdProxyCallback)(void * aCo
* @param[in] aContext A user context pointer.
*
*/
-void otBackboneRouterSetNdProxyCallback(otInstance * aInstance,
+void otBackboneRouterSetNdProxyCallback(otInstance *aInstance,
otBackboneRouterNdProxyCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* Represents the Backbone Router ND Proxy info.
@@ -369,8 +392,8 @@ typedef struct otBackboneRouterNdProxyInfo
* @retval OT_ERROR_NOT_FOUND Failed to find the Domain Unicast Address in the ND Proxy table.
*
*/
-otError otBackboneRouterGetNdProxyInfo(otInstance * aInstance,
- const otIp6Address * aDua,
+otError otBackboneRouterGetNdProxyInfo(otInstance *aInstance,
+ const otIp6Address *aDua,
otBackboneRouterNdProxyInfo *aNdProxyInfo);
/**
@@ -392,9 +415,9 @@ typedef enum
* @param[in] aDomainPrefix The new Domain Prefix if added or changed, nullptr otherwise.
*
*/
-typedef void (*otBackboneRouterDomainPrefixCallback)(void * aContext,
+typedef void (*otBackboneRouterDomainPrefixCallback)(void *aContext,
otBackboneRouterDomainPrefixEvent aEvent,
- const otIp6Prefix * aDomainPrefix);
+ const otIp6Prefix *aDomainPrefix);
/**
* This method sets the Backbone Router Domain Prefix callback.
*
@@ -403,9 +426,9 @@ typedef void (*otBackboneRouterDomainPrefixCallback)(void *
* @param[in] aContext A user context pointer.
*
*/
-void otBackboneRouterSetDomainPrefixCallback(otInstance * aInstance,
+void otBackboneRouterSetDomainPrefixCallback(otInstance *aInstance,
otBackboneRouterDomainPrefixCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* @}
diff --git a/include/openthread/border_agent.h b/include/openthread/border_agent.h
index 83babfa142f..e412f6d8eea 100644
--- a/include/openthread/border_agent.h
+++ b/include/openthread/border_agent.h
@@ -51,6 +51,12 @@ extern "C" {
*
*/
+/**
+ * The length of Border Agent/Router ID in bytes.
+ *
+ */
+#define OT_BORDER_AGENT_ID_LENGTH (16)
+
/**
* This enumeration defines the Border Agent state.
*
@@ -82,6 +88,24 @@ otBorderAgentState otBorderAgentGetState(otInstance *aInstance);
*/
uint16_t otBorderAgentGetUdpPort(otInstance *aInstance);
+/**
+ * Gets the randomly generated Border Agent ID.
+ *
+ * The ID is saved in persistent storage and survives reboots. The typical use case of the ID is to
+ * be published in the MeshCoP mDNS service as the `id` TXT value for the client to identify this
+ * Border Router/Agent device.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[out] aId A pointer to buffer to receive the ID.
+ * @param[inout] aLength Specifies the length of `aId` when used as input and receives the length
+ * actual ID data copied to `aId` when used as output.
+ *
+ * @retval OT_ERROR_INVALID_ARGS If value of `aLength` if smaller than `OT_BORDER_AGENT_ID_LENGTH`.
+ * @retval OT_ERROR_NONE If successfully retrieved the Border Agent ID.
+ *
+ */
+otError otBorderAgentGetId(otInstance *aInstance, uint8_t *aId, uint16_t *aLength);
+
/**
* @}
*
diff --git a/include/openthread/border_router.h b/include/openthread/border_router.h
index fb7dab06536..a945f91fb29 100644
--- a/include/openthread/border_router.h
+++ b/include/openthread/border_router.h
@@ -105,9 +105,9 @@ otError otBorderRouterRemoveOnMeshPrefix(otInstance *aInstance, const otIp6Prefi
* @retval OT_ERROR_NOT_FOUND No subsequent On Mesh prefix exists in the Thread Network Data.
*
*/
-otError otBorderRouterGetNextOnMeshPrefix(otInstance * aInstance,
+otError otBorderRouterGetNextOnMeshPrefix(otInstance *aInstance,
otNetworkDataIterator *aIterator,
- otBorderRouterConfig * aConfig);
+ otBorderRouterConfig *aConfig);
/**
* Add an external route configuration to the local network data.
@@ -150,7 +150,7 @@ otError otBorderRouterRemoveRoute(otInstance *aInstance, const otIp6Prefix *aPre
* @retval OT_ERROR_NOT_FOUND No subsequent external route entry exists in the Thread Network Data.
*
*/
-otError otBorderRouterGetNextRoute(otInstance * aInstance,
+otError otBorderRouterGetNextRoute(otInstance *aInstance,
otNetworkDataIterator *aIterator,
otExternalRouteConfig *aConfig);
diff --git a/include/openthread/border_routing.h b/include/openthread/border_routing.h
index 8cfec1bdb32..961554ea5aa 100644
--- a/include/openthread/border_routing.h
+++ b/include/openthread/border_routing.h
@@ -106,6 +106,18 @@ typedef struct otBorderRoutingPrefixTableEntry
uint32_t mPreferredLifetime; ///< Preferred lifetime of the on-link prefix when `mIsOnLink` is true.
} otBorderRoutingPrefixTableEntry;
+/**
+ * This enumeration represents the state of Border Routing Manager.
+ *
+ */
+typedef enum
+{
+ OT_BORDER_ROUTING_STATE_UNINITIALIZED, ///< Routing Manager is uninitialized.
+ OT_BORDER_ROUTING_STATE_DISABLED, ///< Routing Manager is initialized but disabled.
+ OT_BORDER_ROUTING_STATE_STOPPED, ///< Routing Manager in initialized and enabled but currently stopped.
+ OT_BORDER_ROUTING_STATE_RUNNING, ///< Routing Manager is initialized, enabled, and running.
+} otBorderRoutingState;
+
/**
* This method initializes the Border Routing Manager on given infrastructure interface.
*
@@ -141,23 +153,37 @@ otError otBorderRoutingInit(otInstance *aInstance, uint32_t aInfraIfIndex, bool
otError otBorderRoutingSetEnabled(otInstance *aInstance, bool aEnabled);
/**
- * This function gets the preference used when advertising Route Info Options (e.g., for discovered OMR prefixes) in
- * Router Advertisement messages sent over the infrastructure link.
+ * Gets the current state of Border Routing Manager.
*
- * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aInstance A pointer to an OpenThread instance.
*
- * @returns The OMR prefix advertisement preference.
+ * @returns The current state of Border Routing Manager.
+ *
+ */
+otBorderRoutingState otBorderRoutingGetState(otInstance *aInstance);
+
+/**
+ * This function gets the current preference used when advertising Route Info Options (RIO) in Router Advertisement
+ * messages sent over the infrastructure link.
+ *
+ * The RIO preference is determined as follows:
+ *
+ * - If explicitly set by user by calling `otBorderRoutingSetRouteInfoOptionPreference()`, the given preference is
+ * used.
+ * - Otherwise, it is determined based on device's current role: Medium preference when in router/leader role and
+ * low preference when in child role.
+ *
+ * @returns The current Route Info Option preference.
*
*/
otRoutePreference otBorderRoutingGetRouteInfoOptionPreference(otInstance *aInstance);
/**
- * This function sets the preference to use when advertising Route Info Options in Router Advertisement messages sent
- * over the infrastructure link, for example for discovered OMR prefixes.
+ * This function explicitly sets the preference to use when advertising Route Info Options (RIO) in Router
+ * Advertisement messages sent over the infrastructure link.
*
- * By default BR will use `medium` preference level, but this function allows the default value to be changed. As an
- * example, it can be set to `low` preference in the case where device is a temporary BR (a mobile BR or a
- * battery-powered BR) to indicate that other BRs (if any) should be preferred over this BR on the infrastructure link.
+ * After a call to this function, BR will use the given preference for all its advertised RIOs. The preference can be
+ * cleared by calling `otBorderRoutingClearRouteInfoOptionPreference()`.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPreference The route preference to use.
@@ -165,6 +191,17 @@ otRoutePreference otBorderRoutingGetRouteInfoOptionPreference(otInstance *aInsta
*/
void otBorderRoutingSetRouteInfoOptionPreference(otInstance *aInstance, otRoutePreference aPreference);
+/**
+ * This function clears a previously set preference value for advertised Route Info Options.
+ *
+ * After a call to this function, BR will use device's role to determine the RIO preference: Medium preference when
+ * in router/leader role and low preference when in child role.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ */
+void otBorderRoutingClearRouteInfoOptionPreference(otInstance *aInstance);
+
/**
* Gets the local Off-Mesh-Routable (OMR) Prefix, for example `fdfc:1ff5:1512:5622::/64`.
*
@@ -190,33 +227,47 @@ otError otBorderRoutingGetOmrPrefix(otInstance *aInstance, otIp6Prefix *aPrefix)
* @param[out] aPrefix A pointer to output the favored OMR prefix.
* @param[out] aPreference A pointer to output the preference associated the favored prefix.
*
- * @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
+ * @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not running yet.
* @retval OT_ERROR_NONE Successfully retrieved the favored OMR prefix.
*
*/
otError otBorderRoutingGetFavoredOmrPrefix(otInstance *aInstance, otIp6Prefix *aPrefix, otRoutePreference *aPreference);
/**
- * Gets the On-Link Prefix for the adjacent infrastructure link, for example `fd41:2650:a6f5:0::/64`.
+ * Gets the local On-Link Prefix for the adjacent infrastructure link.
*
- * An On-Link Prefix is a 64-bit prefix that's advertised on the infrastructure link if there isn't already a usable
- * on-link prefix being advertised on the link.
+ * The local On-Link Prefix is a 64-bit prefix that's advertised on the infrastructure link if there isn't already a
+ * usable on-link prefix being advertised on the link.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aPrefix A pointer to where the prefix will be output to.
*
* @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
- * @retval OT_ERROR_NONE Successfully retrieved the on-link prefix.
+ * @retval OT_ERROR_NONE Successfully retrieved the local on-link prefix.
*
*/
otError otBorderRoutingGetOnLinkPrefix(otInstance *aInstance, otIp6Prefix *aPrefix);
+/**
+ * Gets the currently favored On-Link Prefix.
+ *
+ * The favored prefix is either a discovered on-link prefix on the infrastructure link or the local on-link prefix.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[out] aPrefix A pointer to where the prefix will be output to.
+ *
+ * @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
+ * @retval OT_ERROR_NONE Successfully retrieved the favored on-link prefix.
+ *
+ */
+otError otBorderRoutingGetFavoredOnLinkPrefix(otInstance *aInstance, otIp6Prefix *aPrefix);
+
/**
* Gets the local NAT64 Prefix of the Border Router.
*
* NAT64 Prefix might not be advertised in the Thread network.
*
- * `OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE` must be enabled.
+ * `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` must be enabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aPrefix A pointer to where the prefix will be output to.
@@ -227,6 +278,23 @@ otError otBorderRoutingGetOnLinkPrefix(otInstance *aInstance, otIp6Prefix *aPref
*/
otError otBorderRoutingGetNat64Prefix(otInstance *aInstance, otIp6Prefix *aPrefix);
+/**
+ * Gets the currently favored NAT64 prefix.
+ *
+ * The favored NAT64 prefix can be discovered from infrastructure link or can be this device's local NAT64 prefix.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[out] aPrefix A pointer to output the favored NAT64 prefix.
+ * @param[out] aPreference A pointer to output the preference associated the favored prefix.
+ *
+ * @retval OT_ERROR_INVALID_STATE The Border Routing Manager is not initialized yet.
+ * @retval OT_ERROR_NONE Successfully retrieved the favored NAT64 prefix.
+ *
+ */
+otError otBorderRoutingGetFavoredNat64Prefix(otInstance *aInstance,
+ otIp6Prefix *aPrefix,
+ otRoutePreference *aPreference);
+
/**
* This function initializes an `otBorderRoutingPrefixTableIterator`.
*
@@ -254,9 +322,9 @@ void otBorderRoutingPrefixTableInitIterator(otInstance *aInstance, otBorderRouti
* @retval OT_ERROR_NOT_FOUND No more entries in the table.
*
*/
-otError otBorderRoutingGetNextPrefixTableEntry(otInstance * aInstance,
+otError otBorderRoutingGetNextPrefixTableEntry(otInstance *aInstance,
otBorderRoutingPrefixTableIterator *aIterator,
- otBorderRoutingPrefixTableEntry * aEntry);
+ otBorderRoutingPrefixTableEntry *aEntry);
/**
* @}
diff --git a/include/openthread/channel_manager.h b/include/openthread/channel_manager.h
index f7fb8e11c88..73074580680 100644
--- a/include/openthread/channel_manager.h
+++ b/include/openthread/channel_manager.h
@@ -55,12 +55,12 @@ extern "C" {
*/
/**
- * This function requests a Thread network channel change.
+ * Requests a Thread network channel change.
*
- * The network switches to the given channel after a specified delay (see otChannelManagerSetDelay()). The channel
+ * The network switches to the given channel after a specified delay (see #otChannelManagerSetDelay()). The channel
* change is performed by updating the Pending Operational Dataset.
*
- * A subsequent call to this function will cancel an ongoing previously requested channel change.
+ * A subsequent call will cancel an ongoing previously requested channel change.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aChannel The new channel for the Thread network.
@@ -87,9 +87,9 @@ uint8_t otChannelManagerGetRequestedChannel(otInstance *aInstance);
uint16_t otChannelManagerGetDelay(otInstance *aInstance);
/**
- * This function sets the delay (in seconds) used for a channel change.
+ * Sets the delay (in seconds) used for a channel change.
*
- * The delay should preferably be longer than maximum data poll interval used by all sleepy-end-devices within the
+ * The delay should preferably be longer than the maximum data poll interval used by all sleepy-end-devices within the
* Thread network.
*
* @param[in] aInstance A pointer to an OpenThread instance.
@@ -105,7 +105,7 @@ otError otChannelManagerSetDelay(otInstance *aInstance, uint16_t aDelay);
* This function requests that `ChannelManager` checks and selects a new channel and starts a channel change.
*
* Unlike the `otChannelManagerRequestChannelChange()` where the channel must be given as a parameter, this function
- * asks the `ChannelManager` to select a channel by itself (based of collected channel quality info).
+ * asks the `ChannelManager` to select a channel by itself (based on collected channel quality info).
*
* Once called, the Channel Manager will perform the following 3 steps:
*
@@ -132,7 +132,7 @@ otError otChannelManagerSetDelay(otInstance *aInstance, uint16_t aDelay);
otError otChannelManagerRequestChannelSelect(otInstance *aInstance, bool aSkipQualityCheck);
/**
- * This function enables/disables the auto-channel-selection functionality.
+ * Enables or disables the auto-channel-selection functionality.
*
* When enabled, `ChannelManager` will periodically invoke a `RequestChannelSelect(false)`. The period interval
* can be set by `SetAutoChannelSelectionInterval()`.
@@ -154,7 +154,7 @@ void otChannelManagerSetAutoChannelSelectionEnabled(otInstance *aInstance, bool
bool otChannelManagerGetAutoChannelSelectionEnabled(otInstance *aInstance);
/**
- * This function sets the period interval (in seconds) used by auto-channel-selection functionality.
+ * Sets the period interval (in seconds) used by auto-channel-selection functionality.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aInterval The interval in seconds.
@@ -176,7 +176,7 @@ otError otChannelManagerSetAutoChannelSelectionInterval(otInstance *aInstance, u
uint32_t otChannelManagerGetAutoChannelSelectionInterval(otInstance *aInstance);
/**
- * This function gets the supported channel mask.
+ * Gets the supported channel mask.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -186,7 +186,7 @@ uint32_t otChannelManagerGetAutoChannelSelectionInterval(otInstance *aInstance);
uint32_t otChannelManagerGetSupportedChannels(otInstance *aInstance);
/**
- * This function sets the supported channel mask.
+ * Sets the supported channel mask.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aChannelMask A channel mask.
@@ -195,7 +195,7 @@ uint32_t otChannelManagerGetSupportedChannels(otInstance *aInstance);
void otChannelManagerSetSupportedChannels(otInstance *aInstance, uint32_t aChannelMask);
/**
- * This function gets the favored channel mask.
+ * Gets the favored channel mask.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -205,7 +205,7 @@ void otChannelManagerSetSupportedChannels(otInstance *aInstance, uint32_t aChann
uint32_t otChannelManagerGetFavoredChannels(otInstance *aInstance);
/**
- * This function sets the favored channel mask.
+ * Sets the favored channel mask.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aChannelMask A channel mask.
@@ -214,7 +214,7 @@ uint32_t otChannelManagerGetFavoredChannels(otInstance *aInstance);
void otChannelManagerSetFavoredChannels(otInstance *aInstance, uint32_t aChannelMask);
/**
- * This function gets the CCA failure rate threshold
+ * Gets the CCA failure rate threshold.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -224,7 +224,7 @@ void otChannelManagerSetFavoredChannels(otInstance *aInstance, uint32_t aChannel
uint16_t otChannelManagerGetCcaFailureRateThreshold(otInstance *aInstance);
/**
- * This function sets the CCA failure rate threshold
+ * Sets the CCA failure rate threshold.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aThreshold A CCA failure rate threshold. Value 0 maps to 0% and 0xffff maps to 100%.
diff --git a/include/openthread/channel_monitor.h b/include/openthread/channel_monitor.h
index 0c8929c0de5..12fa92af167 100644
--- a/include/openthread/channel_monitor.h
+++ b/include/openthread/channel_monitor.h
@@ -64,13 +64,13 @@ extern "C" {
*/
/**
- * This function enables/disables the Channel Monitoring operation.
+ * Enables or disables the Channel Monitoring operation.
*
* Once operation starts, any previously collected data is cleared. However, after operation is disabled, the previous
* collected data is still valid and can be read.
*
- * @note OpenThread core internally enables/disables the Channel Monitoring operation when the IPv6 interface is
- * brought up/down (i.e., call to `otIp6SetEnabled()`).
+ * @note OpenThread core internally enables or disables the Channel Monitoring operation when the IPv6 interface is
+ * brought up or down, for example in a call to `otIp6SetEnabled()`.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aEnabled TRUE to enable/start Channel Monitoring operation, FALSE to disable/stop it.
diff --git a/include/openthread/child_supervision.h b/include/openthread/child_supervision.h
index 5c01721655d..100e0280c15 100644
--- a/include/openthread/child_supervision.h
+++ b/include/openthread/child_supervision.h
@@ -29,7 +29,7 @@
/**
* @file
* @brief
- * This file includes the OpenThread API for child supervision feature
+ * This file includes the OpenThread API for child supervision feature.
*/
#ifndef OPENTHREAD_CHILD_SUPERVISION_H_
@@ -47,38 +47,35 @@ extern "C" {
* @brief
* This module includes functions for child supervision feature.
*
- * The functions in this module are available when child supervision feature
- * (`OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE`) is enabled.
- *
* @{
*
*/
/**
- * Get the child supervision interval (in seconds).
+ * Gets the child supervision interval (in seconds) on a child.
*
- * Child supervision feature provides a mechanism for parent to ensure that a message is sent to each sleepy child
- * within the supervision interval. If there is no transmission to the child within the supervision interval,
- * OpenThread enqueues and sends a supervision message (a data message with empty payload) to the child.
+ * Child supervision feature provides a mechanism for a sleepy child to ask its parent to ensure to send a message to
+ * it within the supervision interval. If there is no transmission to the child within the supervision interval,
+ * parent sends a supervision message (a data message with empty payload) to the child.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
- * @returns The child supervision interval. Zero indicates that child supervision is disabled.
+ * @returns The child supervision interval. Zero indicates that supervision is disabled.
*
*/
uint16_t otChildSupervisionGetInterval(otInstance *aInstance);
/**
- * Set the child supervision interval (in seconds).
+ * Sets the child supervision interval (in seconds) on the child.
*
* @param[in] aInstance A pointer to an OpenThread instance.
- * @param[in] aInterval The supervision interval (in seconds). Zero to disable supervision on parent.
+ * @param[in] aInterval The supervision interval (in seconds). Zero to disable supervision.
*
*/
void otChildSupervisionSetInterval(otInstance *aInstance, uint16_t aInterval);
/**
- * Get the supervision check timeout interval (in seconds).
+ * Gets the supervision check timeout interval (in seconds) on the child.
*
* If the device is a sleepy child and it does not hear from its parent within the specified check timeout, it initiates
* the re-attach process (MLE Child Update Request/Response exchange with its parent).
@@ -91,7 +88,7 @@ void otChildSupervisionSetInterval(otInstance *aInstance, uint16_t aInterval);
uint16_t otChildSupervisionGetCheckTimeout(otInstance *aInstance);
/**
- * Set the supervision check timeout interval (in seconds).
+ * Sets the supervision check timeout interval (in seconds).
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aTimeout The check timeout (in seconds). Zero to disable supervision check on the child.
@@ -99,6 +96,21 @@ uint16_t otChildSupervisionGetCheckTimeout(otInstance *aInstance);
*/
void otChildSupervisionSetCheckTimeout(otInstance *aInstance, uint16_t aTimeout);
+/**
+ * Get the value of supervision check timeout failure counter.
+ *
+ * The counter tracks the number of supervision check failures on the child. It is incremented when the child does
+ * not hear from its parent within the specified check timeout interval.
+ *
+ */
+uint16_t otChildSupervisionGetCheckFailureCounter(otInstance *aInstance);
+
+/**
+ * Reset the supervision check timeout failure counter to zero.
+ *
+ */
+void otChildSupervisionResetCheckFailureCounter(otInstance *aInstance);
+
/**
* @}
*
diff --git a/include/openthread/cli.h b/include/openthread/cli.h
index 3fa5c565337..e0d9e66ee88 100644
--- a/include/openthread/cli.h
+++ b/include/openthread/cli.h
@@ -52,9 +52,9 @@ extern "C" {
typedef struct otCliCommand
{
const char *mName; ///< A pointer to the command string.
- void (*mCommand)(void * aContext,
- uint8_t aArgsLength,
- char * aArgs[]); ///< A function pointer to process the command.
+ otError (*mCommand)(void *aContext,
+ uint8_t aArgsLength,
+ char *aArgs[]); ///< A function pointer to process the command.
} otCliCommand;
/**
@@ -104,8 +104,10 @@ void otCliInputLine(char *aBuf);
* @param[in] aLength @p aUserCommands length.
* @param[in] aContext @p The context passed to the handler.
*
+ * @retval OT_ERROR_NONE Successfully updated command table with commands from @p aUserCommands.
+ * @retval OT_ERROR_FAILED Maximum number of command entries have already been set.
*/
-void otCliSetUserCommands(const otCliCommand *aUserCommands, uint8_t aLength, void *aContext);
+otError otCliSetUserCommands(const otCliCommand *aUserCommands, uint8_t aLength, void *aContext);
/**
* Write a number of bytes to the CLI console as a hex string.
diff --git a/include/openthread/coap.h b/include/openthread/coap.h
index c2e036bb203..30faca6f8ad 100644
--- a/include/openthread/coap.h
+++ b/include/openthread/coap.h
@@ -341,8 +341,8 @@ typedef enum otCoapBlockSzx
* @retval OT_ERROR_RESPONSE_TIMEOUT No response or acknowledgment received during timeout period.
*
*/
-typedef void (*otCoapResponseHandler)(void * aContext,
- otMessage * aMessage,
+typedef void (*otCoapResponseHandler)(void *aContext,
+ otMessage *aMessage,
const otMessageInfo *aMessageInfo,
otError aResult);
@@ -375,7 +375,7 @@ typedef void (*otCoapRequestHandler)(void *aContext, otMessage *aMessage, const
* @retval OT_ERROR_NO_FRAME_RECEIVED Block segment missing.
*
*/
-typedef otError (*otCoapBlockwiseReceiveHook)(void * aContext,
+typedef otError (*otCoapBlockwiseReceiveHook)(void *aContext,
const uint8_t *aBlock,
uint32_t aPosition,
uint16_t aBlockLength,
@@ -402,11 +402,11 @@ typedef otError (*otCoapBlockwiseReceiveHook)(void * aContext,
* @retval OT_ERROR_INVALID_ARGS Block at @p aPosition does not exist.
*
*/
-typedef otError (*otCoapBlockwiseTransmitHook)(void * aContext,
- uint8_t * aBlock,
+typedef otError (*otCoapBlockwiseTransmitHook)(void *aContext,
+ uint8_t *aBlock,
uint32_t aPosition,
uint16_t *aBlockLength,
- bool * aMore);
+ bool *aMore);
/**
* This structure represents a CoAP resource.
@@ -414,9 +414,9 @@ typedef otError (*otCoapBlockwiseTransmitHook)(void * aContext,
*/
typedef struct otCoapResource
{
- const char * mUriPath; ///< The URI Path string
+ const char *mUriPath; ///< The URI Path string
otCoapRequestHandler mHandler; ///< The callback for handling a received request
- void * mContext; ///< Application-specific context
+ void *mContext; ///< Application-specific context
struct otCoapResource *mNext; ///< The next CoAP resource in the list
} otCoapResource;
@@ -426,7 +426,7 @@ typedef struct otCoapResource
*/
typedef struct otCoapBlockwiseResource
{
- const char * mUriPath; ///< The URI Path string
+ const char *mUriPath; ///< The URI Path string
otCoapRequestHandler mHandler; ///< The callback for handling a received request
/** The callback for handling incoming block-wise transfer.
@@ -440,7 +440,7 @@ typedef struct otCoapBlockwiseResource
* configuration is enabled.
*/
otCoapBlockwiseTransmitHook mTransmitHook;
- void * mContext; ///< Application-specific context
+ void *mContext; ///< Application-specific context
struct otCoapBlockwiseResource *mNext; ///< The next CoAP resource in the list
} otCoapBlockwiseResource;
@@ -883,11 +883,11 @@ otMessage *otCoapNewMessage(otInstance *aInstance, const otMessageSettings *aSet
* @retval OT_ERROR_NO_BUFS Failed to allocate retransmission data.
*
*/
-otError otCoapSendRequestWithParameters(otInstance * aInstance,
- otMessage * aMessage,
- const otMessageInfo * aMessageInfo,
+otError otCoapSendRequestWithParameters(otInstance *aInstance,
+ otMessage *aMessage,
+ const otMessageInfo *aMessageInfo,
otCoapResponseHandler aHandler,
- void * aContext,
+ void *aContext,
const otCoapTxParameters *aTxParameters);
/**
@@ -913,12 +913,12 @@ otError otCoapSendRequestWithParameters(otInstance * aInstance,
* @retval OT_ERROR_NO_BUFS Failed to allocate retransmission data.
*
*/
-otError otCoapSendRequestBlockWiseWithParameters(otInstance * aInstance,
- otMessage * aMessage,
- const otMessageInfo * aMessageInfo,
+otError otCoapSendRequestBlockWiseWithParameters(otInstance *aInstance,
+ otMessage *aMessage,
+ const otMessageInfo *aMessageInfo,
otCoapResponseHandler aHandler,
- void * aContext,
- const otCoapTxParameters * aTxParameters,
+ void *aContext,
+ const otCoapTxParameters *aTxParameters,
otCoapBlockwiseTransmitHook aTransmitHook,
otCoapBlockwiseReceiveHook aReceiveHook);
@@ -944,11 +944,11 @@ otError otCoapSendRequestBlockWiseWithParameters(otInstance * aIn
* @retval OT_ERROR_NO_BUFS Failed to allocate retransmission data.
*
*/
-static inline otError otCoapSendRequestBlockWise(otInstance * aInstance,
- otMessage * aMessage,
- const otMessageInfo * aMessageInfo,
+static inline otError otCoapSendRequestBlockWise(otInstance *aInstance,
+ otMessage *aMessage,
+ const otMessageInfo *aMessageInfo,
otCoapResponseHandler aHandler,
- void * aContext,
+ void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook,
otCoapBlockwiseReceiveHook aReceiveHook)
{
@@ -973,11 +973,11 @@ static inline otError otCoapSendRequestBlockWise(otInstance * aIn
* @retval OT_ERROR_NO_BUFS Failed to allocate retransmission data.
*
*/
-static inline otError otCoapSendRequest(otInstance * aInstance,
- otMessage * aMessage,
- const otMessageInfo * aMessageInfo,
+static inline otError otCoapSendRequest(otInstance *aInstance,
+ otMessage *aMessage,
+ const otMessageInfo *aMessageInfo,
otCoapResponseHandler aHandler,
- void * aContext)
+ void *aContext)
{
// NOLINTNEXTLINE(modernize-use-nullptr)
return otCoapSendRequestWithParameters(aInstance, aMessage, aMessageInfo, aHandler, aContext, NULL);
@@ -1063,9 +1063,9 @@ void otCoapSetDefaultHandler(otInstance *aInstance, otCoapRequestHandler aHandle
* @retval OT_ERROR_NO_BUFS Insufficient buffers available to send the CoAP response.
*
*/
-otError otCoapSendResponseWithParameters(otInstance * aInstance,
- otMessage * aMessage,
- const otMessageInfo * aMessageInfo,
+otError otCoapSendResponseWithParameters(otInstance *aInstance,
+ otMessage *aMessage,
+ const otMessageInfo *aMessageInfo,
const otCoapTxParameters *aTxParameters);
/**
@@ -1085,11 +1085,11 @@ otError otCoapSendResponseWithParameters(otInstance * aInstance,
* @retval OT_ERROR_NO_BUFS Insufficient buffers available to send the CoAP response.
*
*/
-otError otCoapSendResponseBlockWiseWithParameters(otInstance * aInstance,
- otMessage * aMessage,
- const otMessageInfo * aMessageInfo,
- const otCoapTxParameters * aTxParameters,
- void * aContext,
+otError otCoapSendResponseBlockWiseWithParameters(otInstance *aInstance,
+ otMessage *aMessage,
+ const otMessageInfo *aMessageInfo,
+ const otCoapTxParameters *aTxParameters,
+ void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook);
/**
@@ -1108,10 +1108,10 @@ otError otCoapSendResponseBlockWiseWithParameters(otInstance * aI
* @retval OT_ERROR_NO_BUFS Insufficient buffers available to send the CoAP response.
*
*/
-static inline otError otCoapSendResponseBlockWise(otInstance * aInstance,
- otMessage * aMessage,
- const otMessageInfo * aMessageInfo,
- void * aContext,
+static inline otError otCoapSendResponseBlockWise(otInstance *aInstance,
+ otMessage *aMessage,
+ const otMessageInfo *aMessageInfo,
+ void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook)
{
// NOLINTNEXTLINE(modernize-use-nullptr)
diff --git a/include/openthread/coap_secure.h b/include/openthread/coap_secure.h
index 5cb6bd9a02e..6f424096a59 100644
--- a/include/openthread/coap_secure.h
+++ b/include/openthread/coap_secure.h
@@ -108,7 +108,7 @@ void otCoapSecureStop(otInstance *aInstance);
* @param[in] aPskIdLength The PSK Identity Length.
*
*/
-void otCoapSecureSetPsk(otInstance * aInstance,
+void otCoapSecureSetPsk(otInstance *aInstance,
const uint8_t *aPsk,
uint16_t aPskLength,
const uint8_t *aPskIdentity,
@@ -130,9 +130,9 @@ void otCoapSecureSetPsk(otInstance * aInstance,
* @retval OT_ERROR_NO_BUFS Can't allocate memory for certificate.
*
*/
-otError otCoapSecureGetPeerCertificateBase64(otInstance * aInstance,
+otError otCoapSecureGetPeerCertificateBase64(otInstance *aInstance,
unsigned char *aPeerCert,
- size_t * aCertLength,
+ size_t *aCertLength,
size_t aCertBufferSize);
/**
@@ -160,7 +160,7 @@ void otCoapSecureSetSslAuthMode(otInstance *aInstance, bool aVerifyPeerCertifica
* @param[in] aPrivateKeyLength The length of the private key.
*
*/
-void otCoapSecureSetCertificate(otInstance * aInstance,
+void otCoapSecureSetCertificate(otInstance *aInstance,
const uint8_t *aX509Cert,
uint32_t aX509Length,
const uint8_t *aPrivateKey,
@@ -179,7 +179,7 @@ void otCoapSecureSetCertificate(otInstance * aInstance,
* @param[in] aX509CaCertChainLength The length of chain.
*
*/
-void otCoapSecureSetCaCertificateChain(otInstance * aInstance,
+void otCoapSecureSetCaCertificateChain(otInstance *aInstance,
const uint8_t *aX509CaCertificateChain,
uint32_t aX509CaCertChainLength);
@@ -195,10 +195,10 @@ void otCoapSecureSetCaCertificateChain(otInstance * aInstance,
* @retval OT_ERROR_NONE Successfully started DTLS connection.
*
*/
-otError otCoapSecureConnect(otInstance * aInstance,
- const otSockAddr * aSockAddr,
+otError otCoapSecureConnect(otInstance *aInstance,
+ const otSockAddr *aSockAddr,
otHandleCoapSecureClientConnect aHandler,
- void * aContext);
+ void *aContext);
/**
* This method stops the DTLS connection.
@@ -252,10 +252,10 @@ bool otCoapSecureIsConnectionActive(otInstance *aInstance);
* @retval OT_ERROR_INVALID_STATE DTLS connection was not initialized.
*
*/
-otError otCoapSecureSendRequestBlockWise(otInstance * aInstance,
- otMessage * aMessage,
+otError otCoapSecureSendRequestBlockWise(otInstance *aInstance,
+ otMessage *aMessage,
otCoapResponseHandler aHandler,
- void * aContext,
+ void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook,
otCoapBlockwiseReceiveHook aReceiveHook);
@@ -276,10 +276,10 @@ otError otCoapSecureSendRequestBlockWise(otInstance * aInstance,
* @retval OT_ERROR_INVALID_STATE DTLS connection was not initialized.
*
*/
-otError otCoapSecureSendRequest(otInstance * aInstance,
- otMessage * aMessage,
+otError otCoapSecureSendRequest(otInstance *aInstance,
+ otMessage *aMessage,
otCoapResponseHandler aHandler,
- void * aContext);
+ void *aContext);
/**
* This function adds a resource to the CoAP Secure server.
@@ -336,9 +336,9 @@ void otCoapSecureSetDefaultHandler(otInstance *aInstance, otCoapRequestHandler a
* @param[in] aContext A pointer to arbitrary context information. May be NULL if not used.
*
*/
-void otCoapSecureSetClientConnectedCallback(otInstance * aInstance,
+void otCoapSecureSetClientConnectedCallback(otInstance *aInstance,
otHandleCoapSecureClientConnect aHandler,
- void * aContext);
+ void *aContext);
/**
* This function sends a CoAP response block-wise from the CoAP Secure server.
@@ -356,10 +356,10 @@ void otCoapSecureSetClientConnectedCallback(otInstance * aIns
* @retval OT_ERROR_NO_BUFS Insufficient buffers available to send the CoAP response.
*
*/
-otError otCoapSecureSendResponseBlockWise(otInstance * aInstance,
- otMessage * aMessage,
- const otMessageInfo * aMessageInfo,
- void * aContext,
+otError otCoapSecureSendResponseBlockWise(otInstance *aInstance,
+ otMessage *aMessage,
+ const otMessageInfo *aMessageInfo,
+ void *aContext,
otCoapBlockwiseTransmitHook aTransmitHook);
/**
diff --git a/include/openthread/commissioner.h b/include/openthread/commissioner.h
index d632fd0ffd0..9bf09b814b3 100644
--- a/include/openthread/commissioner.h
+++ b/include/openthread/commissioner.h
@@ -170,9 +170,9 @@ typedef void (*otCommissionerStateCallback)(otCommissionerState aState, void *aC
*
*/
typedef void (*otCommissionerJoinerCallback)(otCommissionerJoinerEvent aEvent,
- const otJoinerInfo * aJoinerInfo,
- const otExtAddress * aJoinerId,
- void * aContext);
+ const otJoinerInfo *aJoinerInfo,
+ const otExtAddress *aJoinerId,
+ void *aContext);
/**
* This function enables the Thread Commissioner role.
@@ -187,10 +187,10 @@ typedef void (*otCommissionerJoinerCallback)(otCommissionerJoinerEvent aEvent,
* @retval OT_ERROR_INVALID_STATE Device is not currently attached to a network.
*
*/
-otError otCommissionerStart(otInstance * aInstance,
+otError otCommissionerStart(otInstance *aInstance,
otCommissionerStateCallback aStateCallback,
otCommissionerJoinerCallback aJoinerCallback,
- void * aCallbackContext);
+ void *aCallbackContext);
/**
* This function disables the Thread Commissioner role.
@@ -242,9 +242,9 @@ otError otCommissionerSetId(otInstance *aInstance, const char *aId);
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
*
*/
-otError otCommissionerAddJoiner(otInstance * aInstance,
+otError otCommissionerAddJoiner(otInstance *aInstance,
const otExtAddress *aEui64,
- const char * aPskd,
+ const char *aPskd,
uint32_t aTimeout);
/**
@@ -263,9 +263,9 @@ otError otCommissionerAddJoiner(otInstance * aInstance,
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
*
*/
-otError otCommissionerAddJoinerWithDiscerner(otInstance * aInstance,
+otError otCommissionerAddJoinerWithDiscerner(otInstance *aInstance,
const otJoinerDiscerner *aDiscerner,
- const char * aPskd,
+ const char *aPskd,
uint32_t aTimeout);
/**
@@ -351,7 +351,7 @@ otError otCommissionerSetProvisioningUrl(otInstance *aInstance, const char *aPro
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
*
*/
-otError otCommissionerAnnounceBegin(otInstance * aInstance,
+otError otCommissionerAnnounceBegin(otInstance *aInstance,
uint32_t aChannelMask,
uint8_t aCount,
uint16_t aPeriod,
@@ -369,7 +369,7 @@ otError otCommissionerAnnounceBegin(otInstance * aInstance,
typedef void (*otCommissionerEnergyReportCallback)(uint32_t aChannelMask,
const uint8_t *aEnergyList,
uint8_t aEnergyListLength,
- void * aContext);
+ void *aContext);
/**
* This function sends an Energy Scan Query message.
@@ -390,14 +390,14 @@ typedef void (*otCommissionerEnergyReportCallback)(uint32_t aChannelMask,
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
*
*/
-otError otCommissionerEnergyScan(otInstance * aInstance,
+otError otCommissionerEnergyScan(otInstance *aInstance,
uint32_t aChannelMask,
uint8_t aCount,
uint16_t aPeriod,
uint16_t aScanDuration,
- const otIp6Address * aAddress,
+ const otIp6Address *aAddress,
otCommissionerEnergyReportCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* This function pointer is called when the Commissioner receives a PAN ID Conflict message.
@@ -426,12 +426,12 @@ typedef void (*otCommissionerPanIdConflictCallback)(uint16_t aPanId, uint32_t aC
* @note Only use this after successfully starting the Commissioner role with otCommissionerStart().
*
*/
-otError otCommissionerPanIdQuery(otInstance * aInstance,
+otError otCommissionerPanIdQuery(otInstance *aInstance,
uint16_t aPanId,
uint32_t aChannelMask,
- const otIp6Address * aAddress,
+ const otIp6Address *aAddress,
otCommissionerPanIdConflictCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* This function sends MGMT_COMMISSIONER_GET.
@@ -460,9 +460,9 @@ otError otCommissionerSendMgmtGet(otInstance *aInstance, const uint8_t *aTlvs, u
* @retval OT_ERROR_INVALID_STATE The commissioner is not active.
*
*/
-otError otCommissionerSendMgmtSet(otInstance * aInstance,
+otError otCommissionerSendMgmtSet(otInstance *aInstance,
const otCommissioningDataset *aDataset,
- const uint8_t * aTlvs,
+ const uint8_t *aTlvs,
uint8_t aLength);
/**
diff --git a/include/openthread/crypto.h b/include/openthread/crypto.h
index 3be657bca6a..b2629267e93 100644
--- a/include/openthread/crypto.h
+++ b/include/openthread/crypto.h
@@ -55,25 +55,13 @@ extern "C" {
*
*/
-#define OT_CRYPTO_SHA256_HASH_SIZE 32 ///< Length of SHA256 hash (in bytes).
-
/**
* @struct otCryptoSha256Hash
*
* This structure represents a SHA-256 hash.
*
*/
-OT_TOOL_PACKED_BEGIN
-struct otCryptoSha256Hash
-{
- uint8_t m8[OT_CRYPTO_SHA256_HASH_SIZE]; ///< Hash bytes.
-} OT_TOOL_PACKED_END;
-
-/**
- * This structure represents a SHA-256 hash.
- *
- */
-typedef struct otCryptoSha256Hash otCryptoSha256Hash;
+typedef otPlatCryptoSha256Hash otCryptoSha256Hash;
/**
* This function performs HMAC computation.
@@ -107,37 +95,15 @@ void otCryptoHmacSha256(const otCryptoKey *aKey, const uint8_t *aBuf, uint16_t a
*/
void otCryptoAesCcm(const otCryptoKey *aKey,
uint8_t aTagLength,
- const void * aNonce,
+ const void *aNonce,
uint8_t aNonceLength,
- const void * aHeader,
+ const void *aHeader,
uint32_t aHeaderLength,
- void * aPlainText,
- void * aCipherText,
+ void *aPlainText,
+ void *aCipherText,
uint32_t aLength,
bool aEncrypt,
- void * aTag);
-
-/**
- * This method creates ECDSA sign.
- *
- * @param[out] aOutput An output buffer where ECDSA sign should be stored.
- * @param[in,out] aOutputLength The length of the @p aOutput buffer.
- * @param[in] aInputHash An input hash.
- * @param[in] aInputHashLength The length of the @p aInputHash buffer.
- * @param[in] aPrivateKey A private key in PEM format.
- * @param[in] aPrivateKeyLength The length of the @p aPrivateKey buffer.
- *
- * @retval OT_ERROR_NONE ECDSA sign has been created successfully.
- * @retval OT_ERROR_NO_BUFS Output buffer is too small.
- * @retval OT_ERROR_INVALID_ARGS Private key is not valid EC Private Key.
- * @retval OT_ERROR_FAILED Error during signing.
- */
-otError otCryptoEcdsaSign(uint8_t * aOutput,
- uint16_t * aOutputLength,
- const uint8_t *aInputHash,
- uint16_t aInputHashLength,
- const uint8_t *aPrivateKey,
- uint16_t aPrivateKeyLength);
+ void *aTag);
/**
* @}
diff --git a/include/openthread/dataset.h b/include/openthread/dataset.h
index 63e1e26adc7..efd18bc4b66 100644
--- a/include/openthread/dataset.h
+++ b/include/openthread/dataset.h
@@ -49,6 +49,8 @@ extern "C" {
*
* @{
*
+ * For FTD and MTD builds, the Operational Dataset API includes functions to manage Active and Pending datasets
+ * and dataset TLVs.
*/
#define OT_NETWORK_KEY_SIZE 16 ///< Size of the Thread Network Key (bytes)
@@ -227,7 +229,7 @@ typedef struct otTimestamp
/**
* This structure represents an Active or Pending Operational Dataset.
*
- * Components in Dataset are optional. `mComponets` structure specifies which components are present in the Dataset.
+ * Components in Dataset are optional. `mComponents` structure specifies which components are present in the Dataset.
*
*/
typedef struct otOperationalDataset
@@ -339,7 +341,7 @@ typedef void (*otDatasetMgmtSetCallback)(otError aResult, void *aContext);
bool otDatasetIsCommissioned(otInstance *aInstance);
/**
- * This function gets the Active Operational Dataset.
+ * Gets the Active Operational Dataset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aDataset A pointer to where the Active Operational Dataset will be placed.
@@ -363,7 +365,7 @@ otError otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset
otError otDatasetGetActiveTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset);
/**
- * This function sets the Active Operational Dataset.
+ * Sets the Active Operational Dataset.
*
* If the dataset does not include an Active Timestamp, the dataset is only partially complete.
*
@@ -439,7 +441,7 @@ otError otDatasetGetPending(otInstance *aInstance, otOperationalDataset *aDatase
otError otDatasetGetPendingTlvs(otInstance *aInstance, otOperationalDatasetTlvs *aDataset);
/**
- * This function sets the Pending Operational Dataset.
+ * Sets the Pending Operational Dataset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to the Pending Operational Dataset.
@@ -465,7 +467,7 @@ otError otDatasetSetPending(otInstance *aInstance, const otOperationalDataset *a
otError otDatasetSetPendingTlvs(otInstance *aInstance, const otOperationalDatasetTlvs *aDataset);
/**
- * This function sends MGMT_ACTIVE_GET.
+ * Sends MGMT_ACTIVE_GET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDatasetComponents A pointer to a Dataset Components structure specifying which components to request.
@@ -477,14 +479,14 @@ otError otDatasetSetPendingTlvs(otInstance *aInstance, const otOperationalDatase
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
*
*/
-otError otDatasetSendMgmtActiveGet(otInstance * aInstance,
+otError otDatasetSendMgmtActiveGet(otInstance *aInstance,
const otOperationalDatasetComponents *aDatasetComponents,
- const uint8_t * aTlvTypes,
+ const uint8_t *aTlvTypes,
uint8_t aLength,
- const otIp6Address * aAddress);
+ const otIp6Address *aAddress);
/**
- * This function sends MGMT_ACTIVE_SET.
+ * Sends MGMT_ACTIVE_SET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to operational dataset.
@@ -498,15 +500,15 @@ otError otDatasetSendMgmtActiveGet(otInstance * aInstan
* @retval OT_ERROR_BUSY A previous request is ongoing.
*
*/
-otError otDatasetSendMgmtActiveSet(otInstance * aInstance,
+otError otDatasetSendMgmtActiveSet(otInstance *aInstance,
const otOperationalDataset *aDataset,
- const uint8_t * aTlvs,
+ const uint8_t *aTlvs,
uint8_t aLength,
otDatasetMgmtSetCallback aCallback,
- void * aContext);
+ void *aContext);
/**
- * This function sends MGMT_PENDING_GET.
+ * Sends MGMT_PENDING_GET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDatasetComponents A pointer to a Dataset Components structure specifying which components to request.
@@ -518,14 +520,14 @@ otError otDatasetSendMgmtActiveSet(otInstance * aInstance,
* @retval OT_ERROR_NO_BUFS Insufficient buffer space to send.
*
*/
-otError otDatasetSendMgmtPendingGet(otInstance * aInstance,
+otError otDatasetSendMgmtPendingGet(otInstance *aInstance,
const otOperationalDatasetComponents *aDatasetComponents,
- const uint8_t * aTlvTypes,
+ const uint8_t *aTlvTypes,
uint8_t aLength,
- const otIp6Address * aAddress);
+ const otIp6Address *aAddress);
/**
- * This function sends MGMT_PENDING_SET.
+ * Sends MGMT_PENDING_SET.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDataset A pointer to operational dataset.
@@ -539,12 +541,12 @@ otError otDatasetSendMgmtPendingGet(otInstance * aInsta
* @retval OT_ERROR_BUSY A previous request is ongoing.
*
*/
-otError otDatasetSendMgmtPendingSet(otInstance * aInstance,
+otError otDatasetSendMgmtPendingSet(otInstance *aInstance,
const otOperationalDataset *aDataset,
- const uint8_t * aTlvs,
+ const uint8_t *aTlvs,
uint8_t aLength,
otDatasetMgmtSetCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* This function generates PSKc from a given pass-phrase, network name, and extended PAN ID.
@@ -560,15 +562,15 @@ otError otDatasetSendMgmtPendingSet(otInstance * aInstance,
* @retval OT_ERROR_INVALID_ARGS If any of the input arguments is invalid.
*
*/
-otError otDatasetGeneratePskc(const char * aPassPhrase,
- const otNetworkName * aNetworkName,
+otError otDatasetGeneratePskc(const char *aPassPhrase,
+ const otNetworkName *aNetworkName,
const otExtendedPanId *aExtPanId,
- otPskc * aPskc);
+ otPskc *aPskc);
/**
- * This function sets an `otNetworkName` instance from a given null terminated C string.
+ * Sets an `otNetworkName` instance from a given null terminated C string.
*
- * This function also validates that the given @p aNameString follows UTF-8 encoding and its length is not longer than
+ * @p aNameString must follow UTF-8 encoding and the Network Name length must not be longer than
* `OT_NETWORK_NAME_MAX_SIZE`.
*
* @param[out] aNetworkName A pointer to the `otNetworkName` to set.
@@ -581,7 +583,7 @@ otError otDatasetGeneratePskc(const char * aPassPhrase,
otError otNetworkNameFromString(otNetworkName *aNetworkName, const char *aNameString);
/**
- * This function parses an Operational Dataset from a `otOperationalDatasetTlvs`.
+ * Parses an Operational Dataset from a given `otOperationalDatasetTlvs`.
*
* @param[in] aDatasetTlvs A pointer to dataset TLVs.
* @param[out] aDataset A pointer to where the dataset will be placed.
@@ -592,6 +594,33 @@ otError otNetworkNameFromString(otNetworkName *aNetworkName, const char *aNameSt
*/
otError otDatasetParseTlvs(const otOperationalDatasetTlvs *aDatasetTlvs, otOperationalDataset *aDataset);
+/**
+ * Converts a given Operational Dataset to `otOperationalDatasetTlvs`.
+ *
+ * @param[in] aDataset An Operational dataset to convert to TLVs.
+ * @param[out] aDatasetTlvs A pointer to dataset TLVs to return the result.
+ *
+ * @retval OT_ERROR_NONE Successfully converted @p aDataset and updated @p aDatasetTlvs.
+ * @retval OT_ERROR_INVALID_ARGS @p aDataset is invalid, does not contain active or pending timestamps.
+ *
+ */
+otError otDatasetConvertToTlvs(const otOperationalDataset *aDataset, otOperationalDatasetTlvs *aDatasetTlvs);
+
+/**
+ * Updates a given Operational Dataset.
+ *
+ * @p aDataset contains the fields to be updated and their new value.
+ *
+ * @param[in] aDataset Specifies the set of types and values to update.
+ * @param[in,out] aDatasetTlvs A pointer to dataset TLVs to update.
+ *
+ * @retval OT_ERROR_NONE Successfully updated @p aDatasetTlvs.
+ * @retval OT_ERROR_INVALID_ARGS @p aDataset contains invalid values.
+ * @retval OT_ERROR_NO_BUFS Not enough space space in @p aDatasetTlvs to apply the update.
+ *
+ */
+otError otDatasetUpdateTlvs(const otOperationalDataset *aDataset, otOperationalDatasetTlvs *aDatasetTlvs);
+
/**
* @}
*
diff --git a/include/openthread/dataset_ftd.h b/include/openthread/dataset_ftd.h
index f1ae621ef6b..05e37a1b2bf 100644
--- a/include/openthread/dataset_ftd.h
+++ b/include/openthread/dataset_ftd.h
@@ -50,7 +50,7 @@ extern "C" {
*/
/**
- * This method creates a new Operational Dataset to use when forming a new network.
+ * For FTD only, creates a new Operational Dataset to use when forming a new network.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aDataset The Operational Dataset.
@@ -62,7 +62,7 @@ extern "C" {
otError otDatasetCreateNewNetwork(otInstance *aInstance, otOperationalDataset *aDataset);
/**
- * Get minimal delay timer.
+ * For FTD only, gets a minimal delay timer.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -72,7 +72,7 @@ otError otDatasetCreateNewNetwork(otInstance *aInstance, otOperationalDataset *a
uint32_t otDatasetGetDelayTimerMinimal(otInstance *aInstance);
/**
- * Set minimal delay timer.
+ * For FTD only, sets a minimal delay timer.
*
* @note This API is reserved for testing and demo purposes only. Changing settings with
* this API will render a production application non-compliant with the Thread Specification.
diff --git a/include/openthread/dataset_updater.h b/include/openthread/dataset_updater.h
index 627ddb390b8..cb16c33ac3c 100644
--- a/include/openthread/dataset_updater.h
+++ b/include/openthread/dataset_updater.h
@@ -45,20 +45,18 @@ extern "C" {
/**
* @addtogroup api-operational-dataset
*
- * @brief
- * This module includes functions for Dataset Updater.
- *
- * The functions in this module are available when Dataset Updater feature is enabled (i.e.
- * `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is set to 1). Further this feature is available only on an FTD build.
- *
* @{
*
+ * For FTD builds only, Dataset Updater includes functions to manage dataset updates.
+ *
*/
/**
* This callback function pointer is called when a Dataset update request finishes, reporting success or failure status
* of the Dataset update request.
*
+ * Available when `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is enabled.
+ *
* @param[in] aError The error status.
* OT_ERROR_NONE indicates successful Dataset update.
* OT_ERROR_INVALID_STATE indicates failure due invalid state (MLE being disabled).
@@ -73,6 +71,8 @@ typedef void (*otDatasetUpdaterCallback)(otError aError, void *aContext);
/**
* This function requests an update to Operational Dataset.
*
+ * Available when `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is enabled.
+ *
* @p aDataset should contain the fields to be updated and their new value. It must not contain Active or Pending
* Timestamp fields. The Delay field is optional, if not provided a default value (1000 ms) would be used.
*
@@ -88,14 +88,16 @@ typedef void (*otDatasetUpdaterCallback)(otError aError, void *aContext);
* @retval OT_ERROR_NO_BUFS Could not allocated buffer to save Dataset.
*
*/
-otError otDatasetUpdaterRequestUpdate(otInstance * aInstance,
+otError otDatasetUpdaterRequestUpdate(otInstance *aInstance,
const otOperationalDataset *aDataset,
otDatasetUpdaterCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* This function cancels an ongoing (if any) Operational Dataset update request.
*
+ * Available when `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is enabled.
+ *
* @param[in] aInstance A pointer to an OpenThread instance.
*
*/
@@ -104,6 +106,8 @@ void otDatasetUpdaterCancelUpdate(otInstance *aInstance);
/**
* This function indicates whether there is an ongoing Operation Dataset update request.
*
+ * Available when `OPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE` is enabled.
+ *
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval TRUE There is an ongoing update.
diff --git a/include/openthread/diag.h b/include/openthread/diag.h
index 96571f9c037..98c708e3425 100644
--- a/include/openthread/diag.h
+++ b/include/openthread/diag.h
@@ -70,8 +70,8 @@ extern "C" {
*/
otError otDiagProcessCmd(otInstance *aInstance,
uint8_t aArgsLength,
- char * aArgs[],
- char * aOutput,
+ char *aArgs[],
+ char *aOutput,
size_t aOutputMaxLen);
/**
@@ -85,8 +85,13 @@ otError otDiagProcessCmd(otInstance *aInstance,
* @param[out] aOutput The diagnostics execution result.
* @param[in] aOutputMaxLen The output buffer size.
*
+ * @retval OT_ERROR_NONE The command is successfully process.
+ * @retval OT_ERROR_INVALID_ARGS The command is supported but invalid arguments provided.
+ * @retval OT_ERROR_NOT_IMPLEMENTED The command is not supported.
+ * @retval OT_ERROR_NO_BUFS The command string is too long.
+ *
*/
-void otDiagProcessCmdLine(otInstance *aInstance, const char *aString, char *aOutput, size_t aOutputMaxLen);
+otError otDiagProcessCmdLine(otInstance *aInstance, const char *aString, char *aOutput, size_t aOutputMaxLen);
/**
* This function indicates whether or not the factory diagnostics mode is enabled.
diff --git a/include/openthread/dns.h b/include/openthread/dns.h
index 2a5dd13734d..22f3fc2b74f 100644
--- a/include/openthread/dns.h
+++ b/include/openthread/dns.h
@@ -89,7 +89,7 @@ typedef struct otDnsTxtEntry
* DNS message.
*
*/
- const char * mKey;
+ const char *mKey;
const uint8_t *mValue; ///< The TXT record value or already encoded TXT-DATA (depending on `mKey`).
uint16_t mValueLength; ///< Number of bytes in `mValue` buffer.
} otDnsTxtEntry;
diff --git a/include/openthread/dns_client.h b/include/openthread/dns_client.h
index 17817c1472d..c790bc18c00 100644
--- a/include/openthread/dns_client.h
+++ b/include/openthread/dns_client.h
@@ -80,6 +80,36 @@ typedef enum
OT_DNS_NAT64_DISALLOW = 2, ///< Do not allow NAT64 address translation during DNS client address resolution.
} otDnsNat64Mode;
+/**
+ * This enumeration type represents the service resolution mode in an `otDnsQueryConfig`.
+ *
+ * This is only used during DNS client service resolution `otDnsClientResolveService()`. It determines which
+ * record types to query.
+ *
+ */
+typedef enum
+{
+ OT_DNS_SERVICE_MODE_UNSPECIFIED = 0, ///< Mode is not specified. Use default service mode.
+ OT_DNS_SERVICE_MODE_SRV = 1, ///< Query for SRV record only.
+ OT_DNS_SERVICE_MODE_TXT = 2, ///< Query for TXT record only.
+ OT_DNS_SERVICE_MODE_SRV_TXT = 3, ///< Query for both SRV and TXT records in same message.
+ OT_DNS_SERVICE_MODE_SRV_TXT_SEPARATE = 4, ///< Query in parallel for SRV and TXT using separate messages.
+ OT_DNS_SERVICE_MODE_SRV_TXT_OPTIMIZE = 5, ///< Query for TXT/SRV together first, if fails then query separately.
+} otDnsServiceMode;
+
+/**
+ * This enumeration type represents the DNS transport protocol in an `otDnsQueryConfig`.
+ *
+ * This `OT_DNS_TRANSPORT_TCP` is only supported when `OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE` is enabled.
+ *
+ */
+typedef enum
+{
+ OT_DNS_TRANSPORT_UNSPECIFIED = 0, /// DNS transport is unspecified.
+ OT_DNS_TRANSPORT_UDP = 1, /// DNS query should be sent via UDP.
+ OT_DNS_TRANSPORT_TCP = 2, /// DNS query should be sent via TCP.
+} otDnsTransportProto;
+
/**
* This structure represents a DNS query configuration.
*
@@ -89,11 +119,13 @@ typedef enum
*/
typedef struct otDnsQueryConfig
{
- otSockAddr mServerSockAddr; ///< Server address (IPv6 address/port). All zero or zero port for unspecified.
- uint32_t mResponseTimeout; ///< Wait time (in msec) to rx response. Zero indicates unspecified value.
- uint8_t mMaxTxAttempts; ///< Maximum tx attempts before reporting failure. Zero for unspecified value.
- otDnsRecursionFlag mRecursionFlag; ///< Indicates whether the server can resolve the query recursively or not.
- otDnsNat64Mode mNat64Mode; ///< Allow/Disallow NAT64 address translation during address resolution.
+ otSockAddr mServerSockAddr; ///< Server address (IPv6 addr/port). All zero or zero port for unspecified.
+ uint32_t mResponseTimeout; ///< Wait time (in msec) to rx response. Zero indicates unspecified value.
+ uint8_t mMaxTxAttempts; ///< Maximum tx attempts before reporting failure. Zero for unspecified value.
+ otDnsRecursionFlag mRecursionFlag; ///< Indicates whether the server can resolve the query recursively or not.
+ otDnsNat64Mode mNat64Mode; ///< Allow/Disallow NAT64 address translation during address resolution.
+ otDnsServiceMode mServiceMode; ///< Determines which records to query during service resolution.
+ otDnsTransportProto mTransportProto; ///< Select default transport protocol.
} otDnsQueryConfig;
/**
@@ -203,10 +235,10 @@ typedef void (*otDnsAddressCallback)(otError aError, const otDnsAddressResponse
* @retval OT_ERROR_INVALID_STATE Cannot send query since Thread interface is not up.
*
*/
-otError otDnsClientResolveAddress(otInstance * aInstance,
- const char * aHostName,
+otError otDnsClientResolveAddress(otInstance *aInstance,
+ const char *aHostName,
otDnsAddressCallback aCallback,
- void * aContext,
+ void *aContext,
const otDnsQueryConfig *aConfig);
/**
@@ -233,10 +265,10 @@ otError otDnsClientResolveAddress(otInstance * aInstance,
* @retval OT_ERROR_INVALID_STATE Cannot send query since Thread interface is not up.
*
*/
-otError otDnsClientResolveIp4Address(otInstance * aInstance,
- const char * aHostName,
+otError otDnsClientResolveIp4Address(otInstance *aInstance,
+ const char *aHostName,
otDnsAddressCallback aCallback,
- void * aContext,
+ void *aContext,
const otDnsQueryConfig *aConfig);
/**
@@ -253,7 +285,7 @@ otError otDnsClientResolveIp4Address(otInstance * aInstance,
*
*/
otError otDnsAddressResponseGetHostName(const otDnsAddressResponse *aResponse,
- char * aNameBuffer,
+ char *aNameBuffer,
uint16_t aNameBufferSize);
/**
@@ -279,8 +311,8 @@ otError otDnsAddressResponseGetHostName(const otDnsAddressResponse *aResponse,
*/
otError otDnsAddressResponseGetAddress(const otDnsAddressResponse *aResponse,
uint16_t aIndex,
- otIp6Address * aAddress,
- uint32_t * aTtl);
+ otIp6Address *aAddress,
+ uint32_t *aTtl);
/**
* This type is an opaque representation of a response to a browse (service instance enumeration) DNS query.
@@ -318,12 +350,13 @@ typedef struct otDnsServiceInfo
uint16_t mPort; ///< Service port number.
uint16_t mPriority; ///< Service priority.
uint16_t mWeight; ///< Service weight.
- char * mHostNameBuffer; ///< Buffer to output the service host name (can be NULL if not needed).
+ char *mHostNameBuffer; ///< Buffer to output the service host name (can be NULL if not needed).
uint16_t mHostNameBufferSize; ///< Size of `mHostNameBuffer`.
otIp6Address mHostAddress; ///< The host IPv6 address. Set to all zero if not available.
uint32_t mHostAddressTtl; ///< The host address TTL.
- uint8_t * mTxtData; ///< Buffer to output TXT data (can be NULL if not needed).
- uint16_t mTxtDataSize; ///< On input, size of `mTxtData` buffer. On output `mTxtData` length.
+ uint8_t *mTxtData; ///< Buffer to output TXT data (can be NULL if not needed).
+ uint16_t mTxtDataSize; ///< On input, size of `mTxtData` buffer. On output number bytes written.
+ bool mTxtDataTruncated; ///< Indicates if TXT data could not fit in `mTxtDataSize` and was truncated.
uint32_t mTxtDataTtl; ///< The TXT data TTL.
} otDnsServiceInfo;
@@ -346,10 +379,10 @@ typedef struct otDnsServiceInfo
* @retval OT_ERROR_NO_BUFS Insufficient buffer to prepare and send query.
*
*/
-otError otDnsClientBrowse(otInstance * aInstance,
- const char * aServiceName,
+otError otDnsClientBrowse(otInstance *aInstance,
+ const char *aServiceName,
otDnsBrowseCallback aCallback,
- void * aContext,
+ void *aContext,
const otDnsQueryConfig *aConfig);
/**
@@ -366,7 +399,7 @@ otError otDnsClientBrowse(otInstance * aInstance,
*
*/
otError otDnsBrowseResponseGetServiceName(const otDnsBrowseResponse *aResponse,
- char * aNameBuffer,
+ char *aNameBuffer,
uint16_t aNameBufferSize);
/**
@@ -393,7 +426,7 @@ otError otDnsBrowseResponseGetServiceName(const otDnsBrowseResponse *aResponse,
*/
otError otDnsBrowseResponseGetServiceInstance(const otDnsBrowseResponse *aResponse,
uint16_t aIndex,
- char * aLabelBuffer,
+ char *aLabelBuffer,
uint8_t aLabelBufferSize);
/**
@@ -401,13 +434,15 @@ otError otDnsBrowseResponseGetServiceInstance(const otDnsBrowseResponse *aRespon
*
* This function MUST only be used from `otDnsBrowseCallback`.
*
- * A browse DNS response should include the SRV, TXT, and AAAA records for the service instances that are enumerated
- * (note that it is a SHOULD and not a MUST requirement). This function tries to retrieve this info for a given service
- * instance when available.
+ * A browse DNS response can include SRV, TXT, and AAAA records for the service instances that are enumerated. This is
+ * a SHOULD and not a MUST requirement, and servers/resolvers are not required to provide this. This function attempts
+ * to retrieve this info for a given service instance when available.
*
- * - If no matching SRV record is found in @p aResponse, `OT_ERROR_NOT_FOUND` is returned.
+ * - If no matching SRV record is found in @p aResponse, `OT_ERROR_NOT_FOUND` is returned. In this case, no additional
+ * records (no TXT and/or AAAA) are read.
* - If a matching SRV record is found in @p aResponse, @p aServiceInfo is updated and `OT_ERROR_NONE` is returned.
* - If no matching TXT record is found in @p aResponse, `mTxtDataSize` in @p aServiceInfo is set to zero.
+ * - If TXT data length is greater than `mTxtDataSize`, it is read partially and `mTxtDataTruncated` is set to true.
* - If no matching AAAA record is found in @p aResponse, `mHostAddress is set to all zero or unspecified address.
* - If there are multiple AAAA records for the host name in @p aResponse, `mHostAddress` is set to the first one. The
* other addresses can be retrieved using `otDnsBrowseResponseGetHostAddress()`.
@@ -423,8 +458,8 @@ otError otDnsBrowseResponseGetServiceInstance(const otDnsBrowseResponse *aRespon
*
*/
otError otDnsBrowseResponseGetServiceInfo(const otDnsBrowseResponse *aResponse,
- const char * aInstanceLabel,
- otDnsServiceInfo * aServiceInfo);
+ const char *aInstanceLabel,
+ otDnsServiceInfo *aServiceInfo);
/**
* This function gets the host IPv6 address from a DNS browse (service instance enumeration) response.
@@ -448,10 +483,10 @@ otError otDnsBrowseResponseGetServiceInfo(const otDnsBrowseResponse *aResponse,
*
*/
otError otDnsBrowseResponseGetHostAddress(const otDnsBrowseResponse *aResponse,
- const char * aHostName,
+ const char *aHostName,
uint16_t aIndex,
- otIp6Address * aAddress,
- uint32_t * aTtl);
+ otIp6Address *aAddress,
+ uint32_t *aTtl);
/**
* This type is an opaque representation of a response to a service instance resolution DNS query.
@@ -488,6 +523,18 @@ typedef void (*otDnsServiceCallback)(otError aError, const otDnsServiceResponse
* the config for this query. In a non-NULL @p aConfig, some of the fields can be left unspecified (value zero). The
* unspecified fields are then replaced by the values from the default config.
*
+ * The function sends queries for SRV and/or TXT records for the given service instance. The `mServiceMode` field in
+ * `otDnsQueryConfig` determines which records to query (SRV only, TXT only, or both SRV and TXT) and how to perform
+ * the query (together in the same message, separately in parallel, or in optimized mode where client will try in the
+ * same message first and then separately if it fails to get a response).
+ *
+ * The SRV record provides information about service port, priority, and weight along with the host name associated
+ * with the service instance. This function DOES NOT perform address resolution for the host name discovered from SRV
+ * record. The server/resolver may provide AAAA/A record(s) for the host name in the Additional Data section of the
+ * response to SRV/TXT query and this information can be retrieved using `otDnsServiceResponseGetServiceInfo()` in
+ * `otDnsServiceCallback`. Users of this API MUST NOT assume that host address will always be available from
+ * `otDnsServiceResponseGetServiceInfo()`.
+ *
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aInstanceLabel The service instance label.
* @param[in] aServiceName The service name (together with @p aInstanceLabel form full instance name).
@@ -500,11 +547,11 @@ typedef void (*otDnsServiceCallback)(otError aError, const otDnsServiceResponse
* @retval OT_ERROR_INVALID_ARGS @p aInstanceLabel is NULL.
*
*/
-otError otDnsClientResolveService(otInstance * aInstance,
- const char * aInstanceLabel,
- const char * aServiceName,
+otError otDnsClientResolveService(otInstance *aInstance,
+ const char *aInstanceLabel,
+ const char *aServiceName,
otDnsServiceCallback aCallback,
- void * aContext,
+ void *aContext,
const otDnsQueryConfig *aConfig);
/**
@@ -524,9 +571,9 @@ otError otDnsClientResolveService(otInstance * aInstance,
*
*/
otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse,
- char * aLabelBuffer,
+ char *aLabelBuffer,
uint8_t aLabelBufferSize,
- char * aNameBuffer,
+ char *aNameBuffer,
uint16_t aNameBufferSize);
/**
@@ -534,9 +581,18 @@ otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse
*
* This function MUST only be used from `otDnsServiceCallback`.
*
- * - If no matching SRV record is found in @p aResponse, `OT_ERROR_NOT_FOUND` is returned.
- * - If a matching SRV record is found in @p aResponse, @p aServiceInfo is updated and `OT_ERROR_NONE` is returned.
+ * A service resolution DNS response may include AAAA records in its Additional Data section for host name associated
+ * with the service instance that is resolved. This is a SHOULD and not a MUST requirement so servers/resolvers are
+ * not required to provide this. This function attempts to retrieve AAAA record(s) if included in the response. If it
+ * is not included `mHostAddress` is set to all zero (unspecified address). If the caller wants to resolve the host
+ * address it can call `otDnsClientResolveAddress()` with the host name to start an address resolution query.
+ *
+ * - If a matching SRV record is found in @p aResponse, @p aServiceInfo is updated.
+ * - If no matching SRV record is found, `OT_ERROR_NOT_FOUND` is returned unless the query config for this query
+ * used `OT_DNS_SERVICE_MODE_TXT` for `mServiceMode` (meaning the request was only for TXT record). In this case, we
+ * still try to parse the SRV record from Additional Data Section of response (in case server provided the info).
* - If no matching TXT record is found in @p aResponse, `mTxtDataSize` in @p aServiceInfo is set to zero.
+ * - If TXT data length is greater than `mTxtDataSize`, it is read partially and `mTxtDataTruncated` is set to true.
* - If no matching AAAA record is found in @p aResponse, `mHostAddress is set to all zero or unspecified address.
* - If there are multiple AAAA records for the host name in @p aResponse, `mHostAddress` is set to the first one. The
* other addresses can be retrieved using `otDnsServiceResponseGetHostAddress()`.
@@ -545,7 +601,7 @@ otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse
* @param[out] aServiceInfo A `ServiceInfo` to output the service instance information (MUST NOT be NULL).
*
* @retval OT_ERROR_NONE The service instance info was read. @p aServiceInfo is updated.
- * @retval OT_ERROR_NOT_FOUND Could not find a matching SRV record in @p aResponse.
+ * @retval OT_ERROR_NOT_FOUND Could not find a required record in @p aResponse.
* @retval OT_ERROR_NO_BUFS The host name and/or TXT data could not fit in the given buffers.
* @retval OT_ERROR_PARSE Could not parse the records in the @p aResponse.
*
@@ -574,10 +630,10 @@ otError otDnsServiceResponseGetServiceInfo(const otDnsServiceResponse *aResponse
*
*/
otError otDnsServiceResponseGetHostAddress(const otDnsServiceResponse *aResponse,
- const char * aHostName,
+ const char *aHostName,
uint16_t aIndex,
- otIp6Address * aAddress,
- uint32_t * aTtl);
+ otIp6Address *aAddress,
+ uint32_t *aTtl);
/**
* @}
diff --git a/include/openthread/dnssd_server.h b/include/openthread/dnssd_server.h
index 73666981ac4..cd6463c2355 100644
--- a/include/openthread/dnssd_server.h
+++ b/include/openthread/dnssd_server.h
@@ -112,15 +112,15 @@ typedef void otDnssdQuery;
*/
typedef struct otDnssdServiceInstanceInfo
{
- const char * mFullName; ///< Full instance name (e.g. "OpenThread._ipps._tcp.default.service.arpa.").
- const char * mHostName; ///< Host name (e.g. "ot-host.default.service.arpa.").
+ const char *mFullName; ///< Full instance name (e.g. "OpenThread._ipps._tcp.default.service.arpa.").
+ const char *mHostName; ///< Host name (e.g. "ot-host.default.service.arpa.").
uint8_t mAddressNum; ///< Number of host IPv6 addresses.
const otIp6Address *mAddresses; ///< Host IPv6 addresses.
uint16_t mPort; ///< Service port.
uint16_t mPriority; ///< Service priority.
uint16_t mWeight; ///< Service weight.
uint16_t mTxtLength; ///< Service TXT RDATA length.
- const uint8_t * mTxtData; ///< Service TXT RDATA.
+ const uint8_t *mTxtData; ///< Service TXT RDATA.
uint32_t mTtl; ///< Service TTL (in seconds).
} otDnssdServiceInstanceInfo;
@@ -177,10 +177,10 @@ typedef struct otDnssdCounters
* @param[in] aContext A pointer to the application-specific context.
*
*/
-void otDnssdQuerySetCallbacks(otInstance * aInstance,
+void otDnssdQuerySetCallbacks(otInstance *aInstance,
otDnssdQuerySubscribeCallback aSubscribe,
otDnssdQueryUnsubscribeCallback aUnsubscribe,
- void * aContext);
+ void *aContext);
/**
* This function notifies a discovered service instance.
@@ -195,8 +195,8 @@ void otDnssdQuerySetCallbacks(otInstance * aInstance,
* @param[in] aInstanceInfo A pointer to the discovered service instance information.
*
*/
-void otDnssdQueryHandleDiscoveredServiceInstance(otInstance * aInstance,
- const char * aServiceFullName,
+void otDnssdQueryHandleDiscoveredServiceInstance(otInstance *aInstance,
+ const char *aServiceFullName,
otDnssdServiceInstanceInfo *aInstanceInfo);
/**
* This function notifies a discovered host.
@@ -245,6 +245,35 @@ otDnssdQueryType otDnssdGetQueryTypeAndName(const otDnssdQuery *aQuery, char (*a
*/
const otDnssdCounters *otDnssdGetCounters(otInstance *aInstance);
+/**
+ * Enable or disable forwarding DNS queries to platform DNS upstream API.
+ *
+ * Available when `OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE` is enabled.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aEnabled A boolean to enable/disable forwarding DNS queries to upstream.
+ *
+ * @sa otPlatDnsStartUpstreamQuery
+ * @sa otPlatDnsCancelUpstreamQuery
+ * @sa otPlatDnsUpstreamQueryDone
+ *
+ */
+void otDnssdUpstreamQuerySetEnabled(otInstance *aInstance, bool aEnabled);
+
+/**
+ * Returns whether the DNSSD server will forward DNS queries to the platform DNS upstream API.
+ *
+ * Available when `OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE` is enabled.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @retval TRUE If the DNSSD server will forward DNS queries.
+ * @retval FALSE If the DNSSD server will not forward DNS queries.
+ *
+ * @sa otDnssdUpstreamQuerySetEnabled
+ *
+ */
+bool otDnssdUpstreamQueryIsEnabled(otInstance *aInstance);
+
/**
* @}
*
diff --git a/include/openthread/history_tracker.h b/include/openthread/history_tracker.h
index a8dc7c30150..79a255a77ac 100644
--- a/include/openthread/history_tracker.h
+++ b/include/openthread/history_tracker.h
@@ -43,7 +43,7 @@ extern "C" {
* Records the history of different events, for example RX and TX messages or network info changes. All tracked
* entries are timestamped.
*
- * The functions in this module are available when `OPENTHREAD_CONFIG_HISTOR_TRACKER_ENABLE` is enabled.
+ * The functions in this module are available when `OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE` is enabled.
*
* @{
*
@@ -152,7 +152,7 @@ typedef struct otHistoryTrackerMessageInfo
uint16_t mChecksum; ///< Message checksum (valid only for UDP/TCP/ICMP6).
uint8_t mIpProto; ///< IP Protocol number (`OT_IP6_PROTO_*` enumeration).
uint8_t mIcmp6Type; ///< ICMP6 type if msg is ICMP6, zero otherwise (`OT_ICMP6_TYPE_*` enumeration).
- int8_t mAveRxRss; ///< RSS of received message or OT_RADIO_INVALI_RSSI if not known.
+ int8_t mAveRxRss; ///< RSS of received message or OT_RADIO_INVALID_RSSI if not known.
bool mLinkSecurity : 1; ///< Indicates whether msg used link security.
bool mTxSuccess : 1; ///< Indicates TX success (e.g., ack received). Applicable for TX msg only.
uint8_t mPriority : 2; ///< Message priority (`OT_HISTORY_TRACKER_MSG_PRIORITY_*` enumeration).
@@ -192,6 +192,35 @@ typedef struct otHistoryTrackerNeighborInfo
bool mIsChild : 1; ///< Indicates whether or not the neighbor is a child.
} otHistoryTrackerNeighborInfo;
+/**
+ * This enumeration defines the events in a router info (i.e. whether router is added, removed, or changed).
+ *
+ */
+typedef enum
+{
+ OT_HISTORY_TRACKER_ROUTER_EVENT_ADDED = 0, ///< Router is added (router ID allocated).
+ OT_HISTORY_TRACKER_ROUTER_EVENT_REMOVED = 1, ///< Router entry is removed (router ID released).
+ OT_HISTORY_TRACKER_ROUTER_EVENT_NEXT_HOP_CHANGED = 2, ///< Router entry next hop and cost changed.
+ OT_HISTORY_TRACKER_ROUTER_EVENT_COST_CHANGED = 3, ///< Router entry path cost changed (next hop as before).
+} otHistoryTrackerRouterEvent;
+
+#define OT_HISTORY_TRACKER_NO_NEXT_HOP 63 ///< No next hop - For `mNextHop` in `otHistoryTrackerRouterInfo`.
+
+#define OT_HISTORY_TRACKER_INFINITE_PATH_COST 0 ///< Infinite path cost - used in `otHistoryTrackerRouterInfo`.
+
+/**
+ * This structure represents a router table entry event.
+ *
+ */
+typedef struct otHistoryTrackerRouterInfo
+{
+ uint8_t mEvent : 2; ///< Router entry event (`OT_HISTORY_TRACKER_ROUTER_EVENT_*` enumeration).
+ uint8_t mRouterId : 6; ///< Router ID.
+ uint8_t mNextHop; ///< Next Hop Router ID - `OT_HISTORY_TRACKER_NO_NEXT_HOP` if no next hop.
+ uint8_t mOldPathCost : 4; ///< Old path cost - `OT_HISTORY_TRACKER_INFINITE_PATH_COST` if infinite or unknown.
+ uint8_t mPathCost : 4; ///< New path cost - `OT_HISTORY_TRACKER_INFINITE_PATH_COST` if infinite or unknown.
+} otHistoryTrackerRouterInfo;
+
/**
* This enumeration defines the events for a Network Data entry (i.e., whether an entry is added or removed).
*
@@ -251,9 +280,9 @@ void otHistoryTrackerInitIterator(otHistoryTrackerIterator *aIterator);
* @returns A pointer to `otHistoryTrackerNetworkInfo` entry or `NULL` if no more entries in the list.
*
*/
-const otHistoryTrackerNetworkInfo *otHistoryTrackerIterateNetInfoHistory(otInstance * aInstance,
+const otHistoryTrackerNetworkInfo *otHistoryTrackerIterateNetInfoHistory(otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
- uint32_t * aEntryAge);
+ uint32_t *aEntryAge);
/**
* This function iterates over the entries in the unicast address history list.
@@ -269,9 +298,9 @@ const otHistoryTrackerNetworkInfo *otHistoryTrackerIterateNetInfoHistory(otInsta
*
*/
const otHistoryTrackerUnicastAddressInfo *otHistoryTrackerIterateUnicastAddressHistory(
- otInstance * aInstance,
+ otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
- uint32_t * aEntryAge);
+ uint32_t *aEntryAge);
/**
* This function iterates over the entries in the multicast address history list.
@@ -287,9 +316,9 @@ const otHistoryTrackerUnicastAddressInfo *otHistoryTrackerIterateUnicastAddressH
*
*/
const otHistoryTrackerMulticastAddressInfo *otHistoryTrackerIterateMulticastAddressHistory(
- otInstance * aInstance,
+ otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
- uint32_t * aEntryAge);
+ uint32_t *aEntryAge);
/**
* This function iterates over the entries in the RX message history list.
@@ -304,9 +333,9 @@ const otHistoryTrackerMulticastAddressInfo *otHistoryTrackerIterateMulticastAddr
* @returns The `otHistoryTrackerMessageInfo` entry or `NULL` if no more entries in the list.
*
*/
-const otHistoryTrackerMessageInfo *otHistoryTrackerIterateRxHistory(otInstance * aInstance,
+const otHistoryTrackerMessageInfo *otHistoryTrackerIterateRxHistory(otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
- uint32_t * aEntryAge);
+ uint32_t *aEntryAge);
/**
* This function iterates over the entries in the TX message history list.
@@ -321,9 +350,9 @@ const otHistoryTrackerMessageInfo *otHistoryTrackerIterateRxHistory(otInstance *
* @returns The `otHistoryTrackerMessageInfo` entry or `NULL` if no more entries in the list.
*
*/
-const otHistoryTrackerMessageInfo *otHistoryTrackerIterateTxHistory(otInstance * aInstance,
+const otHistoryTrackerMessageInfo *otHistoryTrackerIterateTxHistory(otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
- uint32_t * aEntryAge);
+ uint32_t *aEntryAge);
/**
* This function iterates over the entries in the neighbor history list.
@@ -338,9 +367,26 @@ const otHistoryTrackerMessageInfo *otHistoryTrackerIterateTxHistory(otInstance *
* @returns The `otHistoryTrackerNeighborInfo` entry or `NULL` if no more entries in the list.
*
*/
-const otHistoryTrackerNeighborInfo *otHistoryTrackerIterateNeighborHistory(otInstance * aInstance,
+const otHistoryTrackerNeighborInfo *otHistoryTrackerIterateNeighborHistory(otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
- uint32_t * aEntryAge);
+ uint32_t *aEntryAge);
+
+/**
+ * This function iterates over the entries in the router history list.
+ *
+ * @param[in] aInstance A pointer to the OpenThread instance.
+ * @param[in,out] aIterator A pointer to an iterator. MUST be initialized or the behavior is undefined.
+ * @param[out] aEntryAge A pointer to a variable to output the entry's age. MUST NOT be NULL.
+ * Age is provided as the duration (in milliseconds) from when entry was recorded to
+ * @p aIterator initialization time. It is set to `OT_HISTORY_TRACKER_MAX_AGE` for entries
+ * older than max age.
+ *
+ * @returns The `otHistoryTrackerRouterInfo` entry or `NULL` if no more entries in the list.
+ *
+ */
+const otHistoryTrackerRouterInfo *otHistoryTrackerIterateRouterHistory(otInstance *aInstance,
+ otHistoryTrackerIterator *aIterator,
+ uint32_t *aEntryAge);
/**
* This function iterates over the entries in the Network Data on mesh prefix entry history list.
@@ -355,9 +401,9 @@ const otHistoryTrackerNeighborInfo *otHistoryTrackerIterateNeighborHistory(otIns
* @returns The `otHistoryTrackerOnMeshPrefixInfo` entry or `NULL` if no more entries in the list.
*
*/
-const otHistoryTrackerOnMeshPrefixInfo *otHistoryTrackerIterateOnMeshPrefixHistory(otInstance * aInstance,
+const otHistoryTrackerOnMeshPrefixInfo *otHistoryTrackerIterateOnMeshPrefixHistory(otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
- uint32_t * aEntryAge);
+ uint32_t *aEntryAge);
/**
* This function iterates over the entries in the Network Data external route entry history list.
@@ -373,9 +419,9 @@ const otHistoryTrackerOnMeshPrefixInfo *otHistoryTrackerIterateOnMeshPrefixHisto
*
*/
const otHistoryTrackerExternalRouteInfo *otHistoryTrackerIterateExternalRouteHistory(
- otInstance * aInstance,
+ otInstance *aInstance,
otHistoryTrackerIterator *aIterator,
- uint32_t * aEntryAge);
+ uint32_t *aEntryAge);
/**
* This function converts a given entry age to a human-readable string.
diff --git a/include/openthread/icmp6.h b/include/openthread/icmp6.h
index cefe596e4f6..38bd6a6a166 100644
--- a/include/openthread/icmp6.h
+++ b/include/openthread/icmp6.h
@@ -66,6 +66,8 @@ typedef enum otIcmp6Type
OT_ICMP6_TYPE_ECHO_REPLY = 129, ///< Echo Reply
OT_ICMP6_TYPE_ROUTER_SOLICIT = 133, ///< Router Solicitation
OT_ICMP6_TYPE_ROUTER_ADVERT = 134, ///< Router Advertisement
+ OT_ICMP6_TYPE_NEIGHBOR_SOLICIT = 135, ///< Neighbor Solicitation
+ OT_ICMP6_TYPE_NEIGHBOR_ADVERT = 136, ///< Neighbor Advertisement
} otIcmp6Type;
/**
@@ -115,8 +117,8 @@ typedef struct otIcmp6Header otIcmp6Header;
* @param[in] aIcmpHeader A pointer to the received ICMPv6 header.
*
*/
-typedef void (*otIcmp6ReceiveCallback)(void * aContext,
- otMessage * aMessage,
+typedef void (*otIcmp6ReceiveCallback)(void *aContext,
+ otMessage *aMessage,
const otMessageInfo *aMessageInfo,
const otIcmp6Header *aIcmpHeader);
@@ -127,7 +129,7 @@ typedef void (*otIcmp6ReceiveCallback)(void * aContext,
typedef struct otIcmp6Handler
{
otIcmp6ReceiveCallback mReceiveCallback; ///< The ICMPv6 received callback
- void * mContext; ///< A pointer to arbitrary context information.
+ void *mContext; ///< A pointer to arbitrary context information.
struct otIcmp6Handler *mNext; ///< A pointer to the next handler in the list.
} otIcmp6Handler;
@@ -188,8 +190,8 @@ otError otIcmp6RegisterHandler(otInstance *aInstance, otIcmp6Handler *aHandler);
* May be zero.
*
*/
-otError otIcmp6SendEchoRequest(otInstance * aInstance,
- otMessage * aMessage,
+otError otIcmp6SendEchoRequest(otInstance *aInstance,
+ otMessage *aMessage,
const otMessageInfo *aMessageInfo,
uint16_t aIdentifier);
diff --git a/include/openthread/instance.h b/include/openthread/instance.h
index db89b62bfe6..616a1d9da40 100644
--- a/include/openthread/instance.h
+++ b/include/openthread/instance.h
@@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
-#define OPENTHREAD_API_VERSION (230)
+#define OPENTHREAD_API_VERSION (321)
/**
* @addtogroup api-instance
@@ -196,6 +196,7 @@ enum
OT_CHANGED_JOINER_STATE = 1 << 27, ///< Joiner state changed
OT_CHANGED_ACTIVE_DATASET = 1 << 28, ///< Active Operational Dataset changed
OT_CHANGED_PENDING_DATASET = 1 << 29, ///< Pending Operational Dataset changed
+ OT_CHANGED_NAT64_TRANSLATOR_STATE = 1 << 30, ///< The state of NAT64 translator changed
};
/**
@@ -250,7 +251,7 @@ void otRemoveStateChangeCallback(otInstance *aInstance, otStateChangedCallback a
void otInstanceReset(otInstance *aInstance);
/**
- * This method deletes all the settings stored on non-volatile memory, and then triggers platform reset.
+ * Deletes all the settings stored on non-volatile memory, and then triggers a platform reset.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
diff --git a/include/openthread/ip6.h b/include/openthread/ip6.h
index f624b426ee0..c04bdc2cacd 100644
--- a/include/openthread/ip6.h
+++ b/include/openthread/ip6.h
@@ -229,7 +229,7 @@ typedef struct otMessageInfo
otIp6Address mPeerAddr; ///< The peer IPv6 address.
uint16_t mSockPort; ///< The local transport-layer port.
uint16_t mPeerPort; ///< The peer transport-layer port.
- const void * mLinkInfo; ///< A pointer to link-specific information.
+ const void *mLinkInfo; ///< A pointer to link-specific information.
uint8_t mHopLimit; ///< The IPv6 Hop Limit value. Only applies if `mAllowZeroHopLimit` is FALSE.
///< If `0`, IPv6 Hop Limit is default value `OPENTHREAD_CONFIG_IP6_HOP_LIMIT_DEFAULT`.
///< Otherwise, specifies the IPv6 Hop Limit.
@@ -257,9 +257,9 @@ enum
};
/**
- * This function brings up/down the IPv6 interface.
+ * Brings the IPv6 interface up or down.
*
- * Call this function to enable/disable IPv6 communication.
+ * Call this to enable or disable IPv6 communication.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aEnabled TRUE to enable IPv6, FALSE otherwise.
@@ -272,7 +272,7 @@ enum
otError otIp6SetEnabled(otInstance *aInstance, bool aEnabled);
/**
- * This function indicates whether or not the IPv6 interface is up.
+ * Indicates whether or not the IPv6 interface is up.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -283,10 +283,10 @@ otError otIp6SetEnabled(otInstance *aInstance, bool aEnabled);
bool otIp6IsEnabled(otInstance *aInstance);
/**
- * Add a Network Interface Address to the Thread interface.
+ * Adds a Network Interface Address to the Thread interface.
*
* The passed-in instance @p aAddress is copied by the Thread interface. The Thread interface only
- * supports a fixed number of externally added unicast addresses. See OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS.
+ * supports a fixed number of externally added unicast addresses. See `OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS`.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aAddress A pointer to a Network Interface Address.
@@ -298,7 +298,7 @@ bool otIp6IsEnabled(otInstance *aInstance);
otError otIp6AddUnicastAddress(otInstance *aInstance, const otNetifAddress *aAddress);
/**
- * Remove a Network Interface Address from the Thread interface.
+ * Removes a Network Interface Address from the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aAddress A pointer to an IP Address.
@@ -310,7 +310,7 @@ otError otIp6AddUnicastAddress(otInstance *aInstance, const otNetifAddress *aAdd
otError otIp6RemoveUnicastAddress(otInstance *aInstance, const otIp6Address *aAddress);
/**
- * Get the list of IPv6 addresses assigned to the Thread interface.
+ * Gets the list of IPv6 addresses assigned to the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -319,10 +319,10 @@ otError otIp6RemoveUnicastAddress(otInstance *aInstance, const otIp6Address *aAd
const otNetifAddress *otIp6GetUnicastAddresses(otInstance *aInstance);
/**
- * Subscribe the Thread interface to a Network Interface Multicast Address.
+ * Subscribes the Thread interface to a Network Interface Multicast Address.
*
* The passed in instance @p aAddress will be copied by the Thread interface. The Thread interface only
- * supports a fixed number of externally added multicast addresses. See OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS.
+ * supports a fixed number of externally added multicast addresses. See `OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS`.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aAddress A pointer to an IP Address.
@@ -338,7 +338,7 @@ const otNetifAddress *otIp6GetUnicastAddresses(otInstance *aInstance);
otError otIp6SubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress);
/**
- * Unsubscribe the Thread interface to a Network Interface Multicast Address.
+ * Unsubscribes the Thread interface to a Network Interface Multicast Address.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aAddress A pointer to an IP Address.
@@ -351,7 +351,7 @@ otError otIp6SubscribeMulticastAddress(otInstance *aInstance, const otIp6Address
otError otIp6UnsubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress);
/**
- * Get the list of IPv6 multicast addresses subscribed to the Thread interface.
+ * Gets the list of IPv6 multicast addresses subscribed to the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -361,7 +361,7 @@ otError otIp6UnsubscribeMulticastAddress(otInstance *aInstance, const otIp6Addre
const otNetifMulticastAddress *otIp6GetMulticastAddresses(otInstance *aInstance);
/**
- * Check if multicast promiscuous mode is enabled on the Thread interface.
+ * Checks if multicast promiscuous mode is enabled on the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -371,7 +371,7 @@ const otNetifMulticastAddress *otIp6GetMulticastAddresses(otInstance *aInstance)
bool otIp6IsMulticastPromiscuousEnabled(otInstance *aInstance);
/**
- * Enable multicast promiscuous mode on the Thread interface.
+ * Enables or disables multicast promiscuous mode on the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aEnabled TRUE to enable Multicast Promiscuous mode, FALSE otherwise.
@@ -414,8 +414,8 @@ otMessage *otIp6NewMessage(otInstance *aInstance, const otMessageSettings *aSett
* @sa otMessageFree
*
*/
-otMessage *otIp6NewMessageFromBuffer(otInstance * aInstance,
- const uint8_t * aData,
+otMessage *otIp6NewMessageFromBuffer(otInstance *aInstance,
+ const uint8_t *aData,
uint16_t aDataLength,
const otMessageSettings *aSettings);
@@ -610,12 +610,27 @@ bool otIp6ArePrefixesEqual(const otIp6Prefix *aFirst, const otIp6Prefix *aSecond
* @param[in] aString A pointer to a NULL-terminated string.
* @param[out] aAddress A pointer to an IPv6 address.
*
- * @retval OT_ERROR_NONE Successfully parsed the string.
- * @retval OT_ERROR_INVALID_ARGS Failed to parse the string.
+ * @retval OT_ERROR_NONE Successfully parsed @p aString and updated @p aAddress.
+ * @retval OT_ERROR_PARSE Failed to parse @p aString as an IPv6 address.
*
*/
otError otIp6AddressFromString(const char *aString, otIp6Address *aAddress);
+/**
+ * This function converts a human-readable IPv6 prefix string into a binary representation.
+ *
+ * The @p aString parameter should be a string in the format "/", where `` is an IPv6
+ * address and `` is a prefix length.
+ *
+ * @param[in] aString A pointer to a NULL-terminated string.
+ * @param[out] aPrefix A pointer to an IPv6 prefix.
+ *
+ * @retval OT_ERROR_NONE Successfully parsed the string as an IPv6 prefix and updated @p aPrefix.
+ * @retval OT_ERROR_PARSE Failed to parse @p aString as an IPv6 prefix.
+ *
+ */
+otError otIp6PrefixFromString(const char *aString, otIp6Prefix *aPrefix);
+
#define OT_IP6_ADDRESS_STRING_SIZE 40 ///< Recommended size for string representation of an IPv6 address.
/**
@@ -638,8 +653,9 @@ void otIp6AddressToString(const otIp6Address *aAddress, char *aBuffer, uint16_t
/**
* This function converts a given IPv6 socket address to a human-readable string.
*
- * The IPv6 socket address string is formatted as "[]:" where ` is shown as 16 hex values
- * separated by ':' and `` is the port number in decimal format (i.e., "[%x:%x:...:%x]:%u")
+ * The IPv6 socket address string is formatted as [`address`]:`port` where `address` is shown
+ * as 16 hex values separated by `:` and `port` is the port number in decimal format,
+ * for example "[%x:%x:...:%x]:%u".
*
* If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated
* but the outputted string is always null-terminated.
@@ -679,6 +695,16 @@ void otIp6PrefixToString(const otIp6Prefix *aPrefix, char *aBuffer, uint16_t aSi
*/
uint8_t otIp6PrefixMatch(const otIp6Address *aFirst, const otIp6Address *aSecond);
+/**
+ * This method gets a prefix with @p aLength from @p aAddress.
+ *
+ * @param[in] aAddress A pointer to an IPv6 address.
+ * @param[in] aLength The length of prefix in bits.
+ * @param[out] aPrefix A pointer to output the IPv6 prefix.
+ *
+ */
+void otIp6GetPrefix(const otIp6Address *aAddress, uint8_t aLength, otIp6Prefix *aPrefix);
+
/**
* This function indicates whether or not a given IPv6 address is the Unspecified Address.
*
@@ -775,7 +801,7 @@ void otIp6SetSlaacPrefixFilter(otInstance *aInstance, otIp6SlaacPrefixFilter aFi
* @sa otIp6RegisterMulticastListeners
*
*/
-typedef void (*otIp6RegisterMulticastListenersCallback)(void * aContext,
+typedef void (*otIp6RegisterMulticastListenersCallback)(void *aContext,
otError aError,
uint8_t aMlrStatus,
const otIp6Address *aFailedAddresses,
@@ -809,12 +835,12 @@ typedef void (*otIp6RegisterMulticastListenersCallback)(void * aCon
* @sa otIp6RegisterMulticastListenersCallback
*
*/
-otError otIp6RegisterMulticastListeners(otInstance * aInstance,
- const otIp6Address * aAddresses,
+otError otIp6RegisterMulticastListeners(otInstance *aInstance,
+ const otIp6Address *aAddresses,
uint8_t aAddressNum,
- const uint32_t * aTimeout,
+ const uint32_t *aTimeout,
otIp6RegisterMulticastListenersCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* This function sets the Mesh Local IID (for test purpose).
@@ -840,6 +866,54 @@ otError otIp6SetMeshLocalIid(otInstance *aInstance, const otIp6InterfaceIdentifi
*/
const char *otIp6ProtoToString(uint8_t aIpProto);
+/**
+ * This structure represents the counters for packets and bytes.
+ *
+ */
+typedef struct otPacketsAndBytes
+{
+ uint64_t mPackets; ///< The number of packets.
+ uint64_t mBytes; ///< The number of bytes.
+} otPacketsAndBytes;
+
+/**
+ * This structure represents the counters of packets forwarded via Border Routing.
+ *
+ */
+typedef struct otBorderRoutingCounters
+{
+ otPacketsAndBytes mInboundUnicast; ///< The counters for inbound unicast.
+ otPacketsAndBytes mInboundMulticast; ///< The counters for inbound multicast.
+ otPacketsAndBytes mOutboundUnicast; ///< The counters for outbound unicast.
+ otPacketsAndBytes mOutboundMulticast; ///< The counters for outbound multicast.
+ uint32_t mRaRx; ///< The number of received RA packets.
+ uint32_t mRaTxSuccess; ///< The number of RA packets successfully transmitted.
+ uint32_t mRaTxFailure; ///< The number of RA packets failed to transmit.
+ uint32_t mRsRx; ///< The number of received RS packets.
+ uint32_t mRsTxSuccess; ///< The number of RS packets successfully transmitted.
+ uint32_t mRsTxFailure; ///< The number of RS packets failed to transmit.
+} otBorderRoutingCounters;
+
+/**
+ * Gets the Border Routing counters.
+ *
+ * This function requires the build-time feature `OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE` to be enabled.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ * @returns A pointer to the Border Routing counters.
+ *
+ */
+const otBorderRoutingCounters *otIp6GetBorderRoutingCounters(otInstance *aInstance);
+
+/**
+ * Resets the Border Routing counters.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ */
+void otIp6ResetBorderRoutingCounters(otInstance *aInstance);
+
/**
* @}
*
diff --git a/include/openthread/joiner.h b/include/openthread/joiner.h
index a1873f74cb2..586e88f5486 100644
--- a/include/openthread/joiner.h
+++ b/include/openthread/joiner.h
@@ -112,15 +112,15 @@ typedef void (*otJoinerCallback)(otError aError, void *aContext);
* @retval OT_ERROR_INVALID_STATE The IPv6 stack is not enabled or Thread stack is fully enabled.
*
*/
-otError otJoinerStart(otInstance * aInstance,
- const char * aPskd,
- const char * aProvisioningUrl,
- const char * aVendorName,
- const char * aVendorModel,
- const char * aVendorSwVersion,
- const char * aVendorData,
+otError otJoinerStart(otInstance *aInstance,
+ const char *aPskd,
+ const char *aProvisioningUrl,
+ const char *aVendorName,
+ const char *aVendorModel,
+ const char *aVendorSwVersion,
+ const char *aVendorData,
otJoinerCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* Disables the Thread Joiner role.
diff --git a/include/openthread/link.h b/include/openthread/link.h
index 0a7280cee66..289cf858ba7 100644
--- a/include/openthread/link.h
+++ b/include/openthread/link.h
@@ -52,7 +52,7 @@ extern "C" {
* @{
*
*/
-#define OT_US_PER_TEN_SYMBOLS 160 ///< The microseconds per 10 symbols.
+#define OT_US_PER_TEN_SYMBOLS OT_RADIO_TEN_SYMBOLS_TIME ///< Time for 10 symbols in units of microseconds
/**
* This structure represents link-specific information for messages received from the Thread radio.
@@ -430,11 +430,11 @@ typedef void (*otHandleActiveScanResult)(otActiveScanResult *aResult, void *aCon
* @retval OT_ERROR_BUSY Already performing an Active Scan.
*
*/
-otError otLinkActiveScan(otInstance * aInstance,
+otError otLinkActiveScan(otInstance *aInstance,
uint32_t aScanChannels,
uint16_t aScanDuration,
otHandleActiveScanResult aCallback,
- void * aCallbackContext);
+ void *aCallbackContext);
/**
* This function indicates whether or not an IEEE 802.15.4 Active Scan is currently in progress.
@@ -468,11 +468,11 @@ typedef void (*otHandleEnergyScanResult)(otEnergyScanResult *aResult, void *aCon
* @retval OT_ERROR_BUSY Could not start the energy scan.
*
*/
-otError otLinkEnergyScan(otInstance * aInstance,
+otError otLinkEnergyScan(otInstance *aInstance,
uint32_t aScanChannels,
uint16_t aScanDuration,
otHandleEnergyScanResult aCallback,
- void * aCallbackContext);
+ void *aCallbackContext);
/**
* This function indicates whether or not an IEEE 802.15.4 Energy Scan is currently in progress.
@@ -565,7 +565,7 @@ uint32_t otLinkGetSupportedChannelMask(otInstance *aInstance);
otError otLinkSetSupportedChannelMask(otInstance *aInstance, uint32_t aChannelMask);
/**
- * Get the IEEE 802.15.4 Extended Address.
+ * Gets the IEEE 802.15.4 Extended Address.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -575,9 +575,9 @@ otError otLinkSetSupportedChannelMask(otInstance *aInstance, uint32_t aChannelMa
const otExtAddress *otLinkGetExtendedAddress(otInstance *aInstance);
/**
- * This function sets the IEEE 802.15.4 Extended Address.
+ * Sets the IEEE 802.15.4 Extended Address.
*
- * This function succeeds only when Thread protocols are disabled.
+ * @note Only succeeds when Thread protocols are disabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aExtAddress A pointer to the IEEE 802.15.4 Extended Address.
@@ -965,7 +965,7 @@ void otLinkResetTxRetrySuccessHistogram(otInstance *aInstance);
const otMacCounters *otLinkGetCounters(otInstance *aInstance);
/**
- * Reset the MAC layer counters.
+ * Resets the MAC layer counters.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -1034,7 +1034,7 @@ otError otLinkSetPromiscuous(otInstance *aInstance, bool aPromiscuous);
uint8_t otLinkCslGetChannel(otInstance *aInstance);
/**
- * This function sets the CSL channel.
+ * Sets the CSL channel.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aChannel The CSL sample channel. Channel value should be `0` (Set CSL Channel unspecified) or
@@ -1057,7 +1057,7 @@ otError otLinkCslSetChannel(otInstance *aInstance, uint8_t aChannel);
uint16_t otLinkCslGetPeriod(otInstance *aInstance);
/**
- * This function sets the CSL period.
+ * Sets the CSL period in units of 10 symbols. Disable CSL by setting this parameter to `0`.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPeriod The CSL period in units of 10 symbols.
@@ -1079,7 +1079,7 @@ otError otLinkCslSetPeriod(otInstance *aInstance, uint16_t aPeriod);
uint32_t otLinkCslGetTimeout(otInstance *aInstance);
/**
- * This function sets the CSL timeout.
+ * Sets the CSL timeout in seconds.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aTimeout The CSL timeout in seconds.
diff --git a/include/openthread/link_metrics.h b/include/openthread/link_metrics.h
index 0b039b57ab4..fc9a7f00912 100644
--- a/include/openthread/link_metrics.h
+++ b/include/openthread/link_metrics.h
@@ -116,10 +116,10 @@ typedef enum otLinkMetricsStatus
* @param[in] aContext A pointer to application-specific context.
*
*/
-typedef void (*otLinkMetricsReportCallback)(const otIp6Address * aSource,
+typedef void (*otLinkMetricsReportCallback)(const otIp6Address *aSource,
const otLinkMetricsValues *aMetricsValues,
uint8_t aStatus,
- void * aContext);
+ void *aContext);
/**
* This function pointer is called when a Link Metrics Management Response is received.
*
@@ -140,9 +140,9 @@ typedef void (*otLinkMetricsMgmtResponseCallback)(const otIp6Address *aSource, u
*
*/
typedef void (*otLinkMetricsEnhAckProbingIeReportCallback)(otShortAddress aShortAddress,
- const otExtAddress * aExtAddress,
+ const otExtAddress *aExtAddress,
const otLinkMetricsValues *aMetricsValues,
- void * aContext);
+ void *aContext);
/**
* This function sends an MLE Data Request to query Link Metrics.
@@ -162,15 +162,15 @@ typedef void (*otLinkMetricsEnhAckProbingIeReportCallback)(otShortAddress
* @retval OT_ERROR_NOT_CAPABLE The neighbor is not a Thread 1.2 device and does not support Link Metrics.
*
*/
-otError otLinkMetricsQuery(otInstance * aInstance,
- const otIp6Address * aDestination,
+otError otLinkMetricsQuery(otInstance *aInstance,
+ const otIp6Address *aDestination,
uint8_t aSeriesId,
- const otLinkMetrics * aLinkMetricsFlags,
+ const otLinkMetrics *aLinkMetricsFlags,
otLinkMetricsReportCallback aCallback,
- void * aCallbackContext);
+ void *aCallbackContext);
/**
- * This function sends an MLE Link Metrics Management Request to configure/clear a Forward Tracking Series.
+ * Sends an MLE Link Metrics Management Request to configure or clear a Forward Tracking Series.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDestination A pointer to the destination address.
@@ -189,13 +189,13 @@ otError otLinkMetricsQuery(otInstance * aInstance,
* @retval OT_ERROR_NOT_CAPABLE The neighbor is not a Thread 1.2 device and does not support Link Metrics.
*
*/
-otError otLinkMetricsConfigForwardTrackingSeries(otInstance * aInstance,
- const otIp6Address * aDestination,
+otError otLinkMetricsConfigForwardTrackingSeries(otInstance *aInstance,
+ const otIp6Address *aDestination,
uint8_t aSeriesId,
otLinkMetricsSeriesFlags aSeriesFlags,
- const otLinkMetrics * aLinkMetricsFlags,
+ const otLinkMetrics *aLinkMetricsFlags,
otLinkMetricsMgmtResponseCallback aCallback,
- void * aCallbackContext);
+ void *aCallbackContext);
/**
* This function sends an MLE Link Metrics Management Request to configure/clear an Enhanced-ACK Based Probing.
@@ -218,17 +218,17 @@ otError otLinkMetricsConfigForwardTrackingSeries(otInstance *
* @retval OT_ERROR_NOT_CAPABLE The neighbor is not a Thread 1.2 device and does not support Link Metrics.
*
*/
-otError otLinkMetricsConfigEnhAckProbing(otInstance * aInstance,
- const otIp6Address * aDestination,
+otError otLinkMetricsConfigEnhAckProbing(otInstance *aInstance,
+ const otIp6Address *aDestination,
otLinkMetricsEnhAckFlags aEnhAckFlags,
- const otLinkMetrics * aLinkMetricsFlags,
+ const otLinkMetrics *aLinkMetricsFlags,
otLinkMetricsMgmtResponseCallback aCallback,
- void * aCallbackContext,
+ void *aCallbackContext,
otLinkMetricsEnhAckProbingIeReportCallback aEnhAckCallback,
- void * aEnhAckCallbackContext);
+ void *aEnhAckCallbackContext);
/**
- * This function sends an MLE Link Probe message.
+ * Sends an MLE Link Probe message.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDestination A pointer to the destination address.
@@ -242,7 +242,7 @@ otError otLinkMetricsConfigEnhAckProbing(otInstance *
* @retval OT_ERROR_NOT_CAPABLE The neighbor is not a Thread 1.2 device and does not support Link Metrics.
*
*/
-otError otLinkMetricsSendLinkProbe(otInstance * aInstance,
+otError otLinkMetricsSendLinkProbe(otInstance *aInstance,
const otIp6Address *aDestination,
uint8_t aSeriesId,
uint8_t aLength);
diff --git a/include/openthread/link_raw.h b/include/openthread/link_raw.h
index 02293e990df..1f43a0578bd 100644
--- a/include/openthread/link_raw.h
+++ b/include/openthread/link_raw.h
@@ -174,7 +174,7 @@ otRadioFrame *otLinkRawGetTransmitBuffer(otInstance *aInstance);
* OT_ERROR_ABORT when transmission was aborted for other reasons.
*
*/
-typedef void (*otLinkRawTransmitDone)(otInstance * aInstance,
+typedef void (*otLinkRawTransmitDone)(otInstance *aInstance,
otRadioFrame *aFrame,
otRadioFrame *aAckFrame,
otError aError);
@@ -236,12 +236,12 @@ typedef void (*otLinkRawEnergyScanDone)(otInstance *aInstance, int8_t aEnergySca
* @param[in] aCallback A pointer to a function called on completion of a scanned channel.
*
* @retval OT_ERROR_NONE Successfully started scanning the channel.
- * @retval OT_ERROR_BUSY The radio is performing enery scanning.
+ * @retval OT_ERROR_BUSY The radio is performing energy scanning.
* @retval OT_ERROR_NOT_IMPLEMENTED The radio doesn't support energy scanning.
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
*
*/
-otError otLinkRawEnergyScan(otInstance * aInstance,
+otError otLinkRawEnergyScan(otInstance *aInstance,
uint8_t aScanChannel,
uint16_t aScanDuration,
otLinkRawEnergyScanDone aCallback);
@@ -346,7 +346,7 @@ otError otLinkRawSrcMatchClearExtEntries(otInstance *aInstance);
* @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
*
*/
-otError otLinkRawSetMacKey(otInstance * aInstance,
+otError otLinkRawSetMacKey(otInstance *aInstance,
uint8_t aKeyIdMode,
uint8_t aKeyId,
const otMacKey *aPrevKey,
@@ -356,6 +356,9 @@ otError otLinkRawSetMacKey(otInstance * aInstance,
/**
* Sets the current MAC frame counter value.
*
+ * This function always sets the MAC counter to the new given value @p aMacFrameCounter independent of the current
+ * value.
+ *
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aMacFrameCounter The MAC frame counter value.
*
@@ -365,6 +368,18 @@ otError otLinkRawSetMacKey(otInstance * aInstance,
*/
otError otLinkRawSetMacFrameCounter(otInstance *aInstance, uint32_t aMacFrameCounter);
+/**
+ * Sets the current MAC frame counter value only if the new value is larger than the current one.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aMacFrameCounter The MAC frame counter value.
+ *
+ * @retval OT_ERROR_NONE If successful.
+ * @retval OT_ERROR_INVALID_STATE If the raw link-layer isn't enabled.
+ *
+ */
+otError otLinkRawSetMacFrameCounterIfLarger(otInstance *aInstance, uint32_t aMacFrameCounter);
+
/**
* Get current platform time (64bits width) of the radio chip.
*
diff --git a/include/openthread/logging.h b/include/openthread/logging.h
index b07e6436755..b581b27021e 100644
--- a/include/openthread/logging.h
+++ b/include/openthread/logging.h
@@ -86,7 +86,7 @@ otError otLoggingSetLevel(otLogLevel aLogLevel);
* @param[in] ... Arguments for the format specification.
*
*/
-void otLogCritPlat(const char *aFormat, ...);
+void otLogCritPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
/**
* This function emits a log message at warning log level.
@@ -98,7 +98,7 @@ void otLogCritPlat(const char *aFormat, ...);
* @param[in] ... Arguments for the format specification.
*
*/
-void otLogWarnPlat(const char *aFormat, ...);
+void otLogWarnPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
/**
* This function emits a log message at note log level.
@@ -110,7 +110,7 @@ void otLogWarnPlat(const char *aFormat, ...);
* @param[in] ... Arguments for the format specification.
*
*/
-void otLogNotePlat(const char *aFormat, ...);
+void otLogNotePlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
/**
* This function emits a log message at info log level.
@@ -122,7 +122,7 @@ void otLogNotePlat(const char *aFormat, ...);
* @param[in] ... Arguments for the format specification.
*
*/
-void otLogInfoPlat(const char *aFormat, ...);
+void otLogInfoPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
/**
* This function emits a log message at debug log level.
@@ -134,7 +134,7 @@ void otLogInfoPlat(const char *aFormat, ...);
* @param[in] ... Arguments for the format specification.
*
*/
-void otLogDebgPlat(const char *aFormat, ...);
+void otLogDebgPlat(const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(1, 2);
/**
* This function generates a memory dump at critical log level.
@@ -212,7 +212,7 @@ void otDumpDebgPlat(const char *aText, const void *aData, uint16_t aDataLength);
* @param[in] ... Arguments for the format specification.
*
*/
-void otLogCli(otLogLevel aLogLevel, const char *aFormat, ...);
+void otLogCli(otLogLevel aLogLevel, const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 3);
/**
* @}
diff --git a/include/openthread/mesh_diag.h b/include/openthread/mesh_diag.h
new file mode 100644
index 00000000000..dd613d1fa6e
--- /dev/null
+++ b/include/openthread/mesh_diag.h
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2023, The OpenThread Authors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ * @brief
+ * This file defines the OpenThread Mesh Diagnostic APIs.
+ */
+
+#ifndef OPENTHREAD_MESH_DIAG_H_
+#define OPENTHREAD_MESH_DIAG_H_
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup api-mesh-diag
+ *
+ * @brief
+ * This module includes definitions and functions for Mesh Diagnostics.
+ *
+ * The Mesh Diagnostics APIs require `OPENTHREAD_CONFIG_MESH_DIAG_ENABLE` and `OPENTHREAD_FTD`.
+ *
+ * @{
+ *
+ */
+
+/**
+ * This structure represents the set of configurations used when discovering mesh topology indicating which items to
+ * discover.
+ *
+ */
+typedef struct otMeshDiagDiscoverConfig
+{
+ bool mDiscoverIp6Addresses : 1; ///< Whether or not to discover IPv6 addresses of every router.
+ bool mDiscoverChildTable : 1; ///< Whether or not to discover children of every router.
+} otMeshDiagDiscoverConfig;
+
+/**
+ * This type is an opaque iterator to iterate over list of IPv6 addresses of a router.
+ *
+ * Pointers to instance of this type are provided in `otMeshDiagRouterInfo`.
+ *
+ */
+typedef struct otMeshDiagIp6AddrIterator otMeshDiagIp6AddrIterator;
+
+/**
+ * This type is an opaque iterator to iterate over list of children of a router.
+ *
+ * Pointers to instance of this type are provided in `otMeshDiagRouterInfo`.
+ *
+ */
+typedef struct otMeshDiagChildIterator otMeshDiagChildIterator;
+
+/**
+ * This constant indicates that Thread Version is unknown.
+ *
+ * This is used in `otMeshDiagRouterInfo` for `mVersion` property when device does not provide its version. This
+ * indicates that device is likely running 1.3.0 (version value 4) or earlier.
+ *
+ */
+#define OT_MESH_DIAG_VERSION_UNKNOWN 0xffff
+
+/**
+ * This type represents information about a router in Thread mesh.
+ *
+ */
+typedef struct otMeshDiagRouterInfo
+{
+ otExtAddress mExtAddress; ///< Extended MAC address.
+ uint16_t mRloc16; ///< RLOC16.
+ uint8_t mRouterId; ///< Router ID.
+ uint16_t mVersion; ///< Thread Version. `OT_MESH_DIAG_VERSION_UNKNOWN` if unknown.
+ bool mIsThisDevice : 1; ///< Whether router is this device itself.
+ bool mIsThisDeviceParent : 1; ///< Whether router is parent of this device (when device is a child).
+ bool mIsLeader : 1; ///< Whether router is leader.
+ bool mIsBorderRouter : 1; ///< Whether router acts as a border router providing ext connectivity.
+
+ /**
+ * This array provides the link quality from this router to other routers, also indicating whether a link is
+ * established between the routers.
+ *
+ * The array is indexed based on Router ID. `mLinkQualities[routerId]` indicates the incoming link quality, the
+ * router sees to the router with `routerId`. Link quality is a value in [0, 3]. Value zero indicates no link.
+ * Larger value indicate better link quality (as defined by Thread specification).
+ *
+ */
+ uint8_t mLinkQualities[OT_NETWORK_MAX_ROUTER_ID + 1];
+
+ /**
+ * A pointer to an iterator to go through the list of IPv6 addresses of the router.
+ *
+ * The pointer is valid only while `otMeshDiagRouterInfo` is valid. It can be used in `otMeshDiagGetNextIp6Address`
+ * to iterate through the IPv6 addresses.
+ *
+ * The pointer can be NULL when there was no request to discover IPv6 addresses (in `otMeshDiagDiscoverConfig`) or
+ * if the router did not provide the list.
+ *
+ */
+ otMeshDiagIp6AddrIterator *mIp6AddrIterator;
+
+ /**
+ * A pointer to an iterator to go through the list of children of the router.
+ *
+ * The pointer is valid only while `otMeshDiagRouterInfo` is valid. It can be used in `otMeshDiagGetNextChildInfo`
+ * to iterate through the children of the router.
+ *
+ * The pointer can be NULL when there was no request to discover children (in `otMeshDiagDiscoverConfig`) or
+ * if the router did not provide the list.
+ *
+ */
+ otMeshDiagChildIterator *mChildIterator;
+} otMeshDiagRouterInfo;
+
+/**
+ * This type represents information about a discovered child in Thread mesh.
+ *
+ */
+typedef struct otMeshDiagChildInfo
+{
+ uint16_t mRloc16; ///< RLOC16.
+ otLinkModeConfig mMode; ///< Device mode.
+ uint8_t mLinkQuality; ///< Incoming link quality to child from parent.
+ bool mIsThisDevice : 1; ///< Whether child is this device itself.
+ bool mIsBorderRouter : 1; ///< Whether child acts as a border router providing ext connectivity.
+} otMeshDiagChildInfo;
+
+/**
+ * This function pointer type represents the callback used by `otMeshDiagDiscoverTopology()` to provide information
+ * about a discovered router.
+ *
+ * When @p aError is `OT_ERROR_PENDING`, it indicates that the discovery is not yet finished and there will be more
+ * routers to discover and the callback will be invoked again.
+ *
+ * @param[in] aError OT_ERROR_PENDING Indicates there are more routers to be discovered.
+ * OT_ERROR_NONE Indicates this is the last router and mesh discovery is done.
+ * OT_ERROR_RESPONSE_TIMEOUT Timed out waiting for response from one or more routers.
+ * @param[in] aRouterInfo The discovered router info (can be null if `aError` is OT_ERROR_RESPONSE_TIMEOUT).
+ * @param[in] aContext Application-specific context.
+ *
+ */
+typedef void (*otMeshDiagDiscoverCallback)(otError aError, otMeshDiagRouterInfo *aRouterInfo, void *aContext);
+
+/**
+ * This function starts network topology discovery.
+ *
+ * @param[in] aInstance The OpenThread instance.
+ * @param[in] aConfig The configuration to use for discovery (e.g., which items to discover).
+ * @param[in] aCallback The callback to report the discovered routers.
+ * @param[in] aContext A context to pass in @p aCallback.
+ *
+ * @retval OT_ERROR_NONE The network topology discovery started successfully.
+ * @retval OT_ERROR_BUSY A previous discovery request is still ongoing.
+ * @retval OT_ERROR_INVALID_STATE Device is not attached.
+ * @retval OT_ERROR_NO_BUFS Could not allocate buffer to send discovery messages.
+ *
+ */
+otError otMeshDiagDiscoverTopology(otInstance *aInstance,
+ const otMeshDiagDiscoverConfig *aConfig,
+ otMeshDiagDiscoverCallback aCallback,
+ void *aContext);
+
+/**
+ * This function cancels an ongoing topology discovery if there is one, otherwise no action.
+ *
+ * When ongoing discovery is cancelled, the callback from `otMeshDiagDiscoverTopology()` will not be called anymore.
+ *
+ */
+void otMeshDiagCancel(otInstance *aInstance);
+
+/**
+ * This function iterates through the discovered IPv6 address of a router.
+ *
+ * @param[in,out] aIterator The address iterator to use.
+ * @param[out] aIp6Address A pointer to return the next IPv6 address (if any).
+ *
+ * @retval OT_ERROR_NONE Successfully retrieved the next address. @p aIp6Address and @p aIterator are updated.
+ * @retval OT_ERROR_NOT_FOUND No more address. Reached the end of the list.
+ *
+ */
+otError otMeshDiagGetNextIp6Address(otMeshDiagIp6AddrIterator *aIterator, otIp6Address *aIp6Address);
+
+/**
+ * This function iterates through the discovered children of a router.
+ *
+ * @param[in,out] aIterator The address iterator to use.
+ * @param[out] aChildInfo A pointer to return the child info (if any).
+ *
+ * @retval OT_ERROR_NONE Successfully retrieved the next child. @p aChildInfo and @p aIterator are updated.
+ * @retval OT_ERROR_NOT_FOUND No more child. Reached the end of the list.
+ *
+ */
+otError otMeshDiagGetNextChildInfo(otMeshDiagChildIterator *aIterator, otMeshDiagChildInfo *aChildInfo);
+
+/**
+ * @}
+ *
+ */
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // OPENTHREAD_MESH_DIAG_H_
diff --git a/include/openthread/message.h b/include/openthread/message.h
index d94c176e4aa..0826ddb3177 100644
--- a/include/openthread/message.h
+++ b/include/openthread/message.h
@@ -287,8 +287,16 @@ typedef struct otMessageQueueInfo
*/
typedef struct otBufferInfo
{
- uint16_t mTotalBuffers; ///< The total number of buffers in the messages pool (0xffff if unknown).
- uint16_t mFreeBuffers; ///< The number of free buffers (0xffff if unknown).
+ uint16_t mTotalBuffers; ///< The total number of buffers in the messages pool (0xffff if unknown).
+ uint16_t mFreeBuffers; ///< The number of free buffers (0xffff if unknown).
+
+ /**
+ * The maximum number of used buffers at the same time since OT stack initialization or last call to
+ * `otMessageResetBufferInfo()`.
+ *
+ */
+ uint16_t mMaxUsedBuffers;
+
otMessageQueueInfo m6loSendQueue; ///< Info about 6LoWPAN send queue.
otMessageQueueInfo m6loReassemblyQueue; ///< Info about 6LoWPAN reassembly queue.
otMessageQueueInfo mIp6Queue; ///< Info about IPv6 send queue.
@@ -369,6 +377,16 @@ otMessage *otMessageQueueGetNext(otMessageQueue *aQueue, const otMessage *aMessa
*/
void otMessageGetBufferInfo(otInstance *aInstance, otBufferInfo *aBufferInfo);
+/**
+ * Reset the Message Buffer information counter tracking the maximum number buffers in use at the same time.
+ *
+ * This resets `mMaxUsedBuffers` in `otBufferInfo`.
+ *
+ * @param[in] aInstance A pointer to the OpenThread instance.
+ *
+ */
+void otMessageResetBufferInfo(otInstance *aInstance);
+
/**
* @}
*
diff --git a/include/openthread/multi_radio.h b/include/openthread/multi_radio.h
index 744b1c080b0..13930f58c5f 100644
--- a/include/openthread/multi_radio.h
+++ b/include/openthread/multi_radio.h
@@ -85,8 +85,8 @@ typedef struct otMultiRadioNeighborInfo
* @retval OT_ERROR_NOT_FOUND Could not find a neighbor with @p aExtAddress.
*
*/
-otError otMultiRadioGetNeighborInfo(otInstance * aInstance,
- const otExtAddress * aExtAddress,
+otError otMultiRadioGetNeighborInfo(otInstance *aInstance,
+ const otExtAddress *aExtAddress,
otMultiRadioNeighborInfo *aNeighborInfo);
/**
diff --git a/include/openthread/nat64.h b/include/openthread/nat64.h
index 55bef4df9f8..cd1eec2996e 100644
--- a/include/openthread/nat64.h
+++ b/include/openthread/nat64.h
@@ -35,6 +35,7 @@
#ifndef OPENTHREAD_NAT64_H_
#define OPENTHREAD_NAT64_H_
+#include
#include
#ifdef __cplusplus
@@ -45,7 +46,7 @@ extern "C" {
* @addtogroup api-nat64
*
* @brief This module includes functions and structs for the NAT64 function on the border router. These functions are
- * only available when `OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE` is enabled.
+ * only available when `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is enabled.
*
* @{
*
@@ -87,6 +88,407 @@ typedef struct otIp4Cidr
uint8_t mLength;
} otIp4Cidr;
+/**
+ * Represents the counters for NAT64.
+ *
+ */
+typedef struct otNat64Counters
+{
+ uint64_t m4To6Packets; ///< Number of packets translated from IPv4 to IPv6.
+ uint64_t m4To6Bytes; ///< Sum of size of packets translated from IPv4 to IPv6.
+ uint64_t m6To4Packets; ///< Number of packets translated from IPv6 to IPv4.
+ uint64_t m6To4Bytes; ///< Sum of size of packets translated from IPv6 to IPv4.
+} otNat64Counters;
+
+/**
+ * Represents the counters for the protocols supported by NAT64.
+ *
+ */
+typedef struct otNat64ProtocolCounters
+{
+ otNat64Counters mTotal; ///< Counters for sum of all protocols.
+ otNat64Counters mIcmp; ///< Counters for ICMP and ICMPv6.
+ otNat64Counters mUdp; ///< Counters for UDP.
+ otNat64Counters mTcp; ///< Counters for TCP.
+} otNat64ProtocolCounters;
+
+/**
+ * Packet drop reasons.
+ *
+ */
+typedef enum otNat64DropReason
+{
+ OT_NAT64_DROP_REASON_UNKNOWN = 0, ///< Packet drop for unknown reasons.
+ OT_NAT64_DROP_REASON_ILLEGAL_PACKET, ///< Packet drop due to failed to parse the datagram.
+ OT_NAT64_DROP_REASON_UNSUPPORTED_PROTO, ///< Packet drop due to unsupported IP protocol.
+ OT_NAT64_DROP_REASON_NO_MAPPING, ///< Packet drop due to no mappings found or mapping pool exhausted.
+ //---
+ OT_NAT64_DROP_REASON_COUNT,
+} otNat64DropReason;
+
+/**
+ * Represents the counters of dropped packets due to errors when handling NAT64 packets.
+ *
+ */
+typedef struct otNat64ErrorCounters
+{
+ uint64_t mCount4To6[OT_NAT64_DROP_REASON_COUNT]; ///< Errors translating IPv4 packets.
+ uint64_t mCount6To4[OT_NAT64_DROP_REASON_COUNT]; ///< Errors translating IPv6 packets.
+} otNat64ErrorCounters;
+
+/**
+ * Gets NAT64 translator counters.
+ *
+ * The counter is counted since the instance initialized.
+ *
+ * Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[out] aCounters A pointer to an `otNat64Counters` where the counters of NAT64 translator will be placed.
+ *
+ */
+void otNat64GetCounters(otInstance *aInstance, otNat64ProtocolCounters *aCounters);
+
+/**
+ * Gets the NAT64 translator error counters.
+ *
+ * The counters are initialized to zero when the OpenThread instance is initialized.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[out] aCounters A pointer to an `otNat64Counters` where the counters of NAT64 translator will be placed.
+ *
+ */
+void otNat64GetErrorCounters(otInstance *aInstance, otNat64ErrorCounters *aCounters);
+
+/**
+ * Represents an address mapping record for NAT64.
+ *
+ * @note The counters will be reset for each mapping session even for the same address pair. Applications can use `mId`
+ * to identify different sessions to calculate the packets correctly.
+ *
+ */
+typedef struct otNat64AddressMapping
+{
+ uint64_t mId; ///< The unique id for a mapping session.
+
+ otIp4Address mIp4; ///< The IPv4 address of the mapping.
+ otIp6Address mIp6; ///< The IPv6 address of the mapping.
+ uint32_t mRemainingTimeMs; ///< Remaining time before expiry in milliseconds.
+
+ otNat64ProtocolCounters mCounters;
+} otNat64AddressMapping;
+
+/**
+ * Used to iterate through NAT64 address mappings.
+ *
+ * The fields in this type are opaque (intended for use by OpenThread core only) and therefore should not be
+ * accessed or used by caller.
+ *
+ * Before using an iterator, it MUST be initialized using `otNat64AddressMappingIteratorInit()`.
+ *
+ */
+typedef struct otNat64AddressMappingIterator
+{
+ void *mPtr;
+} otNat64AddressMappingIterator;
+
+/**
+ * Initializes an `otNat64AddressMappingIterator`.
+ *
+ * An iterator MUST be initialized before it is used.
+ *
+ * An iterator can be initialized again to restart from the beginning of the mapping info.
+ *
+ * @param[in] aInstance The OpenThread instance.
+ * @param[out] aIterator A pointer to the iterator to initialize.
+ *
+ */
+void otNat64InitAddressMappingIterator(otInstance *aInstance, otNat64AddressMappingIterator *aIterator);
+
+/**
+ * Gets the next AddressMapping info (using an iterator).
+ *
+ * Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in,out] aIterator A pointer to the iterator. On success the iterator will be updated to point to next
+ * NAT64 address mapping record. To get the first entry the iterator should be set to
+ * OT_NAT64_ADDRESS_MAPPING_ITERATOR_INIT.
+ * @param[out] aMapping A pointer to an `otNat64AddressMapping` where information of next NAT64 address
+ * mapping record is placed (on success).
+ *
+ * @retval OT_ERROR_NONE Successfully found the next NAT64 address mapping info (@p aMapping was successfully
+ * updated).
+ * @retval OT_ERROR_NOT_FOUND No subsequent NAT64 address mapping info was found.
+ *
+ */
+otError otNat64GetNextAddressMapping(otInstance *aInstance,
+ otNat64AddressMappingIterator *aIterator,
+ otNat64AddressMapping *aMapping);
+
+/**
+ * States of NAT64.
+ *
+ */
+typedef enum
+{
+ OT_NAT64_STATE_DISABLED = 0, ///< NAT64 is disabled.
+ OT_NAT64_STATE_NOT_RUNNING, ///< NAT64 is enabled, but one or more dependencies of NAT64 are not running.
+ OT_NAT64_STATE_IDLE, ///< NAT64 is enabled, but this BR is not an active NAT64 BR.
+ OT_NAT64_STATE_ACTIVE, ///< The BR is publishing a NAT64 prefix and/or translating packets.
+} otNat64State;
+
+/**
+ * Gets the state of NAT64 translator.
+ *
+ * Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ * @retval OT_NAT64_STATE_DISABLED NAT64 translator is disabled.
+ * @retval OT_NAT64_STATE_NOT_RUNNING NAT64 translator is enabled, but the translator is not configured with a valid
+ * NAT64 prefix and a CIDR.
+ * @retval OT_NAT64_STATE_ACTIVE NAT64 translator is enabled, and is translating packets.
+ *
+ */
+otNat64State otNat64GetTranslatorState(otInstance *aInstance);
+
+/**
+ * Gets the state of NAT64 prefix manager.
+ *
+ * Available when `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is enabled.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ * @retval OT_NAT64_STATE_DISABLED NAT64 prefix manager is disabled.
+ * @retval OT_NAT64_STATE_NOT_RUNNING NAT64 prefix manager is enabled, but is not running (because the routing manager
+ * is not running).
+ * @retval OT_NAT64_STATE_IDLE NAT64 prefix manager is enabled, but is not publishing a NAT64 prefix. Usually
+ * when there is another border router publishing a NAT64 prefix with higher
+ * priority.
+ * @retval OT_NAT64_STATE_ACTIVE NAT64 prefix manager is enabled, and is publishing NAT64 prefix to the Thread
+ * network.
+ *
+ */
+otNat64State otNat64GetPrefixManagerState(otInstance *aInstance);
+
+/**
+ * Enable or disable NAT64 functions.
+ *
+ * Note: This includes the NAT64 Translator (when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled) and the NAT64
+ * Prefix Manager (when `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is enabled).
+ *
+ * When `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled, setting disabled to true resets the
+ * mapping table in the translator.
+ *
+ * Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` or `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is
+ * enabled.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aEnabled A boolean to enable/disable the NAT64 functions
+ *
+ * @sa otNat64GetTranslatorState
+ * @sa otNat64GetPrefixManagerState
+ *
+ */
+void otNat64SetEnabled(otInstance *aInstance, bool aEnable);
+
+/**
+ * Allocate a new message buffer for sending an IPv4 message to the NAT64 translator.
+ *
+ * Message buffers allocated by this function will have 20 bytes (difference between the size of IPv6 headers
+ * and IPv4 header sizes) reserved.
+ *
+ * Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
+ *
+ * @note If @p aSettings is `NULL`, the link layer security is enabled and the message priority is set to
+ * OT_MESSAGE_PRIORITY_NORMAL by default.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aSettings A pointer to the message settings or NULL to set default settings.
+ *
+ * @returns A pointer to the message buffer or NULL if no message buffers are available or parameters are invalid.
+ *
+ * @sa otNat64Send
+ *
+ */
+otMessage *otIp4NewMessage(otInstance *aInstance, const otMessageSettings *aSettings);
+
+/**
+ * Sets the CIDR used when setting the source address of the outgoing translated IPv4 packets.
+ *
+ * This function is available only when OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE is enabled.
+ *
+ * @note A valid CIDR must have a non-zero prefix length. The actual addresses pool is limited by the size of the
+ * mapping pool and the number of addresses available in the CIDR block.
+ *
+ * @note This function can be called at any time, but the NAT64 translator will be reset and all existing sessions will
+ * be expired when updating the configured CIDR.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aCidr A pointer to an otIp4Cidr for the IPv4 CIDR block for NAT64.
+ *
+ * @retval OT_ERROR_INVALID_ARGS The given CIDR is not a valid IPv4 CIDR for NAT64.
+ * @retval OT_ERROR_NONE Successfully set the CIDR for NAT64.
+ *
+ * @sa otBorderRouterSend
+ * @sa otBorderRouterSetReceiveCallback
+ *
+ */
+otError otNat64SetIp4Cidr(otInstance *aInstance, const otIp4Cidr *aCidr);
+
+/**
+ * Translates an IPv4 datagram to an IPv6 datagram and sends via the Thread interface.
+ *
+ * The caller transfers ownership of @p aMessage when making this call. OpenThread will free @p aMessage when
+ * processing is complete, including when a value other than `OT_ERROR_NONE` is returned.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aMessage A pointer to the message buffer containing the IPv4 datagram.
+ *
+ * @retval OT_ERROR_NONE Successfully processed the message.
+ * @retval OT_ERROR_DROP Message was well-formed but not fully processed due to packet processing
+ * rules.
+ * @retval OT_ERROR_NO_BUFS Could not allocate necessary message buffers when processing the datagram.
+ * @retval OT_ERROR_NO_ROUTE No route to host.
+ * @retval OT_ERROR_INVALID_SOURCE_ADDRESS Source address is invalid, e.g. an anycast address or a multicast address.
+ * @retval OT_ERROR_PARSE Encountered a malformed header when processing the message.
+ *
+ */
+otError otNat64Send(otInstance *aInstance, otMessage *aMessage);
+
+/**
+ * This function pointer is called when an IPv4 datagram (translated by NAT64 translator) is received.
+ *
+ * @param[in] aMessage A pointer to the message buffer containing the received IPv6 datagram. This function transfers
+ * the ownership of the @p aMessage to the receiver of the callback. The message should be
+ * freed by the receiver of the callback after it is processed.
+ * @param[in] aContext A pointer to application-specific context.
+ *
+ */
+typedef void (*otNat64ReceiveIp4Callback)(otMessage *aMessage, void *aContext);
+
+/**
+ * Registers a callback to provide received IPv4 datagrams.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aCallback A pointer to a function that is called when an IPv4 datagram is received or
+ * NULL to disable the callback.
+ * @param[in] aCallbackContext A pointer to application-specific context.
+ *
+ */
+void otNat64SetReceiveIp4Callback(otInstance *aInstance, otNat64ReceiveIp4Callback aCallback, void *aContext);
+
+/**
+ * Gets the IPv4 CIDR configured in the NAT64 translator.
+ *
+ * Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[out] aCidr A pointer to an otIp4Cidr. Where the CIDR will be filled.
+ *
+ */
+otError otNat64GetCidr(otInstance *aInstance, otIp4Cidr *aCidr);
+
+/**
+ * Test if two IPv4 addresses are the same.
+ *
+ * @param[in] aFirst A pointer to the first IPv4 address to compare.
+ * @param[in] aSecond A pointer to the second IPv4 address to compare.
+ *
+ * @retval TRUE The two IPv4 addresses are the same.
+ * @retval FALSE The two IPv4 addresses are not the same.
+ *
+ */
+bool otIp4IsAddressEqual(const otIp4Address *aFirst, const otIp4Address *aSecond);
+
+/**
+ * Set @p aIp4Address by performing NAT64 address translation from @p aIp6Address as specified
+ * in RFC 6052.
+ *
+ * The NAT64 @p aPrefixLength MUST be one of the following values: 32, 40, 48, 56, 64, or 96, otherwise the behavior
+ * of this method is undefined.
+ *
+ * @param[in] aPrefixLength The prefix length to use for IPv4/IPv6 translation.
+ * @param[in] aIp6Address A pointer to an IPv6 address.
+ * @param[out] aIp4Address A pointer to output the IPv4 address.
+ *
+ */
+void otIp4ExtractFromIp6Address(uint8_t aPrefixLength, const otIp6Address *aIp6Address, otIp4Address *aIp4Address);
+
+#define OT_IP4_ADDRESS_STRING_SIZE 17 ///< Length of 000.000.000.000 plus a suffix NUL
+
+/**
+ * Converts the address to a string.
+ *
+ * The string format uses quad-dotted notation of four bytes in the address (e.g., "127.0.0.1").
+ *
+ * If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be
+ * truncated but the outputted string is always null-terminated.
+ *
+ * @param[in] aAddress A pointer to an IPv4 address (MUST NOT be NULL).
+ * @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be `nullptr`).
+ * @param[in] aSize The size of @p aBuffer (in bytes).
+ *
+ */
+void otIp4AddressToString(const otIp4Address *aAddress, char *aBuffer, uint16_t aSize);
+
+#define OT_IP4_CIDR_STRING_SIZE 20 ///< Length of 000.000.000.000/00 plus a suffix NUL
+
+/**
+ * This function converts a human-readable IPv4 CIDR string into a binary representation.
+ *
+ * @param[in] aString A pointer to a NULL-terminated string.
+ * @param[out] aCidr A pointer to an IPv4 CIDR.
+ *
+ * @retval OT_ERROR_NONE Successfully parsed the string.
+ * @retval OT_ERROR_INVALID_ARGS Failed to parse the string.
+ *
+ */
+otError otIp4CidrFromString(const char *aString, otIp4Cidr *aCidr);
+
+/**
+ * Converts the IPv4 CIDR to a string.
+ *
+ * The string format uses quad-dotted notation of four bytes in the address with the length of prefix (e.g.,
+ * "127.0.0.1/32").
+ *
+ * If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be
+ * truncated but the outputted string is always null-terminated.
+ *
+ * @param[in] aCidr A pointer to an IPv4 CIDR (MUST NOT be NULL).
+ * @param[out] aBuffer A pointer to a char array to output the string (MUST NOT be `nullptr`).
+ * @param[in] aSize The size of @p aBuffer (in bytes).
+ *
+ */
+void otIp4CidrToString(const otIp4Cidr *aCidr, char *aBuffer, uint16_t aSize);
+
+/**
+ * Converts a human-readable IPv4 address string into a binary representation.
+ *
+ * @param[in] aString A pointer to a NULL-terminated string.
+ * @param[out] aAddress A pointer to an IPv4 address.
+ *
+ * @retval OT_ERROR_NONE Successfully parsed the string.
+ * @retval OT_ERROR_INVALID_ARGS Failed to parse the string.
+ *
+ */
+otError otIp4AddressFromString(const char *aString, otIp4Address *aAddress);
+
+/**
+ * Sets the IPv6 address by performing NAT64 address translation from the preferred NAT64 prefix and the given IPv4
+ * address as specified in RFC 6052.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aIp4Address A pointer to the IPv4 address to translate to IPv6.
+ * @param[out] aIp6Address A pointer to the synthesized IPv6 address.
+ *
+ * @returns OT_ERROR_NONE Successfully synthesized the IPv6 address from NAT64 prefix and IPv4 address.
+ * @returns OT_ERROR_INVALID_STATE No valid NAT64 prefix in the network data.
+ *
+ */
+otError otNat64SynthesizeIp6Address(otInstance *aInstance, const otIp4Address *aIp4Address, otIp6Address *aIp6Address);
+
/**
* @}
*
diff --git a/include/openthread/ncp.h b/include/openthread/ncp.h
index 72896723c68..4576c7fd330 100644
--- a/include/openthread/ncp.h
+++ b/include/openthread/ncp.h
@@ -158,94 +158,9 @@ typedef bool (*otNcpDelegateAllowPeekPoke)(uint32_t aAddress, uint16_t aCount);
* @param[in] aAllowPokeDelegate Delegate function pointer for poke operation.
*
*/
-void otNcpRegisterPeekPokeDelagates(otNcpDelegateAllowPeekPoke aAllowPeekDelegate,
+void otNcpRegisterPeekPokeDelegates(otNcpDelegateAllowPeekPoke aAllowPeekDelegate,
otNcpDelegateAllowPeekPoke aAllowPokeDelegate);
-//-----------------------------------------------------------------------------------------
-// Legacy network APIs
-
-#define OT_NCP_LEGACY_ULA_PREFIX_LENGTH 8 ///< Legacy ULA size (in bytes)
-
-/**
- * Defines handler (function pointer) type for starting legacy network
- *
- * Invoked to start the legacy network.
- *
- */
-typedef void (*otNcpHandlerStartLegacy)(void);
-
-/**
- * Defines handler (function pointer) type for stopping legacy network
- *
- * Invoked to stop the legacy network.
- *
- */
-typedef void (*otNcpHandlerStopLegacy)(void);
-
-/**
- * Defines handler (function pointer) type for initiating joining process.
- *
- * @param[in] aExtAddress A pointer to the extended address for the node to join
- * or NULL if desired to join any neighboring node.
- *
- * Invoked to initiate a legacy join procedure to any or a specific node.
- *
- */
-typedef void (*otNcpHandlerJoinLegacyNode)(const otExtAddress *aExtAddress);
-
-/**
- * Defines handler (function pointer) type for setting the legacy ULA prefix.
- *
- * @param[in] aUlaPrefix A pointer to buffer containing the legacy ULA prefix.
- *
- * Invoked to set the legacy ULA prefix.
- *
- */
-typedef void (*otNcpHandlerSetLegacyUlaPrefix)(const uint8_t *aUlaPrefix);
-
-/**
- * Defines a struct containing all the legacy handlers (function pointers).
- *
- */
-typedef struct otNcpLegacyHandlers
-{
- otNcpHandlerStartLegacy mStartLegacy; ///< Start handler
- otNcpHandlerStopLegacy mStopLegacy; ///< Stop handler
- otNcpHandlerJoinLegacyNode mJoinLegacyNode; ///< Join handler
- otNcpHandlerSetLegacyUlaPrefix mSetLegacyUlaPrefix; ///< Set ULA handler
-} otNcpLegacyHandlers;
-
-/**
- * This callback is invoked by the legacy stack to notify that a new
- * legacy node did join the network.
- *
- * @param[in] aExtAddr A pointer to the extended address of the joined node.
- *
- */
-void otNcpHandleLegacyNodeDidJoin(const otExtAddress *aExtAddr);
-
-/**
- * This callback is invoked by the legacy stack to notify that the
- * legacy ULA prefix has changed.
- *
- * @param[in] aUlaPrefix A pointer to the received ULA prefix.
- *
- */
-void otNcpHandleDidReceiveNewLegacyUlaPrefix(const uint8_t *aUlaPrefix);
-
-/**
- * This method registers a set of legacy handlers with NCP.
- *
- * The set of handlers provided by the struct @p aHandlers are used by
- * NCP code to start/stop legacy network.
- * The @p aHandlers can be NULL to disable legacy support on NCP.
- * Individual handlers in the given handlers struct can also be NULL.
- *
- * @param[in] aHandlers A pointer to a handler struct.
- *
- */
-void otNcpRegisterLegacyHandlers(const otNcpLegacyHandlers *aHandlers);
-
/**
* @}
*
diff --git a/include/openthread/netdata.h b/include/openthread/netdata.h
index 74b92e89d87..ba999211495 100644
--- a/include/openthread/netdata.h
+++ b/include/openthread/netdata.h
@@ -71,6 +71,17 @@ typedef struct otBorderRouterConfig
uint16_t mRloc16; ///< The border router's RLOC16 (value ignored on config add).
} otBorderRouterConfig;
+/**
+ * This structure represents 6LoWPAN Context ID information associated with a prefix in Network Data.
+ *
+ */
+typedef struct otLowpanContextInfo
+{
+ uint8_t mContextId; ///< The 6LoWPAN Context ID.
+ bool mCompressFlag; ///< The compress flag.
+ otIp6Prefix mPrefix; ///< The associated IPv6 prefix.
+} otLowpanContextInfo;
+
/**
* This structure represents an External Route configuration.
*
@@ -125,7 +136,7 @@ typedef struct otServiceConfig
} otServiceConfig;
/**
- * This method provides a full or stable copy of the Partition's Thread Network Data.
+ * Provide full or stable copy of the Partition's Thread Network Data.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aStable TRUE when copying the stable version, FALSE when copying the full version.
@@ -133,11 +144,45 @@ typedef struct otServiceConfig
* @param[in,out] aDataLength On entry, size of the data buffer pointed to by @p aData.
* On exit, number of copied bytes.
*
+ * @retval OT_ERROR_NONE Successfully copied the Thread Network Data into @p aData and updated @p aDataLength.
+ * @retval OT_ERROR_NO_BUFS Not enough space in @p aData to fully copy the Thread Network Data.
+ *
*/
otError otNetDataGet(otInstance *aInstance, bool aStable, uint8_t *aData, uint8_t *aDataLength);
/**
- * This function gets the next On Mesh Prefix in the partition's Network Data.
+ * Get the current length (number of bytes) of Partition's Thread Network Data.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ * @return The length of the Network Data.
+ *
+ */
+uint8_t otNetDataGetLength(otInstance *aInstance);
+
+/**
+ * Get the maximum observed length of the Thread Network Data since OT stack initialization or since the last call to
+ * `otNetDataResetMaxLength()`.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ * @return The maximum length of the Network Data (high water mark for Network Data length).
+ *
+ */
+uint8_t otNetDataGetMaxLength(otInstance *aInstance);
+
+/**
+ * Reset the tracked maximum length of the Thread Network Data.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ * @sa otNetDataGetMaxLength
+ *
+ */
+void otNetDataResetMaxLength(otInstance *aInstance);
+
+/**
+ * Get the next On Mesh Prefix in the partition's Network Data.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first on-mesh entry
@@ -148,12 +193,12 @@ otError otNetDataGet(otInstance *aInstance, bool aStable, uint8_t *aData, uint8_
* @retval OT_ERROR_NOT_FOUND No subsequent On Mesh prefix exists in the Thread Network Data.
*
*/
-otError otNetDataGetNextOnMeshPrefix(otInstance * aInstance,
+otError otNetDataGetNextOnMeshPrefix(otInstance *aInstance,
otNetworkDataIterator *aIterator,
- otBorderRouterConfig * aConfig);
+ otBorderRouterConfig *aConfig);
/**
- * This function gets the next external route in the partition's Network Data.
+ * Get the next external route in the partition's Network Data.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first external route entry
@@ -167,7 +212,7 @@ otError otNetDataGetNextOnMeshPrefix(otInstance * aInstance,
otError otNetDataGetNextRoute(otInstance *aInstance, otNetworkDataIterator *aIterator, otExternalRouteConfig *aConfig);
/**
- * This function gets the next service in the partition's Network Data.
+ * Get the next service in the partition's Network Data.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in,out] aIterator A pointer to the Network Data iterator context. To get the first service entry
@@ -180,6 +225,22 @@ otError otNetDataGetNextRoute(otInstance *aInstance, otNetworkDataIterator *aIte
*/
otError otNetDataGetNextService(otInstance *aInstance, otNetworkDataIterator *aIterator, otServiceConfig *aConfig);
+/**
+ * Get the next 6LoWPAN Context ID info in the partition's Network Data.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in,out] aIterator A pointer to the Network Data iterator. To get the first service entry
+ it should be set to OT_NETWORK_DATA_ITERATOR_INIT.
+ * @param[out] aContextInfo A pointer to where the retrieved 6LoWPAN Context ID information will be placed.
+ *
+ * @retval OT_ERROR_NONE Successfully found the next 6LoWPAN Context ID info.
+ * @retval OT_ERROR_NOT_FOUND No subsequent 6LoWPAN Context info exists in the partition's Network Data.
+ *
+ */
+otError otNetDataGetNextLowpanContextInfo(otInstance *aInstance,
+ otNetworkDataIterator *aIterator,
+ otLowpanContextInfo *aContextInfo);
+
/**
* Get the Network Data Version.
*
@@ -227,12 +288,11 @@ struct otJoinerDiscerner;
* @retval OT_ERROR_NOT_FOUND @p aDiscerner is not included in the steering data.
*
*/
-otError otNetDataSteeringDataCheckJoinerWithDiscerner(otInstance * aInstance,
+otError otNetDataSteeringDataCheckJoinerWithDiscerner(otInstance *aInstance,
const struct otJoinerDiscerner *aDiscerner);
/**
- * This function checks whether a given Prefix can act as a valid OMR prefix and also the Leader's Network Data contains
- * this prefix.
+ * Check whether a given Prefix can act as a valid OMR prefix and also the Leader's Network Data contains this prefix.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPrefix A pointer to the IPv6 prefix.
diff --git a/include/openthread/netdata_publisher.h b/include/openthread/netdata_publisher.h
index 2c38e15137f..10346c25494 100644
--- a/include/openthread/netdata_publisher.h
+++ b/include/openthread/netdata_publisher.h
@@ -91,8 +91,8 @@ typedef void (*otNetDataDnsSrpServicePublisherCallback)(otNetDataPublisherEvent
*
*/
typedef void (*otNetDataPrefixPublisherCallback)(otNetDataPublisherEvent aEvent,
- const otIp6Prefix * aPrefix,
- void * aContext);
+ const otIp6Prefix *aPrefix,
+ void *aContext);
/**
* This function requests "DNS/SRP Service Anycast Address" to be published in the Thread Network Data.
@@ -170,9 +170,9 @@ bool otNetDataIsDnsSrpServiceAdded(otInstance *aInstance);
* @param[in] aContext A pointer to application-specific context (used when @p aCallback is invoked).
*
*/
-void otNetDataSetDnsSrpServicePublisherCallback(otInstance * aInstance,
+void otNetDataSetDnsSrpServicePublisherCallback(otInstance *aInstance,
otNetDataDnsSrpServicePublisherCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* Unpublishes any previously added DNS/SRP (Anycast or Unicast) Service entry from the Thread Network
@@ -237,6 +237,42 @@ otError otNetDataPublishOnMeshPrefix(otInstance *aInstance, const otBorderRouter
*/
otError otNetDataPublishExternalRoute(otInstance *aInstance, const otExternalRouteConfig *aConfig);
+/**
+ * This function replaces a previously published external route in the Thread Network Data.
+ *
+ * This function requires the feature `OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE` to be enabled.
+ *
+ * If there is no previously published external route matching @p aPrefix, this function behaves similarly to
+ * `otNetDataPublishExternalRoute()`, i.e., it will start the process of publishing @a aConfig as an external route in
+ * the Thread Network Data.
+ *
+ * If there is a previously published route entry matching @p aPrefix, it will be replaced with the new prefix from
+ * @p aConfig.
+ *
+ * - If the @p aPrefix was already added in the Network Data, the change to the new prefix in @p aConfig is immediately
+ * reflected in the Network Data. This ensures that route entries in the Network Data are not abruptly removed and
+ * the transition from aPrefix to the new prefix is smooth.
+ *
+ * - If the old published @p aPrefix was not added in the Network Data, it will be replaced with the new @p aConfig
+ * prefix but it will not be immediately added. Instead, it will start the process of publishing it in the Network
+ * Data (monitoring the Network Data to determine when/if to add the prefix, depending on the number of similar
+ * prefixes present in the Network Data).
+ *
+ * @param[in] aPrefix The previously published external route prefix to replace.
+ * @param[in] aConfig The external route config to publish.
+ * @param[in] aRequester The requester (`kFromUser` or `kFromRoutingManager` module).
+ *
+ * @retval OT_ERROR_NONE The external route is published successfully.
+ * @retval OT_ERROR_INVALID_ARGS The @p aConfig is not valid (bad prefix, invalid flag combinations, or not stable).
+ * @retval OT_ERROR_NO_BUFS Could not allocate an entry for the new request. Publisher supports a limited number
+ * of entries (shared between on-mesh prefix and external route) determined by config
+ * `OPENTHREAD_CONFIG_NETDATA_PUBLISHER_MAX_PREFIX_ENTRIES`.
+ *
+ */
+otError otNetDataReplacePublishedExternalRoute(otInstance *aInstance,
+ const otIp6Prefix *aPrefix,
+ const otExternalRouteConfig *aConfig);
+
/**
* This function indicates whether or not currently a published prefix entry (on-mesh or external route) is added to
* the Thread Network Data.
@@ -265,9 +301,9 @@ bool otNetDataIsPrefixAdded(otInstance *aInstance, const otIp6Prefix *aPrefix);
* @param[in] aContext A pointer to application-specific context (used when @p aCallback is invoked).
*
*/
-void otNetDataSetPrefixPublisherCallback(otInstance * aInstance,
+void otNetDataSetPrefixPublisherCallback(otInstance *aInstance,
otNetDataPrefixPublisherCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* Unpublishes a previously published On-Mesh or External Route Prefix.
diff --git a/include/openthread/netdiag.h b/include/openthread/netdiag.h
index d40238340e4..76e523bcd2b 100644
--- a/include/openthread/netdiag.h
+++ b/include/openthread/netdiag.h
@@ -66,24 +66,34 @@ extern "C" {
enum
{
- OT_NETWORK_DIAGNOSTIC_TLV_EXT_ADDRESS = 0, ///< MAC Extended Address TLV
- OT_NETWORK_DIAGNOSTIC_TLV_SHORT_ADDRESS = 1, ///< Address16 TLV
- OT_NETWORK_DIAGNOSTIC_TLV_MODE = 2, ///< Mode TLV
- OT_NETWORK_DIAGNOSTIC_TLV_TIMEOUT = 3, ///< Timeout TLV (the maximum polling time period for SEDs)
- OT_NETWORK_DIAGNOSTIC_TLV_CONNECTIVITY = 4, ///< Connectivity TLV
- OT_NETWORK_DIAGNOSTIC_TLV_ROUTE = 5, ///< Route64 TLV
- OT_NETWORK_DIAGNOSTIC_TLV_LEADER_DATA = 6, ///< Leader Data TLV
- OT_NETWORK_DIAGNOSTIC_TLV_NETWORK_DATA = 7, ///< Network Data TLV
- OT_NETWORK_DIAGNOSTIC_TLV_IP6_ADDR_LIST = 8, ///< IPv6 Address List TLV
- OT_NETWORK_DIAGNOSTIC_TLV_MAC_COUNTERS = 9, ///< MAC Counters TLV
- OT_NETWORK_DIAGNOSTIC_TLV_BATTERY_LEVEL = 14, ///< Battery Level TLV
- OT_NETWORK_DIAGNOSTIC_TLV_SUPPLY_VOLTAGE = 15, ///< Supply Voltage TLV
- OT_NETWORK_DIAGNOSTIC_TLV_CHILD_TABLE = 16, ///< Child Table TLV
- OT_NETWORK_DIAGNOSTIC_TLV_CHANNEL_PAGES = 17, ///< Channel Pages TLV
- OT_NETWORK_DIAGNOSTIC_TLV_TYPE_LIST = 18, ///< Type List TLV
- OT_NETWORK_DIAGNOSTIC_TLV_MAX_CHILD_TIMEOUT = 19, ///< Max Child Timeout TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_EXT_ADDRESS = 0, ///< MAC Extended Address TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_SHORT_ADDRESS = 1, ///< Address16 TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_MODE = 2, ///< Mode TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_TIMEOUT = 3, ///< Timeout TLV (the maximum polling time period for SEDs)
+ OT_NETWORK_DIAGNOSTIC_TLV_CONNECTIVITY = 4, ///< Connectivity TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_ROUTE = 5, ///< Route64 TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_LEADER_DATA = 6, ///< Leader Data TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_NETWORK_DATA = 7, ///< Network Data TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_IP6_ADDR_LIST = 8, ///< IPv6 Address List TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_MAC_COUNTERS = 9, ///< MAC Counters TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_BATTERY_LEVEL = 14, ///< Battery Level TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_SUPPLY_VOLTAGE = 15, ///< Supply Voltage TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_CHILD_TABLE = 16, ///< Child Table TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_CHANNEL_PAGES = 17, ///< Channel Pages TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_TYPE_LIST = 18, ///< Type List TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_MAX_CHILD_TIMEOUT = 19, ///< Max Child Timeout TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_VERSION = 24, ///< Version TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_VENDOR_NAME = 25, ///< Vendor Name TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_VENDOR_MODEL = 26, ///< Vendor Model TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_VENDOR_SW_VERSION = 27, ///< Vendor SW Version TLV
+ OT_NETWORK_DIAGNOSTIC_TLV_THREAD_STACK_VERSION = 28, ///< Thread Stack Version TLV
};
+#define OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_NAME_TLV_LENGTH 32 ///< Max length of Vendor Name TLV.
+#define OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_MODEL_TLV_LENGTH 32 ///< Max length of Vendor Model TLV.
+#define OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_SW_VERSION_TLV_LENGTH 16 ///< Max length of Vendor SW Version TLV.
+#define OT_NETWORK_DIAGNOSTIC_MAX_THREAD_STACK_VERSION_TLV_LENGTH 64 ///< Max length of Thread Stack Version TLV.
+
typedef uint16_t otNetworkDiagIterator; ///< Used to iterate through Network Diagnostic TLV.
/**
@@ -202,6 +212,14 @@ typedef struct otNetworkDiagChildEntry
*/
uint16_t mTimeout : 5;
+ /**
+ * Link Quality In value in [0,3].
+ *
+ * Value 0 indicates that sender does not support the feature to provide link quality info.
+ *
+ */
+ uint8_t mLinkQuality : 2;
+
/**
* Child ID from which an RLOC can be generated.
*/
@@ -237,6 +255,11 @@ typedef struct otNetworkDiagTlv
uint8_t mBatteryLevel;
uint16_t mSupplyVoltage;
uint32_t mMaxChildTimeout;
+ uint16_t mVersion;
+ char mVendorName[OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_NAME_TLV_LENGTH + 1];
+ char mVendorModel[OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_MODEL_TLV_LENGTH + 1];
+ char mVendorSwVersion[OT_NETWORK_DIAGNOSTIC_MAX_VENDOR_SW_VERSION_TLV_LENGTH + 1];
+ char mThreadStackVersion[OT_NETWORK_DIAGNOSTIC_MAX_THREAD_STACK_VERSION_TLV_LENGTH + 1];
struct
{
uint8_t mCount;
@@ -264,6 +287,8 @@ typedef struct otNetworkDiagTlv
/**
* This function gets the next Network Diagnostic TLV in the message.
*
+ * Requires `OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE`.
+ *
* @param[in] aMessage A pointer to a message.
* @param[in,out] aIterator A pointer to the Network Diagnostic iterator context. To get the first
* Network Diagnostic TLV it should be set to OT_NETWORK_DIAGNOSTIC_ITERATOR_INIT.
@@ -276,9 +301,9 @@ typedef struct otNetworkDiagTlv
* @Note A subsequent call to this function is allowed only when current return value is OT_ERROR_NONE.
*
*/
-otError otThreadGetNextDiagnosticTlv(const otMessage * aMessage,
+otError otThreadGetNextDiagnosticTlv(const otMessage *aMessage,
otNetworkDiagIterator *aIterator,
- otNetworkDiagTlv * aNetworkDiagTlv);
+ otNetworkDiagTlv *aNetworkDiagTlv);
/**
* This function pointer is called when Network Diagnostic Get response is received.
@@ -292,13 +317,15 @@ otError otThreadGetNextDiagnosticTlv(const otMessage * aMessage,
*
*/
typedef void (*otReceiveDiagnosticGetCallback)(otError aError,
- otMessage * aMessage,
+ otMessage *aMessage,
const otMessageInfo *aMessageInfo,
- void * aContext);
+ void *aContext);
/**
* Send a Network Diagnostic Get request.
*
+ * Requires `OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE`.
+ *
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDestination A pointer to destination address.
* @param[in] aTlvTypes An array of Network Diagnostic TLV types.
@@ -311,16 +338,18 @@ typedef void (*otReceiveDiagnosticGetCallback)(otError aError,
* @retval OT_ERROR_NO_BUFS Insufficient message buffers available to send DIAG_GET.req.
*
*/
-otError otThreadSendDiagnosticGet(otInstance * aInstance,
- const otIp6Address * aDestination,
+otError otThreadSendDiagnosticGet(otInstance *aInstance,
+ const otIp6Address *aDestination,
const uint8_t aTlvTypes[],
uint8_t aCount,
otReceiveDiagnosticGetCallback aCallback,
- void * aCallbackContext);
+ void *aCallbackContext);
/**
* Send a Network Diagnostic Reset request.
*
+ * Requires `OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE`.
+ *
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDestination A pointer to destination address.
* @param[in] aTlvTypes An array of Network Diagnostic TLV types. Currently only Type 9 is allowed.
@@ -330,11 +359,92 @@ otError otThreadSendDiagnosticGet(otInstance * aInstance,
* @retval OT_ERROR_NO_BUFS Insufficient message buffers available to send DIAG_RST.ntf.
*
*/
-otError otThreadSendDiagnosticReset(otInstance * aInstance,
+otError otThreadSendDiagnosticReset(otInstance *aInstance,
const otIp6Address *aDestination,
const uint8_t aTlvTypes[],
uint8_t aCount);
+/**
+ * Get the vendor name string.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ * @returns The vendor name string.
+ *
+ */
+const char *otThreadGetVendorName(otInstance *aInstance);
+
+/**
+ * Get the vendor model string.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ * @returns The vendor model string.
+ *
+ */
+const char *otThreadGetVendorModel(otInstance *aInstance);
+
+/**
+ * Get the vendor sw version string.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ * @returns The vendor sw version string.
+ *
+ */
+const char *otThreadGetVendorSwVersion(otInstance *aInstance);
+
+/**
+ * Set the vendor name string.
+ *
+ * Requires `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE`.
+ *
+ * @p aVendorName should be UTF8 with max length of 32 chars (`MAX_VENDOR_NAME_TLV_LENGTH`). Maximum length does not
+ * include the null `\0` character.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aVendorName The vendor name string.
+ *
+ * @retval OT_ERROR_NONE Successfully set the vendor name.
+ * @retval OT_ERROR_INVALID_ARGS @p aVendorName is not valid (too long or not UTF8).
+ *
+ */
+otError otThreadSetVendorName(otInstance *aInstance, const char *aVendorName);
+
+/**
+ * Set the vendor model string.
+ *
+ * Requires `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE`.
+ *
+ * @p aVendorModel should be UTF8 with max length of 32 chars (`MAX_VENDOR_MODEL_TLV_LENGTH`). Maximum length does not
+ * include the null `\0` character.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aVendorModel The vendor model string.
+ *
+ * @retval OT_ERROR_NONE Successfully set the vendor model.
+ * @retval OT_ERROR_INVALID_ARGS @p aVendorModel is not valid (too long or not UTF8).
+ *
+ */
+otError otThreadSetVendorModel(otInstance *aInstance, const char *aVendorModel);
+
+/**
+ * Set the vendor software version string.
+ *
+ * Requires `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE`.
+ *
+ * @p aVendorSwVersion should be UTF8 with max length of 16 chars(`MAX_VENDOR_SW_VERSION_TLV_LENGTH`). Maximum length
+ * does not include the null `\0` character.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aVendorSwVersion The vendor software version string.
+ *
+ * @retval OT_ERROR_NONE Successfully set the vendor software version.
+ * @retval OT_ERROR_INVALID_ARGS @p aVendorSwVersion is not valid (too long or not UTF8).
+ *
+ */
+otError otThreadSetVendorSwVersion(otInstance *aInstance, const char *aVendorSwVersion);
+
/**
* @}
*
diff --git a/include/openthread/network_time.h b/include/openthread/network_time.h
index 5e772317300..e20a9d5a34a 100644
--- a/include/openthread/network_time.h
+++ b/include/openthread/network_time.h
@@ -145,9 +145,9 @@ uint16_t otNetworkTimeGetXtalThreshold(otInstance *aInstance);
* @param[in] aCallbackContext The context to be passed to the callback function upon invocation
*
*/
-void otNetworkTimeSyncSetCallback(otInstance * aInstance,
+void otNetworkTimeSyncSetCallback(otInstance *aInstance,
otNetworkTimeSyncCallbackFn aCallbackFn,
- void * aCallbackContext);
+ void *aCallbackContext);
/**
* @}
diff --git a/include/openthread/ping_sender.h b/include/openthread/ping_sender.h
index 07e5c03ce5e..a0e30ca9aea 100644
--- a/include/openthread/ping_sender.h
+++ b/include/openthread/ping_sender.h
@@ -112,7 +112,7 @@ typedef struct otPingSenderConfig
otPingSenderReplyCallback mReplyCallback; ///< Callback function to report replies (can be NULL if not needed).
otPingSenderStatisticsCallback
mStatisticsCallback; ///< Callback function to report statistics (can be NULL if not needed).
- void * mCallbackContext; ///< A pointer to the callback application-specific context.
+ void *mCallbackContext; ///< A pointer to the callback application-specific context.
uint16_t mSize; ///< Data size (# of bytes) excludes IPv6/ICMPv6 header. Zero for default.
uint16_t mCount; ///< Number of ping messages to send. Zero to use default.
uint32_t mInterval; ///< Ping tx interval in milliseconds. Zero to use default.
diff --git a/include/openthread/platform/alarm-micro.h b/include/openthread/platform/alarm-micro.h
index e61640740ca..c165a40331a 100644
--- a/include/openthread/platform/alarm-micro.h
+++ b/include/openthread/platform/alarm-micro.h
@@ -53,6 +53,8 @@ extern "C" {
/**
* Set the alarm to fire at @p aDt microseconds after @p aT0.
*
+ * For both @p aT0 and @p aDt, the platform MUST support all values in [0, 2^32-1].
+ *
* @param[in] aInstance The OpenThread instance structure.
* @param[in] aT0 The reference time.
* @param[in] aDt The time delay in microseconds from @p aT0.
@@ -71,6 +73,9 @@ void otPlatAlarmMicroStop(otInstance *aInstance);
/**
* Get the current time.
*
+ * The current time MUST represent a free-running timer. When maintaining current time, the time value MUST utilize the
+ * entire range [0, 2^32-1] and MUST NOT wrap before 2^32.
+ *
* @returns The current time in microseconds.
*
*/
diff --git a/include/openthread/platform/alarm-milli.h b/include/openthread/platform/alarm-milli.h
index dd72201633d..0ddd9180bf5 100644
--- a/include/openthread/platform/alarm-milli.h
+++ b/include/openthread/platform/alarm-milli.h
@@ -56,6 +56,8 @@ extern "C" {
/**
* Set the alarm to fire at @p aDt milliseconds after @p aT0.
*
+ * For both @p aT0 and @p aDt, the platform MUST support all values in [0, 2^32-1].
+ *
* @param[in] aInstance The OpenThread instance structure.
* @param[in] aT0 The reference time.
* @param[in] aDt The time delay in milliseconds from @p aT0.
@@ -72,6 +74,9 @@ void otPlatAlarmMilliStop(otInstance *aInstance);
/**
* Get the current time.
*
+ * The current time MUST represent a free-running timer. When maintaining current time, the time value MUST utilize the
+ * entire range [0, 2^32-1] and MUST NOT wrap before 2^32.
+ *
* @returns The current time in milliseconds.
*/
uint32_t otPlatAlarmMilliGetNow(void);
diff --git a/include/openthread/platform/crypto.h b/include/openthread/platform/crypto.h
index 7cadc8e793f..0bccc38b866 100644
--- a/include/openthread/platform/crypto.h
+++ b/include/openthread/platform/crypto.h
@@ -60,9 +60,10 @@ extern "C" {
*/
typedef enum
{
- OT_CRYPTO_KEY_TYPE_RAW, ///< Key Type: Raw Data.
- OT_CRYPTO_KEY_TYPE_AES, ///< Key Type: AES.
- OT_CRYPTO_KEY_TYPE_HMAC, ///< Key Type: HMAC.
+ OT_CRYPTO_KEY_TYPE_RAW, ///< Key Type: Raw Data.
+ OT_CRYPTO_KEY_TYPE_AES, ///< Key Type: AES.
+ OT_CRYPTO_KEY_TYPE_HMAC, ///< Key Type: HMAC.
+ OT_CRYPTO_KEY_TYPE_ECDSA, ///< Key Type: ECDSA.
} otCryptoKeyType;
/**
@@ -74,6 +75,7 @@ typedef enum
OT_CRYPTO_KEY_ALG_VENDOR, ///< Key Algorithm: Vendor Defined.
OT_CRYPTO_KEY_ALG_AES_ECB, ///< Key Algorithm: AES ECB.
OT_CRYPTO_KEY_ALG_HMAC_SHA_256, ///< Key Algorithm: HMAC SHA-256.
+ OT_CRYPTO_KEY_ALG_ECDSA, ///< Key Algorithm: ECDSA.
} otCryptoKeyAlgorithm;
/**
@@ -82,11 +84,12 @@ typedef enum
*/
enum
{
- OT_CRYPTO_KEY_USAGE_NONE = 0, ///< Key Usage: Key Usage is empty.
- OT_CRYPTO_KEY_USAGE_EXPORT = 1 << 0, ///< Key Usage: Key can be exported.
- OT_CRYPTO_KEY_USAGE_ENCRYPT = 1 << 1, ///< Key Usage: Encryption (vendor defined).
- OT_CRYPTO_KEY_USAGE_DECRYPT = 1 << 2, ///< Key Usage: AES ECB.
- OT_CRYPTO_KEY_USAGE_SIGN_HASH = 1 << 3, ///< Key Usage: HMAC SHA-256.
+ OT_CRYPTO_KEY_USAGE_NONE = 0, ///< Key Usage: Key Usage is empty.
+ OT_CRYPTO_KEY_USAGE_EXPORT = 1 << 0, ///< Key Usage: Key can be exported.
+ OT_CRYPTO_KEY_USAGE_ENCRYPT = 1 << 1, ///< Key Usage: Encryption (vendor defined).
+ OT_CRYPTO_KEY_USAGE_DECRYPT = 1 << 2, ///< Key Usage: AES ECB.
+ OT_CRYPTO_KEY_USAGE_SIGN_HASH = 1 << 3, ///< Key Usage: Sign Hash.
+ OT_CRYPTO_KEY_USAGE_VERIFY_HASH = 1 << 4, ///< Key Usage: Verify Hash.
};
/**
@@ -126,10 +129,105 @@ typedef struct otCryptoKey
*/
typedef struct otCryptoContext
{
- void * mContext; ///< Pointer to the context.
+ void *mContext; ///< Pointer to the context.
uint16_t mContextSize; ///< The length of the context in bytes.
} otCryptoContext;
+/**
+ * Length of SHA256 hash (in bytes).
+ *
+ */
+#define OT_CRYPTO_SHA256_HASH_SIZE 32
+
+/**
+ * @struct otPlatCryptoSha256Hash
+ *
+ * This structure represents a SHA-256 hash.
+ *
+ */
+OT_TOOL_PACKED_BEGIN
+struct otPlatCryptoSha256Hash
+{
+ uint8_t m8[OT_CRYPTO_SHA256_HASH_SIZE]; ///< Hash bytes.
+} OT_TOOL_PACKED_END;
+
+/**
+ * This structure represents a SHA-256 hash.
+ *
+ */
+typedef struct otPlatCryptoSha256Hash otPlatCryptoSha256Hash;
+
+/**
+ * Max buffer size (in bytes) for representing the EDCSA key-pair in DER format.
+ *
+ */
+#define OT_CRYPTO_ECDSA_MAX_DER_SIZE 125
+
+/**
+ * @struct otPlatCryptoEcdsaKeyPair
+ *
+ * This structure represents an ECDSA key pair (public and private keys).
+ *
+ * The key pair is stored using Distinguished Encoding Rules (DER) format (per RFC 5915).
+ *
+ */
+typedef struct otPlatCryptoEcdsaKeyPair
+{
+ uint8_t mDerBytes[OT_CRYPTO_ECDSA_MAX_DER_SIZE];
+ uint8_t mDerLength;
+} otPlatCryptoEcdsaKeyPair;
+
+/**
+ * Buffer size (in bytes) for representing the EDCSA public key.
+ *
+ */
+#define OT_CRYPTO_ECDSA_PUBLIC_KEY_SIZE 64
+
+/**
+ * @struct otPlatCryptoEcdsaPublicKey
+ *
+ * This struct represents a ECDSA public key.
+ *
+ * The public key is stored as a byte sequence representation of an uncompressed curve point (RFC 6605 - sec 4).
+ *
+ */
+OT_TOOL_PACKED_BEGIN
+struct otPlatCryptoEcdsaPublicKey
+{
+ uint8_t m8[OT_CRYPTO_ECDSA_PUBLIC_KEY_SIZE];
+} OT_TOOL_PACKED_END;
+
+typedef struct otPlatCryptoEcdsaPublicKey otPlatCryptoEcdsaPublicKey;
+
+/**
+ * Buffer size (in bytes) for representing the EDCSA signature.
+ *
+ */
+#define OT_CRYPTO_ECDSA_SIGNATURE_SIZE 64
+
+/**
+ * @struct otPlatCryptoEcdsaSignature
+ *
+ * This struct represents an ECDSA signature.
+ *
+ * The signature is encoded as the concatenated binary representation of two MPIs `r` and `s` which are calculated
+ * during signing (RFC 6605 - section 4).
+ *
+ */
+OT_TOOL_PACKED_BEGIN
+struct otPlatCryptoEcdsaSignature
+{
+ uint8_t m8[OT_CRYPTO_ECDSA_SIGNATURE_SIZE];
+} OT_TOOL_PACKED_END;
+
+typedef struct otPlatCryptoEcdsaSignature otPlatCryptoEcdsaSignature;
+
+/**
+ * Max PBKDF2 SALT length: salt prefix (6) + extended panid (8) + network name (16)
+ *
+ */
+#define OT_CRYPTO_PBDKF2_MAX_SALT_SIZE 30
+
/**
* Initialize the Crypto module.
*
@@ -160,12 +258,12 @@ void otPlatCryptoInit(void);
* This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
*
*/
-otError otPlatCryptoImportKey(otCryptoKeyRef * aKeyRef,
+otError otPlatCryptoImportKey(otCryptoKeyRef *aKeyRef,
otCryptoKeyType aKeyType,
otCryptoKeyAlgorithm aKeyAlgorithm,
int aKeyUsage,
otCryptoKeyStorage aKeyPersistence,
- const uint8_t * aKey,
+ const uint8_t *aKey,
size_t aKeyLen);
/**
@@ -242,7 +340,7 @@ otError otPlatCryptoHmacSha256Deinit(otCryptoContext *aContext);
* Start HMAC operation.
*
* @param[in] aContext Context for HMAC operation.
- * @param[in] aKey Key material to be used for for HMAC operation.
+ * @param[in] aKey Key material to be used for HMAC operation.
*
* @retval OT_ERROR_NONE Successfully started HMAC operation.
* @retval OT_ERROR_FAILED Failed to start HMAC operation.
@@ -364,9 +462,9 @@ otError otPlatCryptoHkdfInit(otCryptoContext *aContext);
*
*/
otError otPlatCryptoHkdfExpand(otCryptoContext *aContext,
- const uint8_t * aInfo,
+ const uint8_t *aInfo,
uint16_t aInfoLength,
- uint8_t * aOutputKey,
+ uint8_t *aOutputKey,
uint16_t aOutputKeyLength);
/**
@@ -381,8 +479,8 @@ otError otPlatCryptoHkdfExpand(otCryptoContext *aContext,
* @retval OT_ERROR_FAILED HKDF Extract failed.
*
*/
-otError otPlatCryptoHkdfExtract(otCryptoContext * aContext,
- const uint8_t * aSalt,
+otError otPlatCryptoHkdfExtract(otCryptoContext *aContext,
+ const uint8_t *aSalt,
uint16_t aSaltLength,
const otCryptoKey *aInputKey);
@@ -480,15 +578,180 @@ void otPlatCryptoRandomDeinit(void);
/**
* Fills a given buffer with cryptographically secure random bytes.
*
- * @param[out] aBuffer A pointer to a buffer to fill with the random bytes.
- * @param[in] aSize Size of buffer (number of bytes to fill).
+ * @param[out] aBuffer A pointer to a buffer to fill with the random bytes.
+ * @param[in] aSize Size of buffer (number of bytes to fill).
*
- * @retval OT_ERROR_NONE Successfully filled buffer with random values.
- * @retval OT_ERROR_FAILED Operation failed.
+ * @retval OT_ERROR_NONE Successfully filled buffer with random values.
+ * @retval OT_ERROR_FAILED Operation failed.
*
*/
otError otPlatCryptoRandomGet(uint8_t *aBuffer, uint16_t aSize);
+/**
+ * Generate and populate the output buffer with a new ECDSA key-pair.
+ *
+ * @param[out] aKeyPair A pointer to an ECDSA key-pair structure to store the generated key-pair.
+ *
+ * @retval OT_ERROR_NONE A new key-pair was generated successfully.
+ * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation.
+ * @retval OT_ERROR_NOT_CAPABLE Feature not supported.
+ * @retval OT_ERROR_FAILED Failed to generate key-pair.
+ *
+ */
+otError otPlatCryptoEcdsaGenerateKey(otPlatCryptoEcdsaKeyPair *aKeyPair);
+
+/**
+ * Get the associated public key from the input context.
+ *
+ * @param[in] aKeyPair A pointer to an ECDSA key-pair structure where the key-pair is stored.
+ * @param[out] aPublicKey A pointer to an ECDSA public key structure to store the public key.
+ *
+ * @retval OT_ERROR_NONE Public key was retrieved successfully, and @p aBuffer is updated.
+ * @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format).
+ * @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL.
+ *
+ */
+otError otPlatCryptoEcdsaGetPublicKey(const otPlatCryptoEcdsaKeyPair *aKeyPair, otPlatCryptoEcdsaPublicKey *aPublicKey);
+
+/**
+ * Calculate the ECDSA signature for a hashed message using the private key from the input context.
+ *
+ * This method uses the deterministic digital signature generation procedure from RFC 6979.
+ *
+ * @param[in] aKeyPair A pointer to an ECDSA key-pair structure where the key-pair is stored.
+ * @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature calculation
+ * is stored.
+ * @param[out] aSignature A pointer to an ECDSA signature structure to output the calculated signature.
+ *
+ * @retval OT_ERROR_NONE The signature was calculated successfully, @p aSignature was updated.
+ * @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format).
+ * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature calculation.
+ * @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL.
+ *
+ */
+otError otPlatCryptoEcdsaSign(const otPlatCryptoEcdsaKeyPair *aKeyPair,
+ const otPlatCryptoSha256Hash *aHash,
+ otPlatCryptoEcdsaSignature *aSignature);
+
+/**
+ * Use the key from the input context to verify the ECDSA signature of a hashed message.
+ *
+ * @param[in] aPublicKey A pointer to an ECDSA public key structure where the public key for signature
+ * verification is stored.
+ * @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature verification
+ * is stored.
+ * @param[in] aSignature A pointer to an ECDSA signature structure where the signature value to be verified is
+ * stored.
+ *
+ * @retval OT_ERROR_NONE The signature was verified successfully.
+ * @retval OT_ERROR_SECURITY The signature is invalid.
+ * @retval OT_ERROR_INVALID_ARGS The key or hash is invalid.
+ * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature verification.
+ *
+ */
+otError otPlatCryptoEcdsaVerify(const otPlatCryptoEcdsaPublicKey *aPublicKey,
+ const otPlatCryptoSha256Hash *aHash,
+ const otPlatCryptoEcdsaSignature *aSignature);
+
+/**
+ * Calculate the ECDSA signature for a hashed message using the Key reference passed.
+ *
+ * This method uses the deterministic digital signature generation procedure from RFC 6979.
+ *
+ * @param[in] aKeyRef Key Reference to the slot where the key-pair is stored.
+ * @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature calculation
+ * is stored.
+ * @param[out] aSignature A pointer to an ECDSA signature structure to output the calculated signature.
+ *
+ * @retval OT_ERROR_NONE The signature was calculated successfully, @p aSignature was updated.
+ * @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format).
+ * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature calculation.
+ * @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL.
+ *
+ * @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
+ *
+ */
+otError otPlatCryptoEcdsaSignUsingKeyRef(otCryptoKeyRef aKeyRef,
+ const otPlatCryptoSha256Hash *aHash,
+ otPlatCryptoEcdsaSignature *aSignature);
+
+/**
+ * Get the associated public key from the key reference passed.
+ *
+ * The public key is stored differently depending on the crypto backend library being used
+ * (OPENTHREAD_CONFIG_CRYPTO_LIB).
+ *
+ * This API must make sure to return the public key as a byte sequence representation of an
+ * uncompressed curve point (RFC 6605 - sec 4)
+ *
+ * @param[in] aKeyRef Key Reference to the slot where the key-pair is stored.
+ * @param[out] aPublicKey A pointer to an ECDSA public key structure to store the public key.
+ *
+ * @retval OT_ERROR_NONE Public key was retrieved successfully, and @p aBuffer is updated.
+ * @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format).
+ * @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL.
+ *
+ * @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
+ *
+ */
+otError otPlatCryptoEcdsaExportPublicKey(otCryptoKeyRef aKeyRef, otPlatCryptoEcdsaPublicKey *aPublicKey);
+
+/**
+ * Generate and import a new ECDSA key-pair at reference passed.
+ *
+ * @param[in] aKeyRef Key Reference to the slot where the key-pair is stored.
+ *
+ * @retval OT_ERROR_NONE A new key-pair was generated successfully.
+ * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation.
+ * @retval OT_ERROR_NOT_CAPABLE Feature not supported.
+ * @retval OT_ERROR_FAILED Failed to generate key-pair.
+ *
+ * @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
+ *
+ */
+otError otPlatCryptoEcdsaGenerateAndImportKey(otCryptoKeyRef aKeyRef);
+
+/**
+ * Use the keyref to verify the ECDSA signature of a hashed message.
+ *
+ * @param[in] aKeyRef Key Reference to the slot where the key-pair is stored.
+ * @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature verification
+ * is stored.
+ * @param[in] aSignature A pointer to an ECDSA signature structure where the signature value to be verified is
+ * stored.
+ *
+ * @retval OT_ERROR_NONE The signature was verified successfully.
+ * @retval OT_ERROR_SECURITY The signature is invalid.
+ * @retval OT_ERROR_INVALID_ARGS The key or hash is invalid.
+ * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature verification.
+ *
+ * @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled.
+ *
+ */
+otError otPlatCryptoEcdsaVerifyUsingKeyRef(otCryptoKeyRef aKeyRef,
+ const otPlatCryptoSha256Hash *aHash,
+ const otPlatCryptoEcdsaSignature *aSignature);
+
+/**
+ * Perform PKCS#5 PBKDF2 using CMAC (AES-CMAC-PRF-128).
+ *
+ * @param[in] aPassword Password to use when generating key.
+ * @param[in] aPasswordLen Length of password.
+ * @param[in] aSalt Salt to use when generating key.
+ * @param[in] aSaltLen Length of salt.
+ * @param[in] aIterationCounter Iteration count.
+ * @param[in] aKeyLen Length of generated key in bytes.
+ * @param[out] aKey A pointer to the generated key.
+ *
+ */
+void otPlatCryptoPbkdf2GenerateKey(const uint8_t *aPassword,
+ uint16_t aPasswordLen,
+ const uint8_t *aSalt,
+ uint16_t aSaltLen,
+ uint32_t aIterationCounter,
+ uint16_t aKeyLen,
+ uint8_t *aKey);
+
/**
* @}
*
diff --git a/include/openthread/platform/diag.h b/include/openthread/platform/diag.h
index 9dee346c284..6f65f8234fb 100644
--- a/include/openthread/platform/diag.h
+++ b/include/openthread/platform/diag.h
@@ -56,6 +56,16 @@ extern "C" {
*
*/
+/**
+ * This enumeration defines the gpio modes.
+ *
+ */
+typedef enum
+{
+ OT_GPIO_MODE_INPUT = 0, ///< Input mode without pull resistor.
+ OT_GPIO_MODE_OUTPUT = 1, ///< Output mode.
+} otGpioMode;
+
/**
* This function processes a factory diagnostics command line.
*
@@ -75,8 +85,8 @@ extern "C" {
*/
otError otPlatDiagProcess(otInstance *aInstance,
uint8_t aArgsLength,
- char * aArgs[],
- char * aOutput,
+ char *aArgs[],
+ char *aOutput,
size_t aOutputMaxLen);
/**
@@ -129,6 +139,165 @@ void otPlatDiagRadioReceived(otInstance *aInstance, otRadioFrame *aFrame, otErro
*/
void otPlatDiagAlarmCallback(otInstance *aInstance);
+/**
+ * This function sets the gpio value.
+ *
+ * @param[in] aGpio The gpio number.
+ * @param[in] aValue true to set the gpio to high level, or false otherwise.
+ *
+ * @retval OT_ERROR_NONE Successfully set the gpio.
+ * @retval OT_ERROR_FAILED A platform error occurred while setting the gpio.
+ * @retval OT_ERROR_INVALID_ARGS @p aGpio is not supported.
+ * @retval OT_ERROR_INVALID_STATE Diagnostic mode was not enabled or @p aGpio is not configured as output.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented or configured on the platform.
+ *
+ */
+otError otPlatDiagGpioSet(uint32_t aGpio, bool aValue);
+
+/**
+ * This function gets the gpio value.
+ *
+ * @param[in] aGpio The gpio number.
+ * @param[out] aValue A pointer where to put gpio value.
+ *
+ * @retval OT_ERROR_NONE Successfully got the gpio value.
+ * @retval OT_ERROR_FAILED A platform error occurred while getting the gpio value.
+ * @retval OT_ERROR_INVALID_ARGS @p aGpio is not supported or @p aValue is NULL.
+ * @retval OT_ERROR_INVALID_STATE Diagnostic mode was not enabled or @p aGpio is not configured as input.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented or configured on the platform.
+ *
+ */
+otError otPlatDiagGpioGet(uint32_t aGpio, bool *aValue);
+
+/**
+ * This function sets the gpio mode.
+ *
+ * @param[in] aGpio The gpio number.
+ * @param[out] aMode The gpio mode.
+ *
+ * @retval OT_ERROR_NONE Successfully set the gpio mode.
+ * @retval OT_ERROR_FAILED A platform error occurred while setting the gpio mode.
+ * @retval OT_ERROR_INVALID_ARGS @p aGpio or @p aMode is not supported.
+ * @retval OT_ERROR_INVALID_STATE Diagnostic mode was not enabled.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented or configured on the platform.
+ *
+ */
+otError otPlatDiagGpioSetMode(uint32_t aGpio, otGpioMode aMode);
+
+/**
+ * This function gets the gpio mode.
+ *
+ * @param[in] aGpio The gpio number.
+ * @param[out] aMode A pointer where to put gpio mode.
+ *
+ * @retval OT_ERROR_NONE Successfully got the gpio mode.
+ * @retval OT_ERROR_FAILED Mode returned by the platform is not implemented in OpenThread or a platform error
+ * occurred while getting the gpio mode.
+ * @retval OT_ERROR_INVALID_ARGS @p aGpio is not supported or @p aMode is NULL.
+ * @retval OT_ERROR_INVALID_STATE Diagnostic mode was not enabled.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented or configured on the platform.
+ *
+ */
+otError otPlatDiagGpioGetMode(uint32_t aGpio, otGpioMode *aMode);
+
+/**
+ * Set the radio raw power setting for diagnostics module.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aRawPowerSetting A pointer to the raw power setting byte array.
+ * @param[in] aRawPowerSettingLength The length of the @p aRawPowerSetting.
+ *
+ * @retval OT_ERROR_NONE Successfully set the raw power setting.
+ * @retval OT_ERROR_INVALID_ARGS The @p aRawPowerSetting is NULL or the @p aRawPowerSettingLength is too long.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This method is not implemented.
+ *
+ */
+otError otPlatDiagRadioSetRawPowerSetting(otInstance *aInstance,
+ const uint8_t *aRawPowerSetting,
+ uint16_t aRawPowerSettingLength);
+
+/**
+ * Get the radio raw power setting for diagnostics module.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[out] aRawPowerSetting A pointer to the raw power setting byte array.
+ * @param[in,out] aRawPowerSettingLength On input, a pointer to the size of @p aRawPowerSetting.
+ * On output, a pointer to the length of the raw power setting data.
+ *
+ * @retval OT_ERROR_NONE Successfully set the raw power setting.
+ * @retval OT_ERROR_INVALID_ARGS The @p aRawPowerSetting or @p aRawPowerSettingLength is NULL or
+ * @aRawPowerSettingLength is too short.
+ * @retval OT_ERROR_NOT_FOUND The raw power setting is not set.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This method is not implemented.
+ *
+ */
+otError otPlatDiagRadioGetRawPowerSetting(otInstance *aInstance,
+ uint8_t *aRawPowerSetting,
+ uint16_t *aRawPowerSettingLength);
+
+/**
+ * Enable/disable the platform layer to use the raw power setting set by `otPlatDiagRadioSetRawPowerSetting()`.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aEnable TRUE to enable or FALSE to disable the raw power setting.
+ *
+ * @retval OT_ERROR_NONE Successfully enabled/disabled the raw power setting.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This method is not implemented.
+ *
+ */
+otError otPlatDiagRadioRawPowerSettingEnable(otInstance *aInstance, bool aEnable);
+
+/**
+ * Start/stop the platform layer to transmit continuous carrier wave.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aEnable TRUE to enable or FALSE to disable the platform layer to transmit continuous carrier wave.
+ *
+ * @retval OT_ERROR_NONE Successfully enabled/disabled .
+ * @retval OT_ERROR_INVALID_STATE The radio was not in the Receive state.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This method is not implemented.
+ *
+ */
+otError otPlatDiagRadioTransmitCarrier(otInstance *aInstance, bool aEnable);
+
+/**
+ * Start/stop the platform layer to transmit stream of characters.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aEnable TRUE to enable or FALSE to disable the platform layer to transmit stream.
+ *
+ * @retval OT_ERROR_NONE Successfully enabled/disabled.
+ * @retval OT_ERROR_INVALID_STATE The radio was not in the Receive state.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This function is not implemented.
+ *
+ */
+otError otPlatDiagRadioTransmitStream(otInstance *aInstance, bool aEnable);
+
+/**
+ * Get the power settings for the given channel.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aChannel The radio channel.
+ * @param[out] aTargetPower The target power in 0.01 dBm.
+ * @param[out] aActualPower The actual power in 0.01 dBm.
+ * @param[out] aRawPowerSetting A pointer to the raw power setting byte array.
+ * @param[in,out] aRawPowerSettingLength On input, a pointer to the size of @p aRawPowerSetting.
+ * On output, a pointer to the length of the raw power setting data.
+ *
+ * @retval OT_ERROR_NONE Successfully got the target power.
+ * @retval OT_ERROR_INVALID_ARGS The @p aChannel is invalid, @aTargetPower, @p aActualPower, @p aRawPowerSetting or
+ * @p aRawPowerSettingLength is NULL or @aRawPowerSettingLength is too short.
+ * @retval OT_ERROR_NOT_FOUND The power settings for the @p aChannel was not found.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This method is not implemented.
+ *
+ */
+otError otPlatDiagRadioGetPowerSettings(otInstance *aInstance,
+ uint8_t aChannel,
+ int16_t *aTargetPower,
+ int16_t *aActualPower,
+ uint8_t *aRawPowerSetting,
+ uint16_t *aRawPowerSettingLength);
+
/**
* @}
*
diff --git a/include/openthread/platform/dns.h b/include/openthread/platform/dns.h
new file mode 100644
index 00000000000..9e84fbe43f3
--- /dev/null
+++ b/include/openthread/platform/dns.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2023, The OpenThread Authors.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ * @brief
+ * This file defines the platform DNS interface.
+ *
+ */
+
+#ifndef OPENTHREAD_PLATFORM_DNS_H_
+#define OPENTHREAD_PLATFORM_DNS_H_
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup plat-dns
+ *
+ * @brief
+ * This module includes the platform abstraction for sending recursive DNS query to upstream DNS servers.
+ *
+ * @{
+ *
+ */
+
+/**
+ * This opaque type represents an upstream DNS query transaction.
+ *
+ */
+typedef struct otPlatDnsUpstreamQuery otPlatDnsUpstreamQuery;
+
+/**
+ * Starts an upstream query transaction.
+ *
+ * - In success case (and errors represented by DNS protocol messages), the platform is expected to call
+ * `otPlatDnsUpstreamQueryDone`.
+ * - The OpenThread core may cancel a (possibly timeout) query transaction by calling
+ * `otPlatDnsCancelUpstreamQuery`, the platform must not call `otPlatDnsUpstreamQueryDone` on a
+ * cancelled transaction.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aTxn A pointer to the opaque DNS query transaction object.
+ * @param[in] aQuery A message buffer of the DNS payload that should be sent to upstream DNS server.
+ *
+ */
+void otPlatDnsStartUpstreamQuery(otInstance *aInstance, otPlatDnsUpstreamQuery *aTxn, const otMessage *aQuery);
+
+/**
+ * Cancels a transaction of upstream query.
+ *
+ * The platform must call `otPlatDnsUpstreamQueryDone` to release the resources.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aTxn A pointer to the opaque DNS query transaction object.
+ *
+ */
+void otPlatDnsCancelUpstreamQuery(otInstance *aInstance, otPlatDnsUpstreamQuery *aTxn);
+
+/**
+ * The platform calls this function to finish DNS query.
+ *
+ * The transaction will be released, so the platform must not call on the same transaction twice. This function passes
+ * the ownership of `aResponse` to OpenThread stack.
+ *
+ * Platform can pass a nullptr to close a transaction without a response.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aTxn A pointer to the opaque DNS query transaction object.
+ * @param[in] aResponse A message buffer of the DNS response payload or `nullptr` to close a transaction without a
+ * response.
+ *
+ */
+extern void otPlatDnsUpstreamQueryDone(otInstance *aInstance, otPlatDnsUpstreamQuery *aTxn, otMessage *aResponse);
+
+/**
+ * @}
+ *
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/openthread/platform/infra_if.h b/include/openthread/platform/infra_if.h
index 9242213ef92..5d2c50f1504 100644
--- a/include/openthread/platform/infra_if.h
+++ b/include/openthread/platform/infra_if.h
@@ -87,7 +87,7 @@ bool otPlatInfraIfHasAddress(uint32_t aInfraIfIndex, const otIp6Address *aAddres
*/
otError otPlatInfraIfSendIcmp6Nd(uint32_t aInfraIfIndex,
const otIp6Address *aDestAddress,
- const uint8_t * aBuffer,
+ const uint8_t *aBuffer,
uint16_t aBufferLength);
/**
@@ -106,10 +106,10 @@ otError otPlatInfraIfSendIcmp6Nd(uint32_t aInfraIfIndex,
* address and the IP Hop Limit MUST be 255.
*
*/
-extern void otPlatInfraIfRecvIcmp6Nd(otInstance * aInstance,
+extern void otPlatInfraIfRecvIcmp6Nd(otInstance *aInstance,
uint32_t aInfraIfIndex,
const otIp6Address *aSrcAddress,
- const uint8_t * aBuffer,
+ const uint8_t *aBuffer,
uint16_t aBufferLength);
/**
@@ -133,6 +133,35 @@ extern void otPlatInfraIfRecvIcmp6Nd(otInstance * aInstance,
*/
extern otError otPlatInfraIfStateChanged(otInstance *aInstance, uint32_t aInfraIfIndex, bool aIsRunning);
+/**
+ * Send a request to discover the NAT64 prefix on the infrastructure interface with @p aInfraIfIndex.
+ *
+ * OpenThread will call this method periodically to monitor the presence or change of NAT64 prefix.
+ *
+ * @param[in] aInfraIfIndex The index of the infrastructure interface to discover the NAT64 prefix.
+ *
+ * @retval OT_ERROR_NONE Successfully request NAT64 prefix discovery.
+ * @retval OT_ERROR_FAILED Failed to request NAT64 prefix discovery.
+ *
+ */
+otError otPlatInfraIfDiscoverNat64Prefix(uint32_t aInfraIfIndex);
+
+/**
+ * The infra interface driver calls this method to notify OpenThread that
+ * the discovery of NAT64 prefix is done.
+ *
+ * This method is expected to be invoked after calling otPlatInfraIfDiscoverNat64Prefix.
+ * If no NAT64 prefix is discovered, @p aIp6Prefix shall point to an empty prefix with zero length.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aInfraIfIndex The index of the infrastructure interface on which the NAT64 prefix is discovered.
+ * @param[in] aIp6Prefix A pointer to NAT64 prefix.
+ *
+ */
+extern void otPlatInfraIfDiscoverNat64PrefixDone(otInstance *aInstance,
+ uint32_t aInfraIfIndex,
+ const otIp6Prefix *aIp6Prefix);
+
/**
* @}
*
diff --git a/include/openthread/platform/radio.h b/include/openthread/platform/radio.h
index b95acd54c9f..89e17be88c3 100644
--- a/include/openthread/platform/radio.h
+++ b/include/openthread/platform/radio.h
@@ -68,13 +68,20 @@ extern "C" {
enum
{
- OT_RADIO_FRAME_MAX_SIZE = 127, ///< aMaxPHYPacketSize (IEEE 802.15.4-2006)
- OT_RADIO_FRAME_MIN_SIZE = 3, ///< Minimal size of frame FCS + CONTROL
+ OT_RADIO_FRAME_MAX_SIZE = 127, ///< aMaxPHYPacketSize (IEEE 802.15.4-2006)
+ OT_RADIO_FRAME_MIN_SIZE = 3, ///< Minimal size of frame FCS + CONTROL
+
OT_RADIO_SYMBOLS_PER_OCTET = 2, ///< 2.4 GHz IEEE 802.15.4-2006
OT_RADIO_BIT_RATE = 250000, ///< 2.4 GHz IEEE 802.15.4 (bits per second)
OT_RADIO_BITS_PER_OCTET = 8, ///< Number of bits per octet
- OT_RADIO_SYMBOL_TIME = ((OT_RADIO_BITS_PER_OCTET / OT_RADIO_SYMBOLS_PER_OCTET) * 1000000) / OT_RADIO_BIT_RATE,
+ // Per IEEE 802.15.4-2015, 12.3.3 Symbol rate:
+ // The O-QPSK PHY symbol rate shall be 25 ksymbol/s when operating in the 868 MHz band and 62.5 ksymbol/s when
+ // operating in the 780 MHz, 915 MHz, 2380 MHz, or 2450 MHz band
+ OT_RADIO_SYMBOL_RATE = 62500, ///< The O-QPSK PHY symbol rate when operating in the 780MHz, 915MHz, 2380MHz, 2450MHz
+ OT_RADIO_SYMBOL_TIME = 1000000 * 1 / OT_RADIO_SYMBOL_RATE, ///< Symbol duration time in unit of microseconds
+ OT_RADIO_TEN_SYMBOLS_TIME = 10 * OT_RADIO_SYMBOL_TIME, ///< Time for 10 symbols in unit of microseconds
+
OT_RADIO_LQI_NONE = 0, ///< LQI measurement not supported
OT_RADIO_RSSI_INVALID = 127, ///< Invalid or unknown RSSI value
OT_RADIO_POWER_INVALID = 127, ///< Invalid or unknown power value
@@ -264,12 +271,33 @@ typedef struct otRadioFrame
struct
{
const otMacKeyMaterial *mAesKey; ///< The key material used for AES-CCM frame security.
- otRadioIeInfo * mIeInfo; ///< The pointer to the Header IE(s) related information.
+ otRadioIeInfo *mIeInfo; ///< The pointer to the Header IE(s) related information.
uint32_t mTxDelay; ///< The delay time for this transmission (based on `mTxDelayBaseTime`).
uint32_t mTxDelayBaseTime; ///< The base time for the transmission delay.
uint8_t mMaxCsmaBackoffs; ///< Maximum number of backoffs attempts before declaring CCA failure.
uint8_t mMaxFrameRetries; ///< Maximum number of retries allowed after a transmission failure.
+ /**
+ * The RX channel after frame TX is done (after all frame retries - ack received, or timeout, or abort).
+ *
+ * Radio platforms can choose to fully ignore this. OT stack will make sure to call `otPlatRadioReceive()`
+ * with the desired RX channel after a frame TX is done and signaled in `otPlatRadioTxDone()` callback.
+ * Radio platforms that don't provide `OT_RADIO_CAPS_TRANSMIT_RETRIES` must always ignore this.
+ *
+ * This is intended for situations where there may be delay in interactions between OT stack and radio, as
+ * an example this is used in RCP/host architecture to make sure RCP switches to PAN channel more quickly.
+ * In particular, this can help with CSL tx to a sleepy child, where the child may use a different channel
+ * for CSL than the PAN channel. After frame tx, we want the radio/RCP to go back to the PAN channel
+ * quickly to ensure that parent does not miss tx from child afterwards, e.g., child responding to the
+ * earlier CSL transmitted frame from parent using PAN channel while radio still staying on CSL channel.
+ *
+ * The switch to the RX channel MUST happen after the frame TX is fully done, i.e., after all retries and
+ * when ack is received (when "Ack Request" flag is set on the TX frame) or ack timeout. Note that ack is
+ * expected on the same channel that frame is sent on.
+ *
+ */
+ uint8_t mRxChannelAfterTxDone;
+
/**
* Indicates whether frame counter and CSL IEs are properly updated in the header.
*
@@ -306,8 +334,7 @@ typedef struct otRadioFrame
/**
* The timestamp when the frame was received in microseconds.
*
- * The value SHALL be the time when the SFD was received when TIME_SYNC or CSL is enabled.
- * Otherwise, the time when the MAC frame was fully received is also acceptable.
+ * The value SHALL be the time when the SFD was received.
*
*/
uint64_t mTimestamp;
@@ -536,7 +563,7 @@ otError otPlatRadioGetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t *aT
otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aThreshold);
/**
- * Get the external FEM's Rx LNA gain in dBm.
+ * Gets the external FEM's Rx LNA gain in dBm.
*
* @param[in] aInstance The OpenThread instance structure.
* @param[out] aGain The external FEM's Rx LNA gain in dBm.
@@ -549,7 +576,7 @@ otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aTh
otError otPlatRadioGetFemLnaGain(otInstance *aInstance, int8_t *aGain);
/**
- * Set the external FEM's Rx LNA gain in dBm.
+ * Sets the external FEM's Rx LNA gain in dBm.
*
* @param[in] aInstance The OpenThread instance structure.
* @param[in] aGain The external FEM's Rx LNA gain in dBm.
@@ -594,7 +621,7 @@ void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable);
* @param[in] aKeyType Key Type used.
*
*/
-void otPlatRadioSetMacKey(otInstance * aInstance,
+void otPlatRadioSetMacKey(otInstance *aInstance,
uint8_t aKeyIdMode,
uint8_t aKeyId,
const otMacKeyMaterial *aPrevKey,
@@ -613,6 +640,17 @@ void otPlatRadioSetMacKey(otInstance * aInstance,
*/
void otPlatRadioSetMacFrameCounter(otInstance *aInstance, uint32_t aMacFrameCounter);
+/**
+ * This method sets the current MAC frame counter value only if the new given value is larger than the current value.
+ *
+ * This function is used when radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aMacFrameCounter The MAC frame counter value.
+ *
+ */
+void otPlatRadioSetMacFrameCounterIfLarger(otInstance *aInstance, uint32_t aMacFrameCounter);
+
/**
* Get the current estimated time (in microseconds) of the radio chip.
*
@@ -969,7 +1007,7 @@ void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance);
uint32_t otPlatRadioGetSupportedChannelMask(otInstance *aInstance);
/**
- * Get the radio preferred channel mask that the device prefers to form on.
+ * Gets the radio preferred channel mask that the device prefers to form on.
*
* @param[in] aInstance The OpenThread instance structure.
*
@@ -1032,7 +1070,7 @@ otError otPlatRadioGetCoexMetrics(otInstance *aInstance, otRadioCoexMetrics *aCo
* @retval kErrorNone Successfully enabled or disabled CSL.
*
*/
-otError otPlatRadioEnableCsl(otInstance * aInstance,
+otError otPlatRadioEnableCsl(otInstance *aInstance,
uint32_t aCslPeriod,
otShortAddress aShortAddr,
const otExtAddress *aExtAddr);
@@ -1096,6 +1134,7 @@ otError otPlatRadioSetChannelMaxTransmitPower(otInstance *aInstance, uint8_t aCh
*
* @retval OT_ERROR_FAILED Other platform specific errors.
* @retval OT_ERROR_NONE Successfully set region code.
+ * @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented.
*
*/
otError otPlatRadioSetRegion(otInstance *aInstance, uint16_t aRegionCode);
@@ -1112,6 +1151,7 @@ otError otPlatRadioSetRegion(otInstance *aInstance, uint16_t aRegionCode);
* @retval OT_ERROR_INVALID_ARGS @p aRegionCode is nullptr.
* @retval OT_ERROR_FAILED Other platform specific errors.
* @retval OT_ERROR_NONE Successfully got region code.
+ * @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented.
*
*/
otError otPlatRadioGetRegion(otInstance *aInstance, uint16_t *aRegionCode);
@@ -1134,13 +1174,108 @@ otError otPlatRadioGetRegion(otInstance *aInstance, uint16_t *aRegionCode);
* @retval OT_ERROR_INVALID_ARGS @p aExtAddress is `NULL`.
* @retval OT_ERROR_NOT_FOUND The Initiator indicated by @p aShortAddress is not found when trying to clear.
* @retval OT_ERROR_NO_BUFS No more Initiator can be supported.
+ * @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented.
*
*/
-otError otPlatRadioConfigureEnhAckProbing(otInstance * aInstance,
+otError otPlatRadioConfigureEnhAckProbing(otInstance *aInstance,
otLinkMetrics aLinkMetrics,
otShortAddress aShortAddress,
const otExtAddress *aExtAddress);
+/**
+ * Add a calibrated power of the specified channel to the power calibration table.
+ *
+ * @note This API is an optional radio platform API. It's up to the platform layer to implement it.
+ *
+ * The @p aActualPower is the actual measured output power when the parameters of the radio hardware modules
+ * are set to the @p aRawPowerSetting.
+ *
+ * The raw power setting is an opaque byte array. OpenThread doesn't define the format of the raw power setting.
+ * Its format is radio hardware related and it should be defined by the developers in the platform radio driver.
+ * For example, if the radio hardware contains both the radio chip and the FEM chip, the raw power setting can be
+ * a combination of the radio power register and the FEM gain value.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aChannel The radio channel.
+ * @param[in] aActualPower The actual power in 0.01dBm.
+ * @param[in] aRawPowerSetting A pointer to the raw power setting byte array.
+ * @param[in] aRawPowerSettingLength The length of the @p aRawPowerSetting.
+ *
+ * @retval OT_ERROR_NONE Successfully added the calibrated power to the power calibration table.
+ * @retval OT_ERROR_NO_BUFS No available entry in the power calibration table.
+ * @retval OT_ERROR_INVALID_ARGS The @p aChannel, @p aActualPower or @p aRawPowerSetting is invalid or the
+ * @p aActualPower already exists in the power calibration table.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This feature is not implemented.
+ *
+ */
+otError otPlatRadioAddCalibratedPower(otInstance *aInstance,
+ uint8_t aChannel,
+ int16_t aActualPower,
+ const uint8_t *aRawPowerSetting,
+ uint16_t aRawPowerSettingLength);
+
+/**
+ * Clear all calibrated powers from the power calibration table.
+ *
+ * @note This API is an optional radio platform API. It's up to the platform layer to implement it.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ *
+ * @retval OT_ERROR_NONE Successfully cleared all calibrated powers from the power calibration table.
+ * @retval OT_ERROR_NOT_IMPLEMENTED This feature is not implemented.
+ *
+ */
+otError otPlatRadioClearCalibratedPowers(otInstance *aInstance);
+
+/**
+ * Set the target power for the given channel.
+ *
+ * @note This API is an optional radio platform API. It's up to the platform layer to implement it.
+ * If this API is implemented, the function `otPlatRadioSetTransmitPower()` should be disabled.
+ *
+ * The radio driver should set the actual output power to be less than or equal to the target power and as close
+ * as possible to the target power.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aChannel The radio channel.
+ * @param[in] aTargetPower The target power in 0.01dBm. Passing `INT16_MAX` will disable this channel to use the
+ * target power.
+ *
+ * @retval OT_ERROR_NONE Successfully set the target power.
+ * @retval OT_ERROR_INVALID_ARGS The @p aChannel or @p aTargetPower is invalid.
+ * @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented.
+ *
+ */
+otError otPlatRadioSetChannelTargetPower(otInstance *aInstance, uint8_t aChannel, int16_t aTargetPower);
+
+/**
+ * Get the raw power setting for the given channel.
+ *
+ * @note OpenThread `src/core/utils` implements a default implementation of the API `otPlatRadioAddCalibratedPower()`,
+ * `otPlatRadioClearCalibratedPowers()` and `otPlatRadioSetChannelTargetPower()`. This API is provided by
+ * the default implementation to get the raw power setting for the given channel. If the platform doesn't
+ * use the default implementation, it can ignore this API.
+ *
+ * Platform radio layer should parse the raw power setting based on the radio layer defined format and set the
+ * parameters of each radio hardware module.
+ *
+ * @param[in] aInstance The OpenThread instance structure.
+ * @param[in] aChannel The radio channel.
+ * @param[out] aRawPowerSetting A pointer to the raw power setting byte array.
+ * @param[in,out] aRawPowerSettingLength On input, a pointer to the size of @p aRawPowerSetting.
+ * On output, a pointer to the length of the raw power setting data.
+ *
+ * @retval OT_ERROR_NONE Successfully got the target power.
+ * @retval OT_ERROR_INVALID_ARGS The @p aChannel is invalid, @p aRawPowerSetting or @p aRawPowerSettingLength is NULL
+ * or @aRawPowerSettingLength is too short.
+ * @retval OT_ERROR_NOT_FOUND The raw power setting for the @p aChannel was not found.
+ *
+ */
+extern otError otPlatRadioGetRawPowerSetting(otInstance *aInstance,
+ uint8_t aChannel,
+ uint8_t *aRawPowerSetting,
+ uint16_t *aRawPowerSettingLength);
+
/**
* @}
*
diff --git a/include/openthread/platform/settings.h b/include/openthread/platform/settings.h
index 2a4892baa97..a9ca05de4e0 100644
--- a/include/openthread/platform/settings.h
+++ b/include/openthread/platform/settings.h
@@ -72,6 +72,8 @@ enum
OT_SETTINGS_KEY_SRP_CLIENT_INFO = 0x000c, ///< The SRP client info (selected SRP server address).
OT_SETTINGS_KEY_SRP_SERVER_INFO = 0x000d, ///< The SRP server info (UDP port).
OT_SETTINGS_KEY_BR_ULA_PREFIX = 0x000f, ///< BR ULA prefix.
+ OT_SETTINGS_KEY_BR_ON_LINK_PREFIXES = 0x0010, ///< BR local on-link prefixes.
+ OT_SETTINGS_KEY_BORDER_AGENT_ID = 0x0011, ///< Unique Border Agent/Router ID.
// Deprecated and reserved key values:
//
diff --git a/include/openthread/platform/spi-slave.h b/include/openthread/platform/spi-slave.h
index 3b846673e74..551d7016350 100644
--- a/include/openthread/platform/spi-slave.h
+++ b/include/openthread/platform/spi-slave.h
@@ -79,7 +79,7 @@ extern "C" {
* @returns TRUE if after this call returns the platform should invoke the process callback `aProcessCallback`,
* FALSE if there is nothing to process and no need to invoke the process callback.
*/
-typedef bool (*otPlatSpiSlaveTransactionCompleteCallback)(void * aContext,
+typedef bool (*otPlatSpiSlaveTransactionCompleteCallback)(void *aContext,
uint8_t *aOutputBuf,
uint16_t aOutputBufLen,
uint8_t *aInputBuf,
@@ -115,7 +115,7 @@ typedef void (*otPlatSpiSlaveTransactionProcessCallback)(void *aContext);
*/
otError otPlatSpiSlaveEnable(otPlatSpiSlaveTransactionCompleteCallback aCompleteCallback,
otPlatSpiSlaveTransactionProcessCallback aProcessCallback,
- void * aContext);
+ void *aContext);
/**
* Shutdown and disable the SPI slave interface.
diff --git a/include/openthread/platform/toolchain.h b/include/openthread/platform/toolchain.h
index 56109852da0..d8b0308ef87 100644
--- a/include/openthread/platform/toolchain.h
+++ b/include/openthread/platform/toolchain.h
@@ -110,6 +110,24 @@ extern "C" {
*
*/
+/**
+ * @def OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK
+ *
+ * This macro specifies that a function or method takes `printf` style arguments and should be type-checked against
+ * a format string.
+ *
+ * This macro must be added after the function/method declaration. For example:
+ *
+ * `void MyPrintf(void *aObject, const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 3);`
+ *
+ * The two argument index values indicate format string and first argument to check against it. They start at index 1
+ * for the first parameter in a function and at index 2 for the first parameter in a method.
+ *
+ * @param[in] aFmtIndex The argument index of the format string.
+ * @param[in] aStartIndex The argument index of the first argument to check against the format string.
+ *
+ */
+
// =========== TOOLCHAIN SELECTION : START ===========
#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM) || defined(__TI_ARM__)
@@ -122,6 +140,9 @@ extern "C" {
#define OT_TOOL_PACKED_END __attribute__((packed))
#define OT_TOOL_WEAK __attribute__((weak))
+#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex) \
+ __attribute__((format(printf, aFmtIndex, aStartIndex)))
+
#elif defined(__ICCARM__) || defined(__ICC8051__)
// http://supp.iar.com/FilesPublic/UPDINFO/004916/arm/doc/EWARM_DevelopmentGuide.ENU.pdf
@@ -133,6 +154,8 @@ extern "C" {
#define OT_TOOL_PACKED_END
#define OT_TOOL_WEAK __weak
+#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex)
+
#elif defined(__SDCC)
// Structures are packed by default in sdcc, as it primarily targets 8-bit MCUs.
@@ -142,6 +165,8 @@ extern "C" {
#define OT_TOOL_PACKED_END
#define OT_TOOL_WEAK
+#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex)
+
#else
#error "Error: No valid Toolchain specified"
@@ -153,6 +178,8 @@ extern "C" {
#define OT_TOOL_PACKED_END
#define OT_TOOL_WEAK
+#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex)
+
#endif
// =========== TOOLCHAIN SELECTION : END ===========
diff --git a/include/openthread/platform/trel.h b/include/openthread/platform/trel.h
index d4e0475a60a..6515b98d591 100644
--- a/include/openthread/platform/trel.h
+++ b/include/openthread/platform/trel.h
@@ -178,8 +178,8 @@ void otPlatTrelRegisterService(otInstance *aInstance, uint16_t aPort, const uint
* @param[in] aDestSockAddr The destination socket address.
*
*/
-void otPlatTrelSend(otInstance * aInstance,
- const uint8_t * aUdpPayload,
+void otPlatTrelSend(otInstance *aInstance,
+ const uint8_t *aUdpPayload,
uint16_t aUdpPayloadLen,
const otSockAddr *aDestSockAddr);
diff --git a/include/openthread/platform/udp.h b/include/openthread/platform/udp.h
index 345f1596297..b1dae45c799 100644
--- a/include/openthread/platform/udp.h
+++ b/include/openthread/platform/udp.h
@@ -68,7 +68,7 @@ otError otPlatUdpClose(otUdpSocket *aUdpSocket);
*
* @param[in] aUdpSocket A pointer to the UDP socket.
*
- * @retval OT_ERROR_NONE Successfully binded UDP socket by platform.
+ * @retval OT_ERROR_NONE Successfully bound UDP socket by platform.
* @retval OT_ERROR_FAILED Failed to bind UDP socket.
*
*/
@@ -107,7 +107,7 @@ otError otPlatUdpConnect(otUdpSocket *aUdpSocket);
* @param[in] aMessageInfo A pointer to the message info associated with @p aMessage.
*
* @retval OT_ERROR_NONE Successfully sent by platform, and @p aMessage is freed.
- * @retval OT_ERROR_FAILED Failed to binded UDP socket.
+ * @retval OT_ERROR_FAILED Failed to bind UDP socket.
*
*/
otError otPlatUdpSend(otUdpSocket *aUdpSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo);
@@ -125,7 +125,7 @@ otError otPlatUdpSend(otUdpSocket *aUdpSocket, otMessage *aMessage, const otMess
* @retval OT_ERROR_FAILED Failed to join the multicast group.
*
*/
-otError otPlatUdpJoinMulticastGroup(otUdpSocket * aUdpSocket,
+otError otPlatUdpJoinMulticastGroup(otUdpSocket *aUdpSocket,
otNetifIdentifier aNetifIdentifier,
const otIp6Address *aAddress);
@@ -142,7 +142,7 @@ otError otPlatUdpJoinMulticastGroup(otUdpSocket * aUdpSocket,
* @retval OT_ERROR_FAILED Failed to leave the multicast group.
*
*/
-otError otPlatUdpLeaveMulticastGroup(otUdpSocket * aUdpSocket,
+otError otPlatUdpLeaveMulticastGroup(otUdpSocket *aUdpSocket,
otNetifIdentifier aNetifIdentifier,
const otIp6Address *aAddress);
diff --git a/include/openthread/server.h b/include/openthread/server.h
index 0d177c70127..3ce11170523 100644
--- a/include/openthread/server.h
+++ b/include/openthread/server.h
@@ -94,7 +94,7 @@ otError otServerAddService(otInstance *aInstance, const otServiceConfig *aConfig
* @sa otServerRegister
*
*/
-otError otServerRemoveService(otInstance * aInstance,
+otError otServerRemoveService(otInstance *aInstance,
uint32_t aEnterpriseNumber,
const uint8_t *aServiceData,
uint8_t aServiceDataLength);
diff --git a/include/openthread/sntp.h b/include/openthread/sntp.h
index ca61f0a599a..34b26c28c67 100644
--- a/include/openthread/sntp.h
+++ b/include/openthread/sntp.h
@@ -93,10 +93,10 @@ typedef void (*otSntpResponseHandler)(void *aContext, uint64_t aTime, otError aR
* @param[in] aContext A pointer to arbitrary context information.
*
*/
-otError otSntpClientQuery(otInstance * aInstance,
- const otSntpQuery * aQuery,
+otError otSntpClientQuery(otInstance *aInstance,
+ const otSntpQuery *aQuery,
otSntpResponseHandler aHandler,
- void * aContext);
+ void *aContext);
/**
* This function sets the unix era number.
diff --git a/include/openthread/srp_client.h b/include/openthread/srp_client.h
index bb291d414dd..beaa062250a 100644
--- a/include/openthread/srp_client.h
+++ b/include/openthread/srp_client.h
@@ -74,8 +74,8 @@ typedef enum
*/
typedef struct otSrpClientHostInfo
{
- const char * mName; ///< Host name (label) string (NULL if not yet set).
- const otIp6Address * mAddresses; ///< Array of host IPv6 addresses (NULL if not set or auto address is enabled).
+ const char *mName; ///< Host name (label) string (NULL if not yet set).
+ const otIp6Address *mAddresses; ///< Array of host IPv6 addresses (NULL if not set or auto address is enabled).
uint8_t mNumAddresses; ///< Number of IPv6 addresses in `mAddresses` array.
bool mAutoAddress; ///< Indicates whether auto address mode is enabled or not.
otSrpClientItemState mState; ///< Host info state.
@@ -88,28 +88,34 @@ typedef struct otSrpClientHostInfo
* and stay constant after an instance of this structure is passed to OpenThread from `otSrpClientAddService()` or
* `otSrpClientRemoveService()`.
*
+ * The `mState`, `mData`, `mNext` fields are used/managed by OT core only. Their value is ignored when an instance of
+ * `otSrpClientService` is passed in `otSrpClientAddService()` or `otSrpClientRemoveService()` or other functions. The
+ * caller does not need to set these fields.
+ *
+ * The `mLease` and `mKeyLease` fields specify the desired lease and key lease intervals for this service. Zero value
+ * indicates that the interval is unspecified and then the default lease or key lease intervals from
+ * `otSrpClientGetLeaseInterval()` and `otSrpClientGetKeyLeaseInterval()` are used for this service. If the key lease
+ * interval (whether set explicitly or determined from the default) is shorter than the lease interval for a service,
+ * SRP client will re-use the lease interval value for key lease interval as well. For example, if in service `mLease`
+ * is explicitly set to 2 days and `mKeyLease` is set to zero and default key lease is set to 1 day, then when
+ * registering this service, the requested key lease for this service is also set to 2 days.
+ *
*/
typedef struct otSrpClientService
{
- const char * mName; ///< The service name labels (e.g., "_chip._udp", not the full domain name).
- const char * mInstanceName; ///< The service instance name label (not the full name).
- const char *const * mSubTypeLabels; ///< Array of service sub-type labels (must end with `NULL` or can be `NULL`).
- const otDnsTxtEntry *mTxtEntries; ///< Array of TXT entries (number of entries is given by `mNumTxtEntries`).
- uint16_t mPort; ///< The service port number.
- uint16_t mPriority; ///< The service priority.
- uint16_t mWeight; ///< The service weight.
- uint8_t mNumTxtEntries; ///< Number of entries in the `mTxtEntries` array.
-
- /**
- * @note The following fields are used/managed by OT core only. Their values do not matter and are ignored when an
- * instance of `otSrpClientService` is passed in `otSrpClientAddService()` or `otSrpClientRemoveService()`. The
- * user should not modify these fields.
- *
- */
-
- otSrpClientItemState mState; ///< Service state (managed by OT core).
- uint32_t mData; ///< Internal data (used by OT core).
- struct otSrpClientService *mNext; ///< Pointer to next entry in a linked-list (managed by OT core).
+ const char *mName; ///< The service labels (e.g., "_mt._udp", not the full domain name).
+ const char *mInstanceName; ///< The service instance name label (not the full name).
+ const char *const *mSubTypeLabels; ///< Array of sub-type labels (must end with `NULL` or can be `NULL`).
+ const otDnsTxtEntry *mTxtEntries; ///< Array of TXT entries (`mNumTxtEntries` gives num of entries).
+ uint16_t mPort; ///< The service port number.
+ uint16_t mPriority; ///< The service priority.
+ uint16_t mWeight; ///< The service weight.
+ uint8_t mNumTxtEntries; ///< Number of entries in the `mTxtEntries` array.
+ otSrpClientItemState mState; ///< Service state (managed by OT core).
+ uint32_t mData; ///< Internal data (used by OT core).
+ struct otSrpClientService *mNext; ///< Pointer to next entry in a linked-list (managed by OT core).
+ uint32_t mLease; ///< Desired lease interval in sec - zero to use default.
+ uint32_t mKeyLease; ///< Desired key lease interval in sec - zero to use default.
} otSrpClientService;
/**
@@ -169,9 +175,9 @@ typedef struct otSrpClientService
*/
typedef void (*otSrpClientCallback)(otError aError,
const otSrpClientHostInfo *aHostInfo,
- const otSrpClientService * aServices,
- const otSrpClientService * aRemovedServices,
- void * aContext);
+ const otSrpClientService *aServices,
+ const otSrpClientService *aRemovedServices,
+ void *aContext);
/**
* This function pointer type defines the callback used by SRP client to notify user when it is auto-started or stopped.
@@ -270,12 +276,26 @@ void otSrpClientSetCallback(otInstance *aInstance, otSrpClientCallback aCallback
* Config option `OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_DEFAULT_MODE` specifies the default auto-start mode (whether
* it is enabled or disabled at the start of OT stack).
*
- * When auto-start is enabled, the SRP client will monitor the Thread Network Data for SRP Server Service entries
- * and automatically start and stop the client when an SRP server is detected.
+ * When auto-start is enabled, the SRP client will monitor the Thread Network Data to discover SRP servers and select
+ * the preferred server and automatically start and stop the client when an SRP server is detected.
+ *
+ * There are three categories of Network Data entries indicating presence of SRP sever. They are preferred in the
+ * following order:
+ *
+ * 1) Preferred unicast entries where server address is included in the service data. If there are multiple options,
+ * the one with numerically lowest IPv6 address is preferred.
+ *
+ * 2) Anycast entries each having a seq number. A larger sequence number in the sense specified by Serial Number
+ * Arithmetic logic in RFC-1982 is considered more recent and therefore preferred. The largest seq number using
+ * serial number arithmetic is preferred if it is well-defined (i.e., the seq number is larger than all other
+ * seq numbers). If it is not well-defined, then the numerically largest seq number is preferred.
*
- * If multiple SRP servers are found, a random one will be selected. If the selected SRP server is no longer
- * detected (not longer present in the Thread Network Data), the SRP client will be stopped and then it may switch
- * to another SRP server (if available).
+ * 3) Unicast entries where the server address info is included in server data. If there are multiple options, the
+ * one with numerically lowest IPv6 address is preferred.
+ *
+ * When there is a change in the Network Data entries, client will check that the currently selected server is still
+ * present in the Network Data and is still the preferred one. Otherwise the client will switch to the new preferred
+ * server or stop if there is none.
*
* When the SRP client is explicitly started through a successful call to `otSrpClientStart()`, the given SRP server
* address in `otSrpClientStart()` will continue to be used regardless of the state of auto-start mode and whether the
@@ -345,7 +365,9 @@ uint32_t otSrpClientGetTtl(otInstance *aInstance);
void otSrpClientSetTtl(otInstance *aInstance, uint32_t aTtl);
/**
- * This function gets the lease interval used in SRP update requests.
+ * This function gets the default lease interval used in SRP update requests.
+ *
+ * The default interval is used only for `otSrpClientService` instances with `mLease` set to zero.
*
* Note that this is the lease duration requested by the SRP client. The server may choose to accept a different lease
* interval.
@@ -358,7 +380,9 @@ void otSrpClientSetTtl(otInstance *aInstance, uint32_t aTtl);
uint32_t otSrpClientGetLeaseInterval(otInstance *aInstance);
/**
- * This function sets the lease interval used in SRP update requests.
+ * This function sets the default lease interval used in SRP update requests.
+ *
+ * The default interval is used only for `otSrpClientService` instances with `mLease` set to zero.
*
* Changing the lease interval does not impact the accepted lease interval of already registered services/host-info.
* It only affects any future SRP update messages (i.e., adding new services and/or refreshes of the existing services).
@@ -371,7 +395,9 @@ uint32_t otSrpClientGetLeaseInterval(otInstance *aInstance);
void otSrpClientSetLeaseInterval(otInstance *aInstance, uint32_t aInterval);
/**
- * This function gets the key lease interval used in SRP update requests.
+ * This function gets the default key lease interval used in SRP update requests.
+ *
+ * The default interval is used only for `otSrpClientService` instances with `mKeyLease` set to zero.
*
* Note that this is the lease duration requested by the SRP client. The server may choose to accept a different lease
* interval.
@@ -384,7 +410,9 @@ void otSrpClientSetLeaseInterval(otInstance *aInstance, uint32_t aInterval);
uint32_t otSrpClientGetKeyLeaseInterval(otInstance *aInstance);
/**
- * This function sets the key lease interval used in SRP update requests.
+ * This function sets the default key lease interval used in SRP update requests.
+ *
+ * The default interval is used only for `otSrpClientService` instances with `mKeyLease` set to zero.
*
* Changing the lease interval does not impact the accepted lease interval of already registered services/host-info.
* It only affects any future SRP update messages (i.e., adding new services and/or refreshes of existing services).
diff --git a/include/openthread/srp_server.h b/include/openthread/srp_server.h
index fba71749b03..c3dd36b2f76 100644
--- a/include/openthread/srp_server.h
+++ b/include/openthread/srp_server.h
@@ -132,14 +132,14 @@ enum
};
/**
- * Represents the state of an SRP server
+ * This enumeration represents the state of the SRP server.
*
*/
typedef enum
{
OT_SRP_SERVER_STATE_DISABLED = 0, ///< The SRP server is disabled.
- OT_SRP_SERVER_STATE_RUNNING = 1, ///< The SRP server is running.
- OT_SRP_SERVER_STATE_STOPPED = 2, ///< The SRP server is stopped.
+ OT_SRP_SERVER_STATE_RUNNING = 1, ///< The SRP server is enabled and running.
+ OT_SRP_SERVER_STATE_STOPPED = 2, ///< The SRP server is enabled but stopped.
} otSrpServerState;
/**
@@ -302,12 +302,49 @@ otError otSrpServerSetAnycastModeSequenceNumber(otInstance *aInstance, uint8_t a
/**
* This function enables/disables the SRP server.
*
+ * On a Border Router, it is recommended to use `otSrpServerSetAutoEnableMode()` instead.
+ *
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aEnabled A boolean to enable/disable the SRP server.
*
*/
void otSrpServerSetEnabled(otInstance *aInstance, bool aEnabled);
+/**
+ * This function enables/disables the auto-enable mode on SRP server.
+ *
+ * This function requires `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` feature.
+ *
+ * When this mode is enabled, the Border Routing Manager controls if/when to enable or disable the SRP server.
+ * SRP sever is auto-enabled if/when Border Routing is started and it is done with the initial prefix and route
+ * configurations (when the OMR and on-link prefixes are determined, advertised in emitted Router Advertisement message
+ * on infrastructure side and published in the Thread Network Data). The SRP server is auto-disabled if/when BR is
+ * stopped (e.g., if the infrastructure network interface is brought down or if BR gets detached).
+ *
+ * This mode can be disabled by a `otSrpServerSetAutoEnableMode()` call with @p aEnabled set to `false` or if the SRP
+ * server is explicitly enabled or disabled by a call to `otSrpServerSetEnabled()` function. Disabling auto-enable mode
+ * using `otSrpServerSetAutoEnableMode(false)` will not change the current state of SRP sever (e.g., if it is enabled
+ * it stays enabled).
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aEnabled A boolean to enable/disable the auto-enable mode.
+ *
+ */
+void otSrpServerSetAutoEnableMode(otInstance *aInstance, bool aEnabled);
+
+/**
+ * This function indicates whether the auto-enable mode is enabled or disabled.
+ *
+ * This function requires `OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE` feature.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ * @retval TRUE The auto-enable mode is enabled.
+ * @retval FALSE The auto-enable mode is disabled.
+ *
+ */
+bool otSrpServerIsAutoEnableMode(otInstance *aInstance);
+
/**
* This function returns SRP server TTL configuration.
*
@@ -392,9 +429,9 @@ otError otSrpServerSetLeaseConfig(otInstance *aInstance, const otSrpServerLeaseC
*
*/
typedef void (*otSrpServerServiceUpdateHandler)(otSrpServerServiceUpdateId aId,
- const otSrpServerHost * aHost,
+ const otSrpServerHost *aHost,
uint32_t aTimeout,
- void * aContext);
+ void *aContext);
/**
* This function sets the SRP service updates handler on SRP server.
@@ -405,9 +442,9 @@ typedef void (*otSrpServerServiceUpdateHandler)(otSrpServerServiceUpdateId aId,
* May be NULL if not used.
*
*/
-void otSrpServerSetServiceUpdateHandler(otInstance * aInstance,
+void otSrpServerSetServiceUpdateHandler(otInstance *aInstance,
otSrpServerServiceUpdateHandler aServiceHandler,
- void * aContext);
+ void *aContext);
/**
* This function reports the result of processing a SRP update to the SRP server.
@@ -500,7 +537,7 @@ void otSrpServerHostGetLeaseInfo(const otSrpServerHost *aHost, otSrpServerLeaseI
* @returns A pointer to the next service or NULL if there is no more services.
*
*/
-const otSrpServerService *otSrpServerHostGetNextService(const otSrpServerHost * aHost,
+const otSrpServerService *otSrpServerHostGetNextService(const otSrpServerHost *aHost,
const otSrpServerService *aService);
/**
@@ -535,11 +572,11 @@ const otSrpServerService *otSrpServerHostGetNextService(const otSrpServerHost *
* @returns A pointer to the next matching service or NULL if no matching service could be found.
*
*/
-const otSrpServerService *otSrpServerHostFindNextService(const otSrpServerHost * aHost,
+const otSrpServerService *otSrpServerHostFindNextService(const otSrpServerHost *aHost,
const otSrpServerService *aPrevService,
otSrpServerServiceFlags aFlags,
- const char * aServiceName,
- const char * aInstanceName);
+ const char *aServiceName,
+ const char *aInstanceName);
/**
* This function indicates whether or not the SRP service has been deleted.
diff --git a/include/openthread/tcp.h b/include/openthread/tcp.h
index 6cc11f79495..3b63bc359c5 100644
--- a/include/openthread/tcp.h
+++ b/include/openthread/tcp.h
@@ -63,7 +63,7 @@ extern "C" {
typedef struct otLinkedBuffer
{
struct otLinkedBuffer *mNext; ///< Pointer to the next linked buffer in the chain, or NULL if it is the end.
- const uint8_t * mData; ///< Pointer to data referenced by this linked buffer.
+ const uint8_t *mData; ///< Pointer to data referenced by this linked buffer.
size_t mLength; ///< Length of this linked buffer (number of bytes).
} otLinkedBuffer;
@@ -249,7 +249,7 @@ struct otTcpEndpoint
} mTcb;
struct otTcpEndpoint *mNext; ///< A pointer to the next TCP endpoint (internal use only)
- void * mContext; ///< A pointer to application-specific context
+ void *mContext; ///< A pointer to application-specific context
otTcpEstablished mEstablishedCallback; ///< "Established" callback function
otTcpSendDone mSendDoneCallback; ///< "Send done" callback function
@@ -279,7 +279,7 @@ typedef struct otTcpEndpointInitializeArgs
otTcpReceiveAvailable mReceiveAvailableCallback; ///< "Receive available" callback function
otTcpDisconnected mDisconnectedCallback; ///< "Disconnected" callback function
- void * mReceiveBuffer; ///< Pointer to memory provided to the system for the TCP receive buffer
+ void *mReceiveBuffer; ///< Pointer to memory provided to the system for the TCP receive buffer
size_t mReceiveBufferSize; ///< Size of memory provided to the system for the TCP receive buffer
} otTcpEndpointInitializeArgs;
@@ -294,7 +294,7 @@ typedef struct otTcpEndpointInitializeArgs
* select a smaller buffer size.
*
*/
-#define OT_TCP_RECEIVE_BUFFER_SIZE_FEW_HOPS 2599
+#define OT_TCP_RECEIVE_BUFFER_SIZE_FEW_HOPS 2598
/**
* @def OT_TCP_RECEIVE_BUFFER_SIZE_MANY_HOPS
@@ -306,7 +306,7 @@ typedef struct otTcpEndpointInitializeArgs
* so), then it may be advisable to select a large buffer size manually.
*
*/
-#define OT_TCP_RECEIVE_BUFFER_SIZE_MANY_HOPS 4158
+#define OT_TCP_RECEIVE_BUFFER_SIZE_MANY_HOPS 4157
/**
* Initializes a TCP endpoint.
@@ -325,8 +325,8 @@ typedef struct otTcpEndpointInitializeArgs
* @retval OT_ERROR_FAILED Failed to open the TCP endpoint.
*
*/
-otError otTcpEndpointInitialize(otInstance * aInstance,
- otTcpEndpoint * aEndpoint,
+otError otTcpEndpointInitialize(otInstance *aInstance,
+ otTcpEndpoint *aEndpoint,
const otTcpEndpointInitializeArgs *aArgs);
/**
@@ -401,11 +401,11 @@ enum
/**
* Records the remote host and port for this connection.
*
- * By default TCP Fast Open is used. This means that this function merely
- * records the remote host and port, and that the TCP connection establishment
- * handshake only happens on the first call to otTcpSendByReference(). TCP Fast
- * Open can be explicitly disabled using @p aFlags, in which case the TCP
- * connection establishment handshake is initiated immediately.
+ * Caller must wait for `otTcpEstablished` callback indicating that TCP
+ * connection establishment handshake is done before it can start sending data
+ * e.g., calling `otTcpSendByReference()`.
+ *
+ * The TCP Fast Open is not yet supported and @p aFlags is ignored.
*
* @param[in] aEndpoint A pointer to the TCP endpoint structure to connect.
* @param[in] aSockName The IP address and port of the host to which to connect.
@@ -624,9 +624,9 @@ typedef enum otTcpIncomingConnectionAction
* @returns Description of how to handle the incoming connection.
*
*/
-typedef otTcpIncomingConnectionAction (*otTcpAcceptReady)(otTcpListener * aListener,
+typedef otTcpIncomingConnectionAction (*otTcpAcceptReady)(otTcpListener *aListener,
const otSockAddr *aPeer,
- otTcpEndpoint ** aAcceptInto);
+ otTcpEndpoint **aAcceptInto);
/**
* This callback indicates that the TCP connection is now ready for two-way
@@ -670,11 +670,11 @@ struct otTcpListener
union
{
uint8_t mSize[OT_TCP_LISTENER_TCB_SIZE_BASE + OT_TCP_LISTENER_TCB_NUM_PTR * sizeof(void *)];
- void * mAlign;
+ void *mAlign;
} mTcbListen;
struct otTcpListener *mNext; ///< A pointer to the next TCP listener (internal use only)
- void * mContext; ///< A pointer to application-specific context
+ void *mContext; ///< A pointer to application-specific context
otTcpAcceptReady mAcceptReadyCallback; ///< "Accept ready" callback function
otTcpAcceptDone mAcceptDoneCallback; ///< "Accept done" callback function
@@ -709,8 +709,8 @@ typedef struct otTcpListenerInitializeArgs
* @retval OT_ERROR_FAILED Failed to open the TCP listener.
*
*/
-otError otTcpListenerInitialize(otInstance * aInstance,
- otTcpListener * aListener,
+otError otTcpListenerInitialize(otInstance *aInstance,
+ otTcpListener *aListener,
const otTcpListenerInitializeArgs *aArgs);
/**
diff --git a/include/openthread/tcp_ext.h b/include/openthread/tcp_ext.h
index 5c0ddc678e5..0258ac28bf8 100644
--- a/include/openthread/tcp_ext.h
+++ b/include/openthread/tcp_ext.h
@@ -88,10 +88,10 @@ extern "C" {
*/
typedef struct otTcpCircularSendBuffer
{
- const uint8_t *mDataBuffer; ///< Pointer to data in the circular send buffer
- size_t mCapacity; ///< Length of the circular send buffer
- size_t mStartIndex; ///< Index of the first valid byte in the send buffer
- size_t mCapacityUsed; ///< Number of bytes stored in the send buffer
+ uint8_t *mDataBuffer; ///< Pointer to data in the circular send buffer
+ size_t mCapacity; ///< Length of the circular send buffer
+ size_t mStartIndex; ///< Index of the first valid byte in the send buffer
+ size_t mCapacityUsed; ///< Number of bytes stored in the send buffer
otLinkedBuffer mSendLinks[2];
uint8_t mFirstSendLinkIndex;
@@ -107,6 +107,15 @@ typedef struct otTcpCircularSendBuffer
*/
void otTcpCircularSendBufferInitialize(otTcpCircularSendBuffer *aSendBuffer, void *aDataBuffer, size_t aCapacity);
+/**
+ * This enumeration defines flags passed to @p otTcpCircularSendBufferWrite.
+ *
+ */
+enum
+{
+ OT_TCP_CIRCULAR_SEND_BUFFER_WRITE_MORE_TO_COME = 1 << 0,
+};
+
/**
* Sends out data on a TCP endpoint, using the provided TCP circular send
* buffer to manage buffering.
@@ -136,15 +145,17 @@ void otTcpCircularSendBufferInitialize(otTcpCircularSendBuffer *aSendBuffer, voi
* @param[in] aLength The length of the data pointed to by @p aData to copy into the TCP circular send buffer.
* @param[out] aWritten Populated with the amount of data copied into the send buffer, which might be less than
* @p aLength if the send buffer reaches capacity.
+ * @param[in] aFlags Flags specifying options for this operation (see enumeration above).
*
- * @returns OT_ERROR_NONE Successfully copied data into the send buffer and sent it on the TCP endpoint.
- * @returns OT_ERROR_FAILED Failed to send out data on the TCP endpoint.
+ * @retval OT_ERROR_NONE Successfully copied data into the send buffer and sent it on the TCP endpoint.
+ * @retval OT_ERROR_FAILED Failed to send out data on the TCP endpoint.
*/
-otError otTcpCircularSendBufferWrite(otTcpEndpoint * aEndpoint,
+otError otTcpCircularSendBufferWrite(otTcpEndpoint *aEndpoint,
otTcpCircularSendBuffer *aSendBuffer,
- void * aData,
+ const void *aData,
size_t aLength,
- size_t * aWritten);
+ size_t *aWritten,
+ uint32_t aFlags);
/**
* Performs circular-send-buffer-specific handling in the otTcpForwardProgress
@@ -173,9 +184,9 @@ void otTcpCircularSendBufferHandleForwardProgress(otTcpCircularSendBuffer *aSend
*
* @param[in] aSendBuffer A pointer to the TCP circular send buffer whose amount of free space to return.
*
- * @return The amount of free space in the send buffer.
+ * @returns The amount of free space in the send buffer.
*/
-size_t otTcpCircularSendBufferFreeSpace(otTcpCircularSendBuffer *aSendBuffer);
+size_t otTcpCircularSendBufferGetFreeSpace(const otTcpCircularSendBuffer *aSendBuffer);
/**
* Forcibly discards all data in the circular send buffer.
@@ -204,6 +215,37 @@ void otTcpCircularSendBufferForceDiscardAll(otTcpCircularSendBuffer *aSendBuffer
*/
otError otTcpCircularSendBufferDeinitialize(otTcpCircularSendBuffer *aSendBuffer);
+/**
+ * Context structure to use with mbedtls_ssl_set_bio.
+ */
+typedef struct otTcpEndpointAndCircularSendBuffer
+{
+ otTcpEndpoint *mEndpoint;
+ otTcpCircularSendBuffer *mSendBuffer;
+} otTcpEndpointAndCircularSendBuffer;
+
+/**
+ * Non-blocking send callback to pass to mbedtls_ssl_set_bio.
+ *
+ * @param[in] aCtx A pointer to an otTcpEndpointAndCircularSendBuffer.
+ * @param[in] aBuf The data to add to the send buffer.
+ * @param[in] aLen The amount of data to add to the send buffer.
+ *
+ * @returns The number of bytes sent, or an mbedtls error code.
+ */
+int otTcpMbedTlsSslSendCallback(void *aCtx, const unsigned char *aBuf, size_t aLen);
+
+/**
+ * Non-blocking receive callback to pass to mbedtls_ssl_set_bio.
+ *
+ * @param[in] aCtx A pointer to an otTcpEndpointAndCircularSendBuffer.
+ * @param[out] aBuf The buffer into which to receive data.
+ * @param[in] aLen The maximum amount of data that can be received.
+ *
+ * @returns The number of bytes received, or an mbedtls error code.
+ */
+int otTcpMbedTlsSslRecvCallback(void *aCtx, unsigned char *aBuf, size_t aLen);
+
/**
* @}
*
diff --git a/include/openthread/thread.h b/include/openthread/thread.h
index 04cb747f118..4bde02c140d 100644
--- a/include/openthread/thread.h
+++ b/include/openthread/thread.h
@@ -90,15 +90,18 @@ typedef struct otLinkModeConfig
typedef struct
{
otExtAddress mExtAddress; ///< IEEE 802.15.4 Extended Address
- uint32_t mAge; ///< Time last heard
+ uint32_t mAge; ///< Seconds since last heard
+ uint32_t mConnectionTime; ///< Seconds since link establishment (requires `CONFIG_UPTIME_ENABLE`)
uint16_t mRloc16; ///< RLOC16
uint32_t mLinkFrameCounter; ///< Link Frame Counter
uint32_t mMleFrameCounter; ///< MLE Frame Counter
uint8_t mLinkQualityIn; ///< Link Quality In
int8_t mAverageRssi; ///< Average RSSI
int8_t mLastRssi; ///< Last observed RSSI
+ uint8_t mLinkMargin; ///< Link Margin
uint16_t mFrameErrorRate; ///< Frame error rate (0xffff->100%). Requires error tracking feature.
uint16_t mMessageErrorRate; ///< (IPv6) msg error rate (0xffff->100%). Requires error tracking feature.
+ uint16_t mVersion; ///< Thread version of the neighbor
bool mRxOnWhenIdle : 1; ///< rx-on-when-idle
bool mFullThreadDevice : 1; ///< Full Thread Device
bool mFullNetworkData : 1; ///< Full Network Data
@@ -138,6 +141,14 @@ typedef struct
uint8_t mAge; ///< Time last heard
bool mAllocated : 1; ///< Router ID allocated or not
bool mLinkEstablished : 1; ///< Link established with Router ID or not
+ uint8_t mVersion; ///< Thread version
+
+ /**
+ * Parent CSL parameters are only relevant when OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE is enabled.
+ *
+ */
+ uint8_t mCslClockAccuracy; ///< CSL clock accuracy, in ± ppm
+ uint8_t mCslUncertainty; ///< CSL uncertainty, in ±10 us
} otRouterInfo;
/**
@@ -167,6 +178,19 @@ typedef struct otMleCounters
uint16_t mPartitionIdChanges; ///< Number of changes to partition ID.
uint16_t mBetterPartitionAttachAttempts; ///< Number of attempts to attach to a better partition.
+ /**
+ * Role time tracking.
+ *
+ * When uptime feature is enabled (OPENTHREAD_CONFIG_UPTIME_ENABLE = 1) time spent in each MLE role is tracked.
+ *
+ */
+ uint64_t mDisabledTime; ///< Number of milliseconds device has been in OT_DEVICE_ROLE_DISABLED role.
+ uint64_t mDetachedTime; ///< Number of milliseconds device has been in OT_DEVICE_ROLE_DETACHED role.
+ uint64_t mChildTime; ///< Number of milliseconds device has been in OT_DEVICE_ROLE_CHILD role.
+ uint64_t mRouterTime; ///< Number of milliseconds device has been in OT_DEVICE_ROLE_ROUTER role.
+ uint64_t mLeaderTime; ///< Number of milliseconds device has been in OT_DEVICE_ROLE_LEADER role.
+ uint64_t mTrackedTime; ///< Number of milliseconds tracked by previous counters.
+
/**
* Number of times device changed its parent.
*
@@ -241,6 +265,8 @@ bool otThreadIsSingleton(otInstance *aInstance);
/**
* This function starts a Thread Discovery scan.
*
+ * @note A successful call to this function enables the rx-on-when-idle mode for the entire scan procedure.
+ *
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aScanChannels A bit vector indicating which channels to scan (e.g. OT_CHANNEL_11_MASK).
* @param[in] aPanId The PAN ID filter (set to Broadcast PAN to disable filter).
@@ -256,13 +282,13 @@ bool otThreadIsSingleton(otInstance *aInstance);
* @retval OT_ERROR_BUSY Thread Discovery Scan is already in progress.
*
*/
-otError otThreadDiscover(otInstance * aInstance,
+otError otThreadDiscover(otInstance *aInstance,
uint32_t aScanChannels,
uint16_t aPanId,
bool aJoiner,
bool aEnableEui64Filtering,
otHandleActiveScanResult aCallback,
- void * aCallbackContext);
+ void *aCallbackContext);
/**
* This function determines if an MLE Thread Discovery is currently in progress.
@@ -289,7 +315,7 @@ bool otThreadIsDiscoverInProgress(otInstance *aInstance);
* @retval OT_ERROR_INVALID_ARGS Invalid AdvData.
*
*/
-otError otThreadSetJoinerAdvertisement(otInstance * aInstance,
+otError otThreadSetJoinerAdvertisement(otInstance *aInstance,
uint32_t aOui,
const uint8_t *aAdvData,
uint8_t aAdvDataLength);
@@ -297,7 +323,7 @@ otError otThreadSetJoinerAdvertisement(otInstance * aInstance,
#define OT_JOINER_ADVDATA_MAX_LENGTH 64 ///< Maximum AdvData Length of Joiner Advertisement
/**
- * Get the Thread Child Timeout used when operating in the Child role.
+ * Gets the Thread Child Timeout (in seconds) used when operating in the Child role.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -309,7 +335,7 @@ otError otThreadSetJoinerAdvertisement(otInstance * aInstance,
uint32_t otThreadGetChildTimeout(otInstance *aInstance);
/**
- * Set the Thread Child Timeout used when operating in the Child role.
+ * Sets the Thread Child Timeout (in seconds) used when operating in the Child role.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aTimeout The timeout value in seconds.
@@ -320,7 +346,7 @@ uint32_t otThreadGetChildTimeout(otInstance *aInstance);
void otThreadSetChildTimeout(otInstance *aInstance, uint32_t aTimeout);
/**
- * Get the IEEE 802.15.4 Extended PAN ID.
+ * Gets the IEEE 802.15.4 Extended PAN ID.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -332,9 +358,9 @@ void otThreadSetChildTimeout(otInstance *aInstance, uint32_t aTimeout);
const otExtendedPanId *otThreadGetExtendedPanId(otInstance *aInstance);
/**
- * Set the IEEE 802.15.4 Extended PAN ID.
+ * Sets the IEEE 802.15.4 Extended PAN ID.
*
- * This function can only be called while Thread protocols are disabled. A successful
+ * @note Can only be called while Thread protocols are disabled. A successful
* call to this function invalidates the Active and Pending Operational Datasets in
* non-volatile memory.
*
@@ -391,7 +417,7 @@ otError otThreadSetLinkMode(otInstance *aInstance, otLinkModeConfig aConfig);
* Get the Thread Network Key.
*
* @param[in] aInstance A pointer to an OpenThread instance.
- * @param[out] aNetworkKey A pointer to an `otNetworkkey` to return the Thread Network Key.
+ * @param[out] aNetworkKey A pointer to an `otNetworkKey` to return the Thread Network Key.
*
* @sa otThreadSetNetworkKey
*
@@ -451,7 +477,7 @@ otError otThreadSetNetworkKey(otInstance *aInstance, const otNetworkKey *aKey);
otError otThreadSetNetworkKeyRef(otInstance *aInstance, otNetworkKeyRef aKeyRef);
/**
- * This function returns a pointer to the Thread Routing Locator (RLOC) address.
+ * Gets the Thread Routing Locator (RLOC) address.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -461,7 +487,7 @@ otError otThreadSetNetworkKeyRef(otInstance *aInstance, otNetworkKeyRef aKeyRef)
const otIp6Address *otThreadGetRloc(otInstance *aInstance);
/**
- * This function returns a pointer to the Mesh Local EID address.
+ * Gets the Mesh Local EID address.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -497,7 +523,7 @@ const otMeshLocalPrefix *otThreadGetMeshLocalPrefix(otInstance *aInstance);
otError otThreadSetMeshLocalPrefix(otInstance *aInstance, const otMeshLocalPrefix *aMeshLocalPrefix);
/**
- * This function returns the Thread link-local IPv6 address.
+ * Gets the Thread link-local IPv6 address.
*
* The Thread link local address is derived using IEEE802.15.4 Extended Address as Interface Identifier.
*
@@ -509,9 +535,9 @@ otError otThreadSetMeshLocalPrefix(otInstance *aInstance, const otMeshLocalPrefi
const otIp6Address *otThreadGetLinkLocalIp6Address(otInstance *aInstance);
/**
- * This function returns the Thread Link-Local All Thread Nodes multicast address.
+ * Gets the Thread Link-Local All Thread Nodes multicast address.
*
- * The address is a link-local Unicast Prefix-Based Multcast Address [RFC 3306], with:
+ * The address is a link-local Unicast Prefix-Based Multicast Address [RFC 3306], with:
* - flgs set to 3 (P = 1 and T = 1)
* - scop set to 2
* - plen set to 64
@@ -526,9 +552,9 @@ const otIp6Address *otThreadGetLinkLocalIp6Address(otInstance *aInstance);
const otIp6Address *otThreadGetLinkLocalAllThreadNodesMulticastAddress(otInstance *aInstance);
/**
- * This function returns the Thread Realm-Local All Thread Nodes multicast address.
+ * Gets the Thread Realm-Local All Thread Nodes multicast address.
*
- * The address is a realm-local Unicast Prefix-Based Multcast Address [RFC 3306], with:
+ * The address is a realm-local Unicast Prefix-Based Multicast Address [RFC 3306], with:
* - flgs set to 3 (P = 1 and T = 1)
* - scop set to 3
* - plen set to 64
@@ -585,9 +611,9 @@ const char *otThreadGetNetworkName(otInstance *aInstance);
otError otThreadSetNetworkName(otInstance *aInstance, const char *aNetworkName);
/**
- * Get the Thread Domain Name.
+ * Gets the Thread Domain Name.
*
- * This function is only available since Thread 1.2.
+ * @note Available since Thread 1.2.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -599,10 +625,9 @@ otError otThreadSetNetworkName(otInstance *aInstance, const char *aNetworkName);
const char *otThreadGetDomainName(otInstance *aInstance);
/**
- * Set the Thread Domain Name.
+ * Sets the Thread Domain Name. Only succeeds when Thread protocols are disabled.
*
- * This function is only available since Thread 1.2.
- * This function succeeds only when Thread protocols are disabled.
+ * @note Available since Thread 1.2.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aDomainName A pointer to the Thread Domain Name.
@@ -616,9 +641,11 @@ const char *otThreadGetDomainName(otInstance *aInstance);
otError otThreadSetDomainName(otInstance *aInstance, const char *aDomainName);
/**
- * Set/Clear the Interface Identifier manually specified for the Thread Domain Unicast Address.
+ * Sets or clears the Interface Identifier manually specified for the Thread Domain Unicast Address.
*
- * This function is only available since Thread 1.2 when `OPENTHREAD_CONFIG_DUA_ENABLE` is enabled.
+ * Available when `OPENTHREAD_CONFIG_DUA_ENABLE` is enabled.
+ *
+ * @note Only available since Thread 1.2.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aIid A pointer to the Interface Identifier to set or NULL to clear.
@@ -631,9 +658,11 @@ otError otThreadSetDomainName(otInstance *aInstance, const char *aDomainName);
otError otThreadSetFixedDuaInterfaceIdentifier(otInstance *aInstance, const otIp6InterfaceIdentifier *aIid);
/**
- * Get the Interface Identifier manually specified for the Thread Domain Unicast Address.
+ * Gets the Interface Identifier manually specified for the Thread Domain Unicast Address.
+ *
+ * Available when `OPENTHREAD_CONFIG_DUA_ENABLE` is enabled.
*
- * This function is only available since Thread 1.2 when `OPENTHREAD_CONFIG_DUA_ENABLE` is enabled.
+ * @note Only available since Thread 1.2.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -645,7 +674,7 @@ otError otThreadSetFixedDuaInterfaceIdentifier(otInstance *aInstance, const otIp
const otIp6InterfaceIdentifier *otThreadGetFixedDuaInterfaceIdentifier(otInstance *aInstance);
/**
- * Get the thrKeySequenceCounter.
+ * Gets the thrKeySequenceCounter.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -657,7 +686,7 @@ const otIp6InterfaceIdentifier *otThreadGetFixedDuaInterfaceIdentifier(otInstanc
uint32_t otThreadGetKeySequenceCounter(otInstance *aInstance);
/**
- * Set the thrKeySequenceCounter.
+ * Sets the thrKeySequenceCounter.
*
* @note This API is reserved for testing and demo purposes only. Changing settings with
* this API will render a production application non-compliant with the Thread Specification.
@@ -671,7 +700,7 @@ uint32_t otThreadGetKeySequenceCounter(otInstance *aInstance);
void otThreadSetKeySequenceCounter(otInstance *aInstance, uint32_t aKeySequenceCounter);
/**
- * Get the thrKeySwitchGuardTime
+ * Gets the thrKeySwitchGuardTime (in hours).
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -683,7 +712,7 @@ void otThreadSetKeySequenceCounter(otInstance *aInstance, uint32_t aKeySequenceC
uint32_t otThreadGetKeySwitchGuardTime(otInstance *aInstance);
/**
- * Set the thrKeySwitchGuardTime
+ * Sets the thrKeySwitchGuardTime (in hours).
*
* @note This API is reserved for testing and demo purposes only. Changing settings with
* this API will render a production application non-compliant with the Thread Specification.
@@ -845,7 +874,18 @@ otError otThreadGetParentAverageRssi(otInstance *aInstance, int8_t *aParentRssi)
otError otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi);
/**
- * Get the IPv6 counters.
+ * Starts the process for child to search for a better parent while staying attached to its current parent.
+ *
+ * Must be used when device is attached as a child.
+ *
+ * @retval OT_ERROR_NONE Successfully started the process to search for a better parent.
+ * @retval OT_ERROR_INVALID_STATE Device role is not child.
+ *
+ */
+otError otThreadSearchForBetterParent(otInstance *aInstance);
+
+/**
+ * Gets the IPv6 counters.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -855,7 +895,7 @@ otError otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi);
const otIpCounters *otThreadGetIp6Counters(otInstance *aInstance);
/**
- * Reset the IPv6 counters.
+ * Resets the IPv6 counters.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -863,7 +903,7 @@ const otIpCounters *otThreadGetIp6Counters(otInstance *aInstance);
void otThreadResetIp6Counters(otInstance *aInstance);
/**
- * Get the Thread MLE counters.
+ * Gets the Thread MLE counters.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -873,7 +913,7 @@ void otThreadResetIp6Counters(otInstance *aInstance);
const otMleCounters *otThreadGetMleCounters(otInstance *aInstance);
/**
- * Reset the Thread MLE counters.
+ * Resets the Thread MLE counters.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -883,6 +923,8 @@ void otThreadResetMleCounters(otInstance *aInstance);
/**
* This function pointer is called every time an MLE Parent Response message is received.
*
+ * This is used in `otThreadRegisterParentResponseCallback()`.
+ *
* @param[in] aInfo A pointer to a location on stack holding the stats data.
* @param[in] aContext A pointer to callback client-specific context.
*
@@ -892,14 +934,16 @@ typedef void (*otThreadParentResponseCallback)(otThreadParentResponseInfo *aInfo
/**
* This function registers a callback to receive MLE Parent Response data.
*
+ * This function requires `OPENTHREAD_CONFIG_MLE_PARENT_RESPONSE_CALLBACK_API_ENABLE`.
+ *
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aCallback A pointer to a function that is called upon receiving an MLE Parent Response message.
* @param[in] aContext A pointer to callback client-specific context.
*
*/
-void otThreadRegisterParentResponseCallback(otInstance * aInstance,
+void otThreadRegisterParentResponseCallback(otInstance *aInstance,
otThreadParentResponseCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* This structure represents the Thread Discovery Request data.
@@ -929,9 +973,9 @@ typedef void (*otThreadDiscoveryRequestCallback)(const otThreadDiscoveryRequestI
* @param[in] aContext A pointer to callback application-specific context.
*
*/
-void otThreadSetDiscoveryRequestCallback(otInstance * aInstance,
+void otThreadSetDiscoveryRequestCallback(otInstance *aInstance,
otThreadDiscoveryRequestCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* This function pointer type defines the callback to notify the outcome of a `otThreadLocateAnycastDestination()`
@@ -946,7 +990,7 @@ void otThreadSetDiscoveryRequestCallback(otInstance * aInsta
* @param[in] aRloc16 The RLOC16 of the destination if found, otherwise invalid RLOC16 (0xfffe).
*
*/
-typedef void (*otThreadAnycastLocatorCallback)(void * aContext,
+typedef void (*otThreadAnycastLocatorCallback)(void *aContext,
otError aError,
const otIp6Address *aMeshLocalAddress,
uint16_t aRloc16);
@@ -968,10 +1012,10 @@ typedef void (*otThreadAnycastLocatorCallback)(void * aContext,
* @retval OT_ERROR_NO_BUFS Out of buffer to prepare and send the request message.
*
*/
-otError otThreadLocateAnycastDestination(otInstance * aInstance,
- const otIp6Address * aAnycastAddress,
+otError otThreadLocateAnycastDestination(otInstance *aInstance,
+ const otIp6Address *aAnycastAddress,
otThreadAnycastLocatorCallback aCallback,
- void * aContext);
+ void *aContext);
/**
* This function indicates whether an anycast locate request is currently in progress.
@@ -996,9 +1040,9 @@ bool otThreadIsAnycastLocateInProgress(otInstance *aInstance);
* @param[in] aMlIid The ML-IID of the ADDR_NTF.ntf message.
*
*/
-void otThreadSendAddressNotification(otInstance * aInstance,
- otIp6Address * aDestination,
- otIp6Address * aTarget,
+void otThreadSendAddressNotification(otInstance *aInstance,
+ otIp6Address *aDestination,
+ otIp6Address *aTarget,
otIp6InterfaceIdentifier *aMlIid);
/**
@@ -1015,8 +1059,8 @@ void otThreadSendAddressNotification(otInstance * aInstance,
* @retval OT_ERROR_NO_BUFS If insufficient message buffers available.
*
*/
-otError otThreadSendProactiveBackboneNotification(otInstance * aInstance,
- otIp6Address * aTarget,
+otError otThreadSendProactiveBackboneNotification(otInstance *aInstance,
+ otIp6Address *aTarget,
otIp6InterfaceIdentifier *aMlIid,
uint32_t aTimeSinceLastTransaction);
@@ -1035,6 +1079,28 @@ otError otThreadSendProactiveBackboneNotification(otInstance * aIns
*/
otError otThreadDetachGracefully(otInstance *aInstance, otDetachGracefullyCallback aCallback, void *aContext);
+#define OT_DURATION_STRING_SIZE 21 ///< Recommended size for string representation of `uint32_t` duration in seconds.
+
+/**
+ * This function converts an `uint32_t` duration (in seconds) to a human-readable string.
+ *
+ * This function requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled.
+ *
+ * The string follows the format "::" for hours, minutes, seconds (if duration is shorter than one day) or
+ * "d.::" (if longer than a day).
+ *
+ * If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated
+ * but the outputted string is always null-terminated.
+ *
+ * This function is intended for use with `mAge` or `mConnectionTime` in `otNeighborInfo` or `otChildInfo` structures.
+ *
+ * @param[in] aDuration A duration interval in seconds.
+ * @param[out] aBuffer A pointer to a char array to output the string.
+ * @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_DURATION_STRING_SIZE`.
+ *
+ */
+void otConvertDurationInSecondsToString(uint32_t aDuration, char *aBuffer, uint16_t aSize);
+
/**
* @}
*
diff --git a/include/openthread/thread_ftd.h b/include/openthread/thread_ftd.h
index ea052deed39..f2b0db5d958 100644
--- a/include/openthread/thread_ftd.h
+++ b/include/openthread/thread_ftd.h
@@ -58,7 +58,8 @@ typedef struct
{
otExtAddress mExtAddress; ///< IEEE 802.15.4 Extended Address
uint32_t mTimeout; ///< Timeout
- uint32_t mAge; ///< Time last heard
+ uint32_t mAge; ///< Seconds since last heard
+ uint64_t mConnectionTime; ///< Seconds since attach (requires `OPENTHREAD_CONFIG_UPTIME_ENABLE`)
uint16_t mRloc16; ///< RLOC16
uint16_t mChildId; ///< Child ID
uint8_t mNetworkDataVersion; ///< Network Data Version
@@ -68,6 +69,7 @@ typedef struct
uint16_t mFrameErrorRate; ///< Frame error rate (0xffff->100%). Requires error tracking feature.
uint16_t mMessageErrorRate; ///< (IPv6) msg error rate (0xffff->100%). Requires error tracking feature.
uint16_t mQueuedMessageCnt; ///< Number of queued messages for the child.
+ uint16_t mSupervisionInterval; ///< Supervision interval (in seconds).
uint8_t mVersion; ///< MLE version
bool mRxOnWhenIdle : 1; ///< rx-on-when-idle
bool mFullThreadDevice : 1; ///< Full Thread Device
@@ -122,7 +124,7 @@ typedef struct otCacheEntryIterator
} otCacheEntryIterator;
/**
- * Get the maximum number of children currently allowed.
+ * Gets the maximum number of children currently allowed.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -134,7 +136,7 @@ typedef struct otCacheEntryIterator
uint16_t otThreadGetMaxAllowedChildren(otInstance *aInstance);
/**
- * Set the maximum number of children currently allowed.
+ * Sets the maximum number of children currently allowed.
*
* This parameter can only be set when Thread protocol operation has been stopped.
*
@@ -196,19 +198,76 @@ otError otThreadSetRouterEligible(otInstance *aInstance, bool aEligible);
otError otThreadSetPreferredRouterId(otInstance *aInstance, uint8_t aRouterId);
/**
- * Get the Thread Leader Weight used when operating in the Leader role.
+ * This enumeration represents the power supply property on a device.
+ *
+ * This is used as a property in `otDeviceProperties` to calculate the leader weight.
+ *
+ */
+typedef enum
+{
+ OT_POWER_SUPPLY_BATTERY = 0, ///< Battery powered.
+ OT_POWER_SUPPLY_EXTERNAL = 1, ///< Externally powered (mains-powered).
+ OT_POWER_SUPPLY_EXTERNAL_STABLE = 2, ///< Stable external power with a battery backup or UPS.
+ OT_POWER_SUPPLY_EXTERNAL_UNSTABLE = 3, ///< Potentially unstable ext power (e.g. light bulb powered via a switch).
+} otPowerSupply;
+
+/**
+ * This structure represents the device properties which are used for calculating the local leader weight on a
+ * device.
+ *
+ * The parameters are set based on device's capability, whether acting as border router, its power supply config, etc.
+ *
+ * `mIsUnstable` indicates operational stability of device and is determined via a vendor specific mechanism. It can
+ * include the following cases:
+ * - Device internally detects that it loses external power supply more often than usual. What is usual is
+ * determined by the vendor.
+ * - Device internally detects that it reboots more often than usual. What is usual is determined by the vendor.
+ *
+ */
+typedef struct otDeviceProperties
+{
+ otPowerSupply mPowerSupply; ///< Power supply config.
+ bool mIsBorderRouter : 1; ///< Whether device is a border router.
+ bool mSupportsCcm : 1; ///< Whether device supports CCM (can act as a CCM border router).
+ bool mIsUnstable : 1; ///< Operational stability of device (vendor specific).
+ int8_t mLeaderWeightAdjustment; ///< Weight adjustment. Should be -16 to +16 (clamped otherwise).
+} otDeviceProperties;
+
+/**
+ * Get the current device properties.
+ *
+ * @returns The device properties `otDeviceProperties`.
+ *
+ */
+const otDeviceProperties *otThreadGetDeviceProperties(otInstance *aInstance);
+
+/**
+ * Set the device properties which are then used to determine and set the Leader Weight.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aDeviceProperties The device properties.
+ *
+ */
+void otThreadSetDeviceProperties(otInstance *aInstance, const otDeviceProperties *aDeviceProperties);
+
+/**
+ * Gets the Thread Leader Weight used when operating in the Leader role.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns The Thread Leader Weight value.
*
* @sa otThreadSetLeaderWeight
+ * @sa otThreadSetDeviceProperties
*
*/
uint8_t otThreadGetLocalLeaderWeight(otInstance *aInstance);
/**
- * Set the Thread Leader Weight used when operating in the Leader role.
+ * Sets the Thread Leader Weight used when operating in the Leader role.
+ *
+ * This function directly sets the Leader Weight to the new value, replacing its previous value (which may have been
+ * determined from the current `otDeviceProperties`).
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aWeight The Thread Leader Weight value.
@@ -238,7 +297,7 @@ uint32_t otThreadGetPreferredLeaderPartitionId(otInstance *aInstance);
void otThreadSetPreferredLeaderPartitionId(otInstance *aInstance, uint32_t aPartitionId);
/**
- * Get the Joiner UDP Port.
+ * Gets the Joiner UDP Port.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -250,7 +309,7 @@ void otThreadSetPreferredLeaderPartitionId(otInstance *aInstance, uint32_t aPart
uint16_t otThreadGetJoinerUdpPort(otInstance *aInstance);
/**
- * Set the Joiner UDP Port.
+ * Sets the Joiner UDP Port.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aJoinerUdpPort The Joiner UDP Port number.
@@ -355,6 +414,35 @@ uint8_t otThreadGetRouterUpgradeThreshold(otInstance *aInstance);
*/
void otThreadSetRouterUpgradeThreshold(otInstance *aInstance, uint8_t aThreshold);
+/**
+ * Get the MLE_CHILD_ROUTER_LINKS parameter used in the REED role.
+ *
+ * This parameter specifies the max number of neighboring routers with which the device (as an FED)
+ * will try to establish link.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ *
+ * @returns The MLE_CHILD_ROUTER_LINKS value.
+ *
+ * @sa otThreadSetChildRouterLinks
+ *
+ */
+uint8_t otThreadGetChildRouterLinks(otInstance *aInstance);
+
+/**
+ * Set the MLE_CHILD_ROUTER_LINKS parameter used in the REED role.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aChildRouterLinks The MLE_CHILD_ROUTER_LINKS value.
+ *
+ * @retval OT_ERROR_NONE Successfully set the value.
+ * @retval OT_ERROR_INVALID_STATE Thread protocols are enabled.
+ *
+ * @sa otThreadGetChildRouterLinks
+ *
+ */
+otError otThreadSetChildRouterLinks(otInstance *aInstance, uint8_t aChildRouterLinks);
+
/**
* Release a Router ID that has been allocated by the device in the Leader role.
*
@@ -451,7 +539,7 @@ uint8_t otThreadGetRouterSelectionJitter(otInstance *aInstance);
void otThreadSetRouterSelectionJitter(otInstance *aInstance, uint8_t aRouterJitter);
/**
- * The function retains diagnostic information for an attached Child by its Child ID or RLOC16.
+ * Gets diagnostic information for an attached Child by its Child ID or RLOC16.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aChildId The Child ID or RLOC16 for the attached child.
@@ -498,10 +586,10 @@ otError otThreadGetChildInfoByIndex(otInstance *aInstance, uint16_t aChildIndex,
* @sa otThreadGetChildInfoByIndex
*
*/
-otError otThreadGetChildNextIp6Address(otInstance * aInstance,
+otError otThreadGetChildNextIp6Address(otInstance *aInstance,
uint16_t aChildIndex,
otChildIp6AddressIterator *aIterator,
- otIp6Address * aAddress);
+ otIp6Address *aAddress);
/**
* Get the current Router ID Sequence.
@@ -645,7 +733,7 @@ int8_t otThreadGetParentPriority(otInstance *aInstance);
otError otThreadSetParentPriority(otInstance *aInstance, int8_t aParentPriority);
/**
- * This function gets the maximum number of IP addresses that each MTD child may register with this device as parent.
+ * Gets the maximum number of IP addresses that each MTD child may register with this device as parent.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
@@ -657,11 +745,15 @@ otError otThreadSetParentPriority(otInstance *aInstance, int8_t aParentPriority)
uint8_t otThreadGetMaxChildIpAddresses(otInstance *aInstance);
/**
- * This function sets/restores the maximum number of IP addresses that each MTD child may register with this
+ * Sets or restores the maximum number of IP addresses that each MTD child may register with this
* device as parent.
*
- * @note This API requires `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE`, and is only used by Thread Test Harness
- * to limit the address registrations of the reference parent in order to test the MTD DUT reaction.
+ * Pass `0` to clear the setting and restore the default.
+ *
+ * Available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled.
+ *
+ * @note Only used by Thread Test Harness to limit the address registrations of the reference
+ * parent in order to test the MTD DUT reaction.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aMaxIpAddresses The maximum number of IP addresses that each MTD child may register with this
@@ -783,6 +875,36 @@ void otThreadGetRouterIdRange(otInstance *aInstance, uint8_t *aMinRouterId, uint
*
*/
otError otThreadSetRouterIdRange(otInstance *aInstance, uint8_t aMinRouterId, uint8_t aMaxRouterId);
+
+/**
+ * This function indicates whether or not a Router ID is currently allocated.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aRouterId The router ID to check.
+ *
+ * @retval TRUE The @p aRouterId is allocated.
+ * @retval FALSE The @p aRouterId is not allocated.
+ *
+ */
+bool otThreadIsRouterIdAllocated(otInstance *aInstance, uint8_t aRouterId);
+
+/**
+ * This function gets the next hop and path cost towards a given RLOC16 destination.
+ *
+ * This function can be used with either @p aNextHopRloc16 or @p aPathCost being NULL indicating caller does not want
+ * to get the value.
+ *
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aDesRloct16 The RLOC16 of destination.
+ * @param[out] aNextHopRloc16 A pointer to return RLOC16 of next hop, 0xfffe if no next hop.
+ * @param[out] aPathCost A pointer to return path cost towards destination.
+ *
+ */
+void otThreadGetNextHopAndPathCost(otInstance *aInstance,
+ uint16_t aDestRloc16,
+ uint16_t *aNextHopRloc16,
+ uint8_t *aPathCost);
+
/**
* @}
*
diff --git a/include/openthread/trel.h b/include/openthread/trel.h
index e2dcbdbe4b5..26373501c42 100644
--- a/include/openthread/trel.h
+++ b/include/openthread/trel.h
@@ -74,30 +74,23 @@ typedef struct otTrelPeer
typedef uint16_t otTrelPeerIterator;
/**
- * This function enables TREL operation.
+ * Enables or disables TREL operation.
*
- * This function initiates an ongoing DNS-SD browse on the service name "_trel._udp" within the local browsing domain
- * to discover other devices supporting TREL. Device also registers a new service to be advertised using DNS-SD,
- * with the service name is "_trel._udp" indicating its support for TREL. Device is then ready to receive TREL messages
- * from peers.
+ * When @p aEnable is true, this function initiates an ongoing DNS-SD browse on the service name "_trel._udp" within the
+ * local browsing domain to discover other devices supporting TREL. Device also registers a new service to be advertised
+ * using DNS-SD, with the service name is "_trel._udp" indicating its support for TREL. Device is then ready to receive
+ * TREL messages from peers.
*
- * @note By default the OpenThread stack enables the TREL operation on start.
- *
- * @param[in] aInstance The OpenThread instance.
+ * When @p aEnable is false, this function stops the DNS-SD browse on the service name "_trel._udp", stops advertising
+ * TREL DNS-SD service, and clears the TREL peer table.
*
- */
-void otTrelEnable(otInstance *aInstance);
-
-/**
- * This function disables TREL operation.
- *
- * This function stops the DNS-SD browse on the service name "_trel._udp", stops advertising TREL DNS-SD service, and
- * clears the TREL peer table.
+ * @note By default the OpenThread stack enables the TREL operation on start.
*
- * @param[in] aInstance The OpenThread instance.
+ * @param[in] aInstance A pointer to an OpenThread instance.
+ * @param[in] aEnable A boolean to enable/disable the TREL operation.
*
*/
-void otTrelDisable(otInstance *aInstance);
+void otTrelSetEnabled(otInstance *aInstance, bool aEnable);
/**
* This function indicates whether the TREL operation is enabled.
diff --git a/include/openthread/udp.h b/include/openthread/udp.h
index 3b2ffcebac4..5a2681320bd 100644
--- a/include/openthread/udp.h
+++ b/include/openthread/udp.h
@@ -70,7 +70,7 @@ typedef struct otUdpReceiver
{
struct otUdpReceiver *mNext; ///< A pointer to the next UDP receiver (internal use only).
otUdpHandler mHandler; ///< A function pointer to the receiver callback.
- void * mContext; ///< A pointer to application-specific context.
+ void *mContext; ///< A pointer to application-specific context.
} otUdpReceiver;
/**
@@ -125,8 +125,8 @@ typedef struct otUdpSocket
otSockAddr mSockName; ///< The local IPv6 socket address.
otSockAddr mPeerName; ///< The peer IPv6 socket address.
otUdpReceive mHandler; ///< A function pointer to the application callback.
- void * mContext; ///< A pointer to application-specific context.
- void * mHandle; ///< A handle to platform's UDP.
+ void *mContext; ///< A pointer to application-specific context.
+ void *mHandle; ///< A handle to platform's UDP.
struct otUdpSocket *mNext; ///< A pointer to the next UDP socket (internal use only).
} otUdpSocket;
@@ -278,11 +278,11 @@ otUdpSocket *otUdpGetSockets(otInstance *aInstance);
* @param[in] aContext A pointer to application-specific context.
*
*/
-typedef void (*otUdpForwarder)(otMessage * aMessage,
+typedef void (*otUdpForwarder)(otMessage *aMessage,
uint16_t aPeerPort,
otIp6Address *aPeerAddr,
uint16_t aSockPort,
- void * aContext);
+ void *aContext);
/**
* Set UDP forward callback to deliver UDP packets to host.
@@ -306,8 +306,8 @@ void otUdpForwardSetForwarder(otInstance *aInstance, otUdpForwarder aForwarder,
* @warning No matter the call success or fail, the message is freed.
*
*/
-void otUdpForwardReceive(otInstance * aInstance,
- otMessage * aMessage,
+void otUdpForwardReceive(otInstance *aInstance,
+ otMessage *aMessage,
uint16_t aPeerPort,
const otIp6Address *aPeerAddr,
uint16_t aSockPort);
diff --git a/script/bootstrap b/script/bootstrap
index 9a4479c3521..45f2f75978d 100755
--- a/script/bootstrap
+++ b/script/bootstrap
@@ -38,7 +38,7 @@ install_packages_pretty_format()
echo 'Installing pretty tools useful for code contributions...'
# add clang-format and clang-tidy for pretty
- sudo apt-get --no-install-recommends install -y clang-format-9 clang-tidy-9 || echo 'WARNING: could not install clang-format-9 and clang-tidy-9, which is useful if you plan to contribute C/C++ code to the OpenThread project.'
+ sudo apt-get --no-install-recommends install -y clang-format-14 clang-tidy-14 || echo 'WARNING: could not install clang-format-14 and clang-tidy-14, which is useful if you plan to contribute C/C++ code to the OpenThread project.'
# add yapf for pretty
python3 -m pip install yapf==0.31.0 || echo 'WARNING: could not install yapf, which is useful if you plan to contribute python code to the OpenThread project.'
@@ -46,8 +46,8 @@ install_packages_pretty_format()
# add mdv for local size report
python3 -m pip install mdv || echo 'WARNING: could not install mdv, which is required to post markdown size report for OpenThread.'
- # add shfmt for shell pretty, try brew only because snap does not support home directory not being /home and doesn't work in docker.
- command -v shfmt || brew install shfmt || echo 'WARNING: could not install shfmt, which is useful if you plan to contribute shell scripts to the OpenThread project.'
+ # add shfmt for shell pretty
+ command -v shfmt || sudo apt-get install shfmt || echo 'WARNING: could not install shfmt, which is useful if you plan to contribute shell scripts to the OpenThread project.'
}
install_packages_apt()
@@ -66,7 +66,7 @@ install_packages_apt()
if [ "$PLATFORM" = "Raspbian" ]; then
sudo apt-get --no-install-recommends install -y binutils-arm-none-eabi gcc-arm-none-eabi gdb-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
elif [ "$PLATFORM" = "Ubuntu" ]; then
- sudo apt-get --no-install-recommends install -y ca-certificates wget
+ sudo apt-get --no-install-recommends install -y bzip2 ca-certificates wget
(cd /tmp \
&& wget --tries 4 --no-check-certificate --quiet -c https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-"$ARCH"-linux.tar.bz2 \
&& sudo tar xjf gcc-arm-none-eabi-9-2020-q2-update-"$ARCH"-linux.tar.bz2 -C /opt \
@@ -111,11 +111,14 @@ install_packages_brew()
echo 'Installing pretty tools useful for code contributions...'
# add clang-format for pretty
- CLANG_FORMAT_VERSION="clang-format version 9"
- command -v clang-format-9 || (command -v clang-format && (clang-format --version | grep -q "${CLANG_FORMAT_VERSION}")) || {
- brew install llvm@9
- sudo ln -s "$(brew --prefix llvm@9)/bin/clang-format" /usr/local/bin/clang-format-9
- } || echo 'WARNING: could not install llvm@9, which is useful if you plan to contribute C/C++ code to the OpenThread project.'
+ CLANG_FORMAT_VERSION="clang-format version 14"
+ command -v clang-format-14 || (command -v clang-format && (clang-format --version | grep -q "${CLANG_FORMAT_VERSION}")) || {
+ brew install llvm@14
+ sudo ln -s "$(brew --prefix llvm@14)/bin/clang-format" /usr/local/bin/clang-format-14
+ sudo ln -s "$(brew --prefix llvm@14)/bin/clang-tidy" /usr/local/bin/clang-tidy-14
+ sudo ln -s "$(brew --prefix llvm@14)/bin/clang-apply-replacements" /usr/local/bin/clang-apply-replacements-14
+ sudo ln -s "$(brew --prefix llvm@14)/bin/run-clang-tidy" /usr/local/bin/run-clang-tidy-14
+ } || echo 'WARNING: could not install llvm@14, which is useful if you plan to contribute C/C++ code to the OpenThread project.'
# add yapf for pretty
python3 -m pip install yapf || echo 'Failed to install python code formatter yapf. Install it manually if you need.'
diff --git a/script/check-android-build b/script/check-android-build
deleted file mode 100755
index 6647b9f1514..00000000000
--- a/script/check-android-build
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2018, The OpenThread Authors.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. Neither the name of the copyright holder nor the
-# names of its contributors may be used to endorse or promote products
-# derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-
-#
-# Run this command on parent directory of openthread
-#
-
-set -euxo pipefail
-
-check_targets()
-{
- for target in "$@"; do
- make showcommands "${target}"
- test -x "out/target/product/generic/system/bin/${target}"
- done
-
- for target in "$@"; do
- make "clean-${target}" || true
- done
-}
-
-check_datetime()
-{
- local datetime
-
- datetime="$(date)"
- cat >openthread-config-datetime.h <"$RADIO_PTY" <"$RADIO_PTY" &
# Cover setting a valid network interface name.
- readonly VALID_NETIF_NAME="wan$(date +%H%M%S)"
+ VALID_NETIF_NAME="wan$(date +%H%M%S)"
+ readonly VALID_NETIF_NAME
RADIO_URL="spinel+hdlc+uart://${CORE_PTY}?region=US&max-power-table=11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26"
@@ -140,7 +141,8 @@ do_check()
# sleep a while for daemon ready
sleep 2
- readonly OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH=640
+ OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH=640
+ readonly OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH
local -r kMaxStringLength="$((OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH - 1))"
# verify success if command length doesn't exceed the limit
@@ -160,7 +162,8 @@ do_check()
# Cover setting a too long(max is 15 characters) network interface name.
# Expect exit code to be 2(OT_EXIT_INVALID_ARGUMENTS).
- readonly INVALID_NETIF_NAME="wan0123456789123"
+ INVALID_NETIF_NAME="wan0123456789123"
+ readonly INVALID_NETIF_NAME
sudo "${OT_CLI}" -I "${INVALID_NETIF_NAME}" -n "${RADIO_URL}" || test $? = 2
OT_CLI_CMD="$PWD/build/posix/src/posix/ot-cli ${RADIO_URL}"
diff --git a/script/check-scan-build b/script/check-scan-build
index 06329d9ca7d..ef723faad8a 100755
--- a/script/check-scan-build
+++ b/script/check-scan-build
@@ -29,15 +29,16 @@
set -euxo pipefail
-readonly OT_SRCDIR="$(pwd)"
+OT_SRCDIR="$(pwd)"
+readonly OT_SRCDIR
-readonly OT_BUILD_OPTIONS=(
+OT_BUILD_OPTIONS=(
+ "-DBUILD_TESTING=OFF"
"-DOT_ANYCAST_LOCATOR=ON"
"-DOT_BUILD_EXECUTABLES=OFF"
"-DOT_BORDER_AGENT=ON"
"-DOT_BORDER_ROUTER=ON"
"-DOT_BORDER_ROUTING=ON"
- "-DOT_BORDER_ROUTING_NAT64=ON"
"-DOT_COAP=ON"
"-DOT_COAP_BLOCK=ON"
"-DOT_COAP_OBSERVE=ON"
@@ -47,7 +48,6 @@ readonly OT_BUILD_OPTIONS=(
"-DOT_COVERAGE=ON"
"-DOT_CHANNEL_MANAGER=ON"
"-DOT_CHANNEL_MONITOR=ON"
- "-DOT_CHILD_SUPERVISION=ON"
"-DOT_DATASET_UPDATER=ON"
"-DOT_DHCP6_CLIENT=ON"
"-DOT_DHCP6_SERVER=ON"
@@ -59,11 +59,13 @@ readonly OT_BUILD_OPTIONS=(
"-DOT_IP6_FRAGM=ON"
"-DOT_JAM_DETECTION=ON"
"-DOT_JOINER=ON"
- "-DOT_LEGACY=ON"
"-DOT_LOG_LEVEL_DYNAMIC=ON"
"-DOT_MAC_FILTER=ON"
- "-DOT_MTD_NETDIAG=ON"
+ "-DOT_MESH_DIAG=ON"
+ "-DOT_NAT64_BORDER_ROUTING=ON"
+ "-DOT_NAT64_TRANSLATOR=ON"
"-DOT_NEIGHBOR_DISCOVERY_AGENT=ON"
+ "-DOT_NETDIAG_CLIENT=ON"
"-DOT_PING_SENDER=ON"
"-DOT_PLATFORM=external"
"-DOT_RCP_RESTORATION_MAX_COUNT=2"
@@ -73,22 +75,27 @@ readonly OT_BUILD_OPTIONS=(
"-DOT_SNTP_CLIENT=ON"
"-DOT_SRP_CLIENT=ON"
"-DOT_SRP_SERVER=ON"
+ "-DOT_VENDOR_NAME=OpenThread"
+ "-DOT_VENDOR_MODEL=Scan-build"
+ "-DOT_VENDOR_SW_VERSION=OT"
)
+readonly OT_BUILD_OPTIONS
-readonly OT_CFLAGS=(
+OT_CFLAGS=(
"-DMBEDTLS_DEBUG_C"
"-I$(pwd)/third_party/mbedtls"
"-I$(pwd)/third_party/mbedtls/repo/include"
'-DMBEDTLS_CONFIG_FILE=\"mbedtls-config.h\"'
)
+readonly OT_CFLAGS
main()
{
mkdir -p build
cd build
- scan-build-9 cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DOT_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_C_FLAGS="${OT_CFLAGS[*]}" -DCMAKE_CXX_FLAGS="${OT_CFLAGS[*]}" "${OT_BUILD_OPTIONS[@]}" "${OT_SRCDIR}"
- scan-build-9 --status-bugs -analyze-headers -v ninja
+ scan-build-14 cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DOT_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_C_FLAGS="${OT_CFLAGS[*]}" -DCMAKE_CXX_FLAGS="${OT_CFLAGS[*]}" "${OT_BUILD_OPTIONS[@]}" "${OT_SRCDIR}"
+ scan-build-14 --status-bugs -analyze-headers -v ninja
cd "${OT_SRCDIR}"
}
diff --git a/script/check-simulation-build-autotools b/script/check-simulation-build-autotools
index aa6f6316b81..1e3ef250f4d 100755
--- a/script/check-simulation-build-autotools
+++ b/script/check-simulation-build-autotools
@@ -29,7 +29,8 @@
set -euxo pipefail
-readonly OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN)
+OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN)
+readonly OT_BUILD_JOBS
reset_source()
{
@@ -46,7 +47,6 @@ build_all_features()
"-DOPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE=1"
"-DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1"
"-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1"
- "-DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1"
"-DOPENTHREAD_CONFIG_COAP_API_ENABLE=1"
"-DOPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1"
"-DOPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1"
@@ -63,7 +63,6 @@ build_all_features()
"-DOPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1"
"-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1"
"-DOPENTHREAD_CONFIG_JOINER_ENABLE=1"
- "-DOPENTHREAD_CONFIG_LEGACY_ENABLE=1"
"-DOPENTHREAD_CONFIG_LINK_RAW_ENABLE=1"
"-DOPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1"
"-DOPENTHREAD_CONFIG_MAC_BEACON_RSP_WHEN_JOINABLE_ENABLE=1"
@@ -87,7 +86,7 @@ build_all_features()
"-DOPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1"
"-DOPENTHREAD_CONFIG_SRP_CLIENT_ENABLE=1"
"-DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1"
- "-DOPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1"
+ "-DOPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE=1"
"-DOPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1"
"-DOPENTHREAD_CONFIG_MAC_BEACON_PAYLOAD_PARSING_ENABLE=1"
"-DOPENTHREAD_CONFIG_MAC_OUTGOING_BEACON_PAYLOAD_ENABLE=1"
@@ -95,6 +94,8 @@ build_all_features()
local options_1_3=(
"-DOPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1"
+ "-DOPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE=1"
+ "-DOPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE=1"
"-DOPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1"
"-DOPENTHREAD_CONFIG_DUA_ENABLE=1"
"-DOPENTHREAD_CONFIG_MLR_ENABLE=1"
@@ -142,11 +143,9 @@ build_nest_common()
"-DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1"
"-DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1"
"-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1"
- "-DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1"
"-DOPENTHREAD_CONFIG_DATASET_UPDATER_ENABLE=1"
"-DOPENTHREAD_CONFIG_DIAG_ENABLE=1"
"-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1"
- "-DOPENTHREAD_CONFIG_LEGACY_ENABLE=1"
"-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1"
"-DOPENTHREAD_CONFIG_PING_SENDER_ENABLE=1"
"-DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1"
diff --git a/script/check-simulation-build-cmake b/script/check-simulation-build-cmake
index f296ab1ec84..3a0800a2bb0 100755
--- a/script/check-simulation-build-cmake
+++ b/script/check-simulation-build-cmake
@@ -29,7 +29,8 @@
set -euxo pipefail
-readonly OT_BUILDDIR="$(pwd)/build"
+OT_BUILDDIR="$(pwd)/build"
+readonly OT_BUILDDIR
reset_source()
{
@@ -57,6 +58,8 @@ build_all_features()
local options=(
"-DOT_BACKBONE_ROUTER=ON"
"-DOT_BORDER_ROUTING=ON"
+ "-DOT_NAT64_BORDER_ROUTING=ON"
+ "-DOT_NAT64_TRANSLATOR=ON"
"-DOT_CSL_RECEIVER=ON"
"-DOT_MLR=ON"
"-DOT_OTNS=ON"
diff --git a/script/check-size b/script/check-size
index e81c0bfafa9..9076626984e 100755
--- a/script/check-size
+++ b/script/check-size
@@ -29,10 +29,17 @@
set -euo pipefail
-readonly OT_TMP_DIR=/tmp/ot-size-report
-readonly OT_SHA_NEW=${GITHUB_SHA:-$(git rev-parse HEAD)}
-readonly OT_SHA_OLD="$(git cat-file -p "${OT_SHA_NEW}" | grep 'parent ' | head -n1 | cut -d' ' -f2)"
-readonly OT_REPORT_FILE=/tmp/size_report
+OT_TMP_DIR=/tmp/ot-size-report
+readonly OT_TMP_DIR
+
+OT_SHA_NEW=${GITHUB_SHA:-$(git rev-parse HEAD)}
+readonly OT_SHA_NEW
+
+OT_SHA_OLD="$(git cat-file -p "${OT_SHA_NEW}" | grep 'parent ' | head -n1 | cut -d' ' -f2)"
+readonly OT_SHA_OLD
+
+OT_REPORT_FILE=/tmp/size_report
+readonly OT_REPORT_FILE
setup_arm_gcc_7()
{
@@ -119,7 +126,6 @@ size_nrf52840_version()
"-DOT_BORDER_ROUTER=ON"
"-DOT_CHANNEL_MANAGER=ON"
"-DOT_CHANNEL_MONITOR=ON"
- "-DOT_CHILD_SUPERVISION=ON"
"-DOT_COAP=ON"
"-DOT_COAPS=ON"
"-DOT_COMMISSIONER=ON"
@@ -136,7 +142,6 @@ size_nrf52840_version()
"-DOT_LINK_RAW=ON"
"-DOT_MAC_FILTER=ON"
"-DOT_MESSAGE_USE_HEAP=ON"
- "-DOT_MTD_NETDIAG=ON"
"-DOT_NETDATA_PUBLISHER=ON"
"-DOT_PING_SENDER=ON"
"-DOT_SERVICE=ON"
diff --git a/script/clang-format b/script/clang-format
index 01b9535e0c2..e31466d22b5 100755
--- a/script/clang-format
+++ b/script/clang-format
@@ -27,7 +27,7 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-CLANG_FORMAT_VERSION="clang-format version 9.0"
+CLANG_FORMAT_VERSION="clang-format version 14.0"
die()
{
@@ -39,36 +39,41 @@ die()
# expand_aliases shell option is set using shopt.
shopt -s expand_aliases
-if command -v clang-format-9 >/dev/null; then
- alias clang-format=clang-format-9
+if command -v clang-format-14 >/dev/null; then
+ alias clang-format=clang-format-14
elif command -v clang-format >/dev/null; then
case "$(clang-format --version)" in
"$CLANG_FORMAT_VERSION"*) ;;
*)
- die "$(clang-format --version); clang-format 9.0 required"
+ die "$(clang-format --version); clang-format 14.0 required"
;;
esac
else
- die "clang-format 9.0 required"
+ die "clang-format 14.0 required"
fi
clang-format "$@" || die
# ensure EOF newline
REPLACE=no
+FILES=()
for arg; do
case $arg in
-i)
REPLACE=yes
;;
+ -*) ;;
+ *)
+ FILES+=("$arg")
+ ;;
esac
done
-file=$arg
-
[ $REPLACE != yes ] || {
- [ -n "$(tail -c1 "$file")" ] && echo >>"$file"
+ for file in "${FILES[@]}"; do
+ [ -n "$(tail -c1 "$file")" ] && echo >>"$file"
+ done
}
exit 0
diff --git a/script/clang-tidy b/script/clang-tidy
index b2dfb4d4d8e..c4608092626 100755
--- a/script/clang-tidy
+++ b/script/clang-tidy
@@ -27,8 +27,8 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-CLANG_TIDY_VERSION="LLVM version 9.0"
-CLANG_APPLY_REPLACEMENTS_VERSION="clang-apply-replacements version 9.0"
+CLANG_TIDY_VERSION="LLVM version 14.0"
+CLANG_APPLY_REPLACEMENTS_VERSION="clang-apply-replacements version 14.0"
die()
{
@@ -36,9 +36,9 @@ die()
exit 1
}
-# Search for clang-tidy-9
-if command -v clang-tidy-9 >/dev/null; then
- clang_tidy=$(command -v clang-tidy-9)
+# Search for clang-tidy-14
+if command -v clang-tidy-14 >/dev/null; then
+ clang_tidy=$(command -v clang-tidy-14)
elif command -v clang-tidy >/dev/null; then
clang_tidy=$(command -v clang-tidy)
case "$($clang_tidy --version)" in
@@ -49,12 +49,12 @@ elif command -v clang-tidy >/dev/null; then
;;
esac
else
- die "clang-tidy 9.0 required"
+ die "clang-tidy 14.0 required"
fi
-# Search for clang-apply-replacements-9
-if command -v clang-apply-replacements-9 >/dev/null; then
- clang_apply_replacements=$(command -v clang-apply-replacements-9)
+# Search for clang-apply-replacements-14
+if command -v clang-apply-replacements-14 >/dev/null; then
+ clang_apply_replacements=$(command -v clang-apply-replacements-14)
elif command -v clang-apply-replacements >/dev/null; then
clang_apply_replacements=$(command -v clang-apply-replacements)
case "$($clang_apply_replacements --version)" in
@@ -65,20 +65,20 @@ elif command -v clang-apply-replacements >/dev/null; then
;;
esac
else
- die "clang-apply-replacements 9.0 required"
+ die "clang-apply-replacements 14.0 required"
fi
-# Search for run-clang-tidy-9.py
-if command -v run-clang-tidy-9.py >/dev/null; then
- run_clang_tidy=$(command -v run-clang-tidy-9.py)
-elif command -v run-clang-tidy-9 >/dev/null; then
- run_clang_tidy=$(command -v run-clang-tidy-9)
+# Search for run-clang-tidy-14.py
+if command -v run-clang-tidy-14.py >/dev/null; then
+ run_clang_tidy=$(command -v run-clang-tidy-14.py)
+elif command -v run-clang-tidy-14 >/dev/null; then
+ run_clang_tidy=$(command -v run-clang-tidy-14)
elif command -v run-clang-tidy.py >/dev/null; then
run_clang_tidy=$(command -v run-clang-tidy.py)
elif command -v run-clang-tidy >/dev/null; then
run_clang_tidy=$(command -v run-clang-tidy)
else
- die "run-clang-tidy.py 9.0 required"
+ die "run-clang-tidy.py 14.0 required"
fi
$run_clang_tidy -clang-tidy-binary "$clang_tidy" -clang-apply-replacements-binary "$clang_apply_replacements" "$@" || die
diff --git a/script/cmake-build b/script/cmake-build
index b91b7be0959..475728644e3 100755
--- a/script/cmake-build
+++ b/script/cmake-build
@@ -45,6 +45,7 @@
# Compile with the specified ninja build target:
#
# OT_CMAKE_NINJA_TARGET="ot-cli-ftd" script/cmake-build ${platform}
+# OT_CMAKE_NINJA_TARGET="ot-cli-ftd ot-cli-mtd" script/cmake-build ${platform}
#
# Compile with the specified build directory:
#
@@ -61,50 +62,55 @@
set -euxo pipefail
-OT_CMAKE_NINJA_TARGET=${OT_CMAKE_NINJA_TARGET:-}
+OT_CMAKE_NINJA_TARGET=${OT_CMAKE_NINJA_TARGET-}
OT_SRCDIR="$(cd "$(dirname "$0")"/.. && pwd)"
-
readonly OT_SRCDIR
-readonly OT_PLATFORMS=(cc2538 simulation posix)
-readonly OT_POSIX_SIM_COMMON_OPTIONS=(
+
+OT_PLATFORMS=(simulation posix android-ndk)
+readonly OT_PLATFORMS
+
+OT_POSIX_SIM_COMMON_OPTIONS=(
"-DOT_ANYCAST_LOCATOR=ON"
"-DOT_BORDER_AGENT=ON"
+ "-DOT_BORDER_AGENT_ID=ON"
"-DOT_BORDER_ROUTER=ON"
+ "-DOT_CHANNEL_MANAGER=ON"
+ "-DOT_CHANNEL_MONITOR=ON"
+ "-DOT_CHILD_SUPERVISION=ON"
"-DOT_COAP=ON"
+ "-DOT_COAPS=ON"
"-DOT_COAP_BLOCK=ON"
"-DOT_COAP_OBSERVE=ON"
- "-DOT_COAPS=ON"
"-DOT_COMMISSIONER=ON"
- "-DOT_CHANNEL_MANAGER=ON"
- "-DOT_CHANNEL_MONITOR=ON"
- "-DOT_CHILD_SUPERVISION=ON"
+ "-DOT_COMPILE_WARNING_AS_ERROR=ON"
+ "-DOT_COVERAGE=ON"
"-DOT_DATASET_UPDATER=ON"
"-DOT_DHCP6_CLIENT=ON"
"-DOT_DHCP6_SERVER=ON"
"-DOT_DIAGNOSTIC=ON"
+ "-DOT_DNSSD_SERVER=ON"
"-DOT_DNS_CLIENT=ON"
"-DOT_ECDSA=ON"
"-DOT_HISTORY_TRACKER=ON"
"-DOT_IP6_FRAGM=ON"
"-DOT_JAM_DETECTION=ON"
"-DOT_JOINER=ON"
- "-DOT_LEGACY=ON"
+ "-DOT_LOG_LEVEL_DYNAMIC=ON"
"-DOT_MAC_FILTER=ON"
- "-DOT_MTD_NETDIAG=ON"
"-DOT_NEIGHBOR_DISCOVERY_AGENT=ON"
"-DOT_NETDATA_PUBLISHER=ON"
+ "-DOT_NETDIAG_CLIENT=ON"
"-DOT_PING_SENDER=ON"
+ "-DOT_RCP_RESTORATION_MAX_COUNT=2"
"-DOT_REFERENCE_DEVICE=ON"
"-DOT_SERVICE=ON"
"-DOT_SNTP_CLIENT=ON"
"-DOT_SRP_CLIENT=ON"
- "-DOT_COVERAGE=ON"
- "-DOT_LOG_LEVEL_DYNAMIC=ON"
- "-DOT_COMPILE_WARNING_AS_ERROR=ON"
- "-DOT_RCP_RESTORATION_MAX_COUNT=2"
+ "-DOT_SRP_SERVER=ON"
"-DOT_UPTIME=ON"
)
+readonly OT_POSIX_SIM_COMMON_OPTIONS
die()
{
@@ -122,11 +128,11 @@ build()
cd "${builddir}"
cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DOT_COMPILE_WARNING_AS_ERROR=ON "$@" "${OT_SRCDIR}"
-
- if [[ -n ${OT_CMAKE_NINJA_TARGET[*]} ]]; then
- ninja "${OT_CMAKE_NINJA_TARGET[@]}"
- else
+ if [[ -z ${OT_CMAKE_NINJA_TARGET// /} ]]; then
ninja
+ else
+ IFS=' ' read -r -a OT_CMAKE_NINJA_TARGET <<<"${OT_CMAKE_NINJA_TARGET}"
+ ninja "${OT_CMAKE_NINJA_TARGET[@]}"
fi
cd "${OT_SRCDIR}"
@@ -146,30 +152,87 @@ main()
shift
local local_options=()
local options=(
- "-DOT_PLATFORM=${platform}"
"-DOT_SLAAC=ON"
)
case "${platform}" in
+ android-ndk)
+ if [ -z "${NDK-}" ]; then
+ echo "
+The 'NDK' environment variable needs to point to the Android NDK toolchain.
+Please ensure the NDK is downloaded and extracted then try to run this script again
+
+For example:
+ NDK=/opt/android-ndk-r25c ./script/cmake-build-android
+
+You can download the NDK at https://developer.android.com/ndk/downloads
+
+ "
+ exit 1
+ fi
+
+ NDK_CMAKE_TOOLCHAIN_FILE="${NDK?}/build/cmake/android.toolchain.cmake"
+ if [ ! -f "${NDK_CMAKE_TOOLCHAIN_FILE}" ]; then
+ echo "
+Could not fild the Android NDK CMake toolchain file
+- NDK=${NDK}
+- NDK_CMAKE_TOOLCHAIN_FILE=${NDK_CMAKE_TOOLCHAIN_FILE}
+
+ "
+ exit 2
+ fi
+ local_options+=(
+ "-DOT_LOG_OUTPUT=PLATFORM_DEFINED"
+
+ # Add Android NDK flags
+ "-DOT_ANDROID_NDK=1"
+ "-DCMAKE_TOOLCHAIN_FILE=${NDK?}/build/cmake/android.toolchain.cmake"
+
+ # Android API needs to be >= android-24 for `getifsaddrs()`
+ "-DANDROID_PLATFORM=android-24"
+
+ # Store thread settings in the CWD when executing ot-cli or ot-daemon
+ '-DOT_POSIX_SETTINGS_PATH="./thread"'
+ )
+
+ # Rewrite platform to posix
+ platform="posix"
+
+ # Check if OT_DAEMON or OT_APP_CLI flags are needed
+ if [[ ${OT_CMAKE_NINJA_TARGET[*]} =~ "ot-daemon" ]] || [[ ${OT_CMAKE_NINJA_TARGET[*]} =~ "ot-ctl" ]]; then
+ local_options+=("-DOT_DAEMON=ON")
+ elif [[ ${OT_CMAKE_NINJA_TARGET[*]} =~ "ot-cli" ]]; then
+ local_options+=("-DOT_APP_CLI=ON")
+ fi
+
+ options+=("${local_options[@]}")
+ ;;
+
posix)
local_options+=(
+ "-DOT_TCP=OFF"
"-DOT_LOG_OUTPUT=PLATFORM_DEFINED"
"-DOT_POSIX_MAX_POWER_TABLE=ON"
)
options+=("${OT_POSIX_SIM_COMMON_OPTIONS[@]}" "${local_options[@]}")
;;
simulation)
- local_options=("-DOT_LINK_RAW=ON")
+ local_options+=(
+ "-DOT_LINK_RAW=ON"
+ "-DOT_DNS_DSO=ON"
+ "-DOT_DNS_CLIENT_OVER_TCP=ON"
+ "-DOT_UDP_FORWARD=ON"
+ )
options+=("${OT_POSIX_SIM_COMMON_OPTIONS[@]}" "${local_options[@]}")
;;
- cc2538)
- options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=MinSizeRel")
- ;;
*)
options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/${platform}/arm-none-eabi.cmake")
;;
esac
+ options+=(
+ "-DOT_PLATFORM=${platform}"
+ )
options+=("$@")
build "${platform}" "${options[@]}"
}
diff --git a/script/gcda-tool b/script/gcda-tool
index d5bf2035be8..1b757cce6d1 100755
--- a/script/gcda-tool
+++ b/script/gcda-tool
@@ -29,8 +29,11 @@
set -euxo pipefail
-readonly OT_MERGED_PROFILES=merged_profiles
-readonly OT_GCOV_PREFIX_BASE=ot-run
+OT_MERGED_PROFILES=merged_profiles
+readonly OT_MERGED_PROFILES
+
+OT_GCOV_PREFIX_BASE=ot-run
+readonly OT_GCOV_PREFIX_BASE
merge_profiles()
{
diff --git a/script/make-pretty b/script/make-pretty
index 22201c3f1a1..28abdf01461 100755
--- a/script/make-pretty
+++ b/script/make-pretty
@@ -64,15 +64,25 @@
set -euo pipefail
-readonly OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN)
-readonly OT_EXCLUDE_DIRS=(third_party doc/site)
+OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN)
+readonly OT_BUILD_JOBS
-readonly OT_CLANG_SOURCES=('*.c' '*.cc' '*.cpp' '*.h' '*.hpp')
-readonly OT_MARKDOWN_SOURCES=('*.md')
-readonly OT_PYTHON_SOURCES=('*.py')
+OT_EXCLUDE_DIRS=(third_party doc/site)
+readonly OT_EXCLUDE_DIRS
-readonly OT_CLANG_TIDY_FIX_DIRS=('examples' 'include' 'src' 'tests')
-readonly OT_CLANG_TIDY_BUILD_OPTS=(
+OT_CLANG_SOURCES=('*.c' '*.cc' '*.cpp' '*.h' '*.hpp')
+readonly OT_CLANG_SOURCES
+
+OT_MARKDOWN_SOURCES=('*.md')
+readonly OT_MARKDOWN_SOURCES
+
+OT_PYTHON_SOURCES=('*.py')
+readonly OT_PYTHON_SOURCES
+
+OT_CLANG_TIDY_FIX_DIRS=('examples' 'include' 'src' 'tests')
+readonly OT_CLANG_TIDY_FIX_DIRS
+
+OT_CLANG_TIDY_BUILD_OPTS=(
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON'
'-DOT_ANYCAST_LOCATOR=ON'
'-DOT_APP_RCP=OFF'
@@ -83,10 +93,8 @@ readonly OT_CLANG_TIDY_BUILD_OPTS=(
'-DOT_BORDER_AGENT=ON'
'-DOT_BORDER_ROUTER=ON'
'-DOT_BORDER_ROUTING=ON'
- '-DOT_BORDER_ROUTING_NAT64=ON'
'-DOT_CHANNEL_MANAGER=ON'
'-DOT_CHANNEL_MONITOR=ON'
- '-DOT_CHILD_SUPERVISION=ON'
'-DOT_COAP=ON'
'-DOT_COAP_BLOCK=ON'
'-DOT_COAP_OBSERVE=ON'
@@ -99,6 +107,7 @@ readonly OT_CLANG_TIDY_BUILD_OPTS=(
'-DOT_DIAGNOSTIC=ON'
'-DOT_DNS_CLIENT=ON'
'-DOT_DNS_DSO=ON'
+ '-DOT_DNS_UPSTREAM_QUERY=ON'
'-DOT_DNSSD_SERVER=ON'
'-DOT_DUA=ON'
'-DOT_MLR=ON'
@@ -107,13 +116,15 @@ readonly OT_CLANG_TIDY_BUILD_OPTS=(
'-DOT_IP6_FRAGM=ON'
'-DOT_JAM_DETECTION=ON'
'-DOT_JOINER=ON'
- '-DOT_LEGACY=ON'
'-DOT_LINK_RAW=ON'
'-DOT_LINK_METRICS_INITIATOR=ON'
'-DOT_LINK_METRICS_SUBJECT=ON'
'-DOT_MAC_FILTER=ON'
- '-DOT_MTD_NETDIAG=ON'
+ '-DOT_MESH_DIAG=ON'
+ '-DOT_NAT64_BORDER_ROUTING=ON'
+ '-DOT_NAT64_TRANSLATOR=ON'
'-DOT_NETDATA_PUBLISHER=ON'
+ '-DOT_NETDIAG_CLIENT=ON'
'-DOT_PING_SENDER=ON'
'-DOT_REFERENCE_DEVICE=ON'
'-DOT_SERVICE=ON'
@@ -128,12 +139,14 @@ readonly OT_CLANG_TIDY_BUILD_OPTS=(
'-DOT_COMPILE_WARNING_AS_ERROR=ON'
'-DOT_UPTIME=ON'
)
+readonly OT_CLANG_TIDY_BUILD_OPTS
-readonly OT_CLANG_TIDY_CHECKS="\
+OT_CLANG_TIDY_CHECKS="\
-*,\
google-explicit-constructor,\
google-readability-casting,\
misc-unused-using-decls,\
+modernize-loop-convert,\
modernize-use-bool-literals,\
modernize-use-equals-default,\
modernize-use-equals-delete,\
@@ -142,12 +155,12 @@ readability-avoid-const-params-in-decls,\
readability-else-after-return,\
readability-inconsistent-declaration-parameter-name,\
readability-make-member-function-const,\
+readability-redundant-control-flow,\
readability-redundant-member-init,\
readability-simplify-boolean-expr,\
readability-static-accessed-through-instance,\
"
-
-#performance-for-range-copy\
+readonly OT_CLANG_TIDY_CHECKS
do_clang_format()
{
diff --git a/script/package b/script/package
index 4eaafdf3bdb..2cd8eef9458 100755
--- a/script/package
+++ b/script/package
@@ -32,12 +32,14 @@
set -euo pipefail
-readonly OT_BUILDDIR="${OT_BUILDDIR:-${PWD}/build}"
+OT_BUILDDIR="${OT_BUILDDIR:-${PWD}/build}"
+readonly OT_BUILDDIR
main()
{
local builddir
local options=(
+ "-DBUILD_TESTING=OFF"
"-DCMAKE_BUILD_TYPE=Release"
"-DOT_COVERAGE=OFF"
"-DOT_LOG_LEVEL=INFO"
diff --git a/script/test b/script/test
index be16f85bd30..7fc0c3ed214 100755
--- a/script/test
+++ b/script/test
@@ -32,27 +32,62 @@
set -euo pipefail
-readonly OT_BUILDDIR="${OT_BUILDDIR:-${PWD}/build}"
-readonly OT_SRCDIR="${PWD}"
-
-readonly OT_COLOR_PASS='\033[0;32m'
-readonly OT_COLOR_FAIL='\033[0;31m'
-readonly OT_COLOR_SKIP='\033[0;33m'
-readonly OT_COLOR_NONE='\033[0m'
-
-readonly OT_NODE_TYPE="${OT_NODE_TYPE:-cli}"
-readonly OT_NATIVE_IP="${OT_NATIVE_IP:-0}"
-readonly THREAD_VERSION="${THREAD_VERSION:-1.3}"
-readonly INTER_OP="${INTER_OP:-0}"
-readonly VERBOSE="${VERBOSE:-0}"
-readonly BORDER_ROUTING="${BORDER_ROUTING:-1}"
-readonly NAT64="${NAT64:-0}"
-readonly INTER_OP_BBR="${INTER_OP_BBR:-1}"
-
-readonly OT_COREDUMP_DIR="${PWD}/ot-core-dump"
-readonly FULL_LOGS=${FULL_LOGS:-0}
-readonly TREL=${TREL:-0}
-readonly LOCAL_OTBR_DIR=${LOCAL_OTBR_DIR:-""}
+OT_BUILDDIR="${OT_BUILDDIR:-${PWD}/build}"
+readonly OT_BUILDDIR
+
+OT_SRCDIR="${PWD}"
+readonly OT_SRCDIR
+
+OT_COLOR_PASS='\033[0;32m'
+readonly OT_COLOR_PASS
+
+OT_COLOR_FAIL='\033[0;31m'
+readonly OT_COLOR_FAIL
+
+OT_COLOR_SKIP='\033[0;33m'
+readonly OT_COLOR_SKIP
+
+OT_COLOR_NONE='\033[0m'
+readonly OT_COLOR_NONE
+
+OT_NODE_TYPE="${OT_NODE_TYPE:-cli}"
+readonly OT_NODE_TYPE
+
+OT_NATIVE_IP="${OT_NATIVE_IP:-0}"
+readonly OT_NATIVE_IP
+
+THREAD_VERSION="${THREAD_VERSION:-1.3}"
+readonly THREAD_VERSION
+
+INTER_OP="${INTER_OP:-0}"
+readonly INTER_OP
+
+VERBOSE="${VERBOSE:-0}"
+readonly VERBOSE
+
+BORDER_ROUTING="${BORDER_ROUTING:-1}"
+readonly BORDER_ROUTING
+
+NAT64="${NAT64:-0}"
+readonly NAT64
+
+NAT64_SERVICE="${NAT64_SERVICE:-openthread}"
+readonly NAT64_SERVICE
+
+INTER_OP_BBR="${INTER_OP_BBR:-0}"
+readonly INTER_OP_BBR
+
+OT_COREDUMP_DIR="${PWD}/ot-core-dump"
+readonly OT_COREDUMP_DIR
+
+FULL_LOGS=${FULL_LOGS:-0}
+readonly FULL_LOGS
+
+TREL=${TREL:-0}
+readonly TREL
+
+LOCAL_OTBR_DIR=${LOCAL_OTBR_DIR:-""}
+readonly LOCAL_OTBR_DIR
build_simulation()
{
@@ -237,6 +272,7 @@ do_cert()
do_cert_suite()
{
export top_builddir="${OT_BUILDDIR}/openthread-simulation-${THREAD_VERSION}"
+ export top_srcdir="${OT_SRCDIR}"
if [[ ${THREAD_VERSION} != "1.1" ]]; then
export top_builddir_1_3_bbr="${OT_BUILDDIR}/openthread-simulation-1.3-bbr"
@@ -250,7 +286,8 @@ do_cert_suite()
sudo modprobe ip6table_filter
- python3 tests/scripts/thread-cert/run_cert_suite.py --multiply "${MULTIPLY:-1}" "$@"
+ mkdir -p ot_testing
+ ./tests/scripts/thread-cert/run_cert_suite.py --run-directory ot_testing --multiply "${MULTIPLY:-1}" "$@"
exit 0
}
@@ -286,9 +323,27 @@ do_build_otbr_docker()
"-DOT_SRP_CLIENT=ON"
"-DOT_FULL_LOGS=ON"
"-DOT_UPTIME=ON"
+ "-DOTBR_DNS_UPSTREAM_QUERY=ON"
"-DOTBR_DUA_ROUTING=ON"
- "-DCMAKE_CXX_FLAGS='-DOPENTHREAD_CONFIG_DNSSD_SERVER_BIND_UNSPECIFIED_NETIF=1'"
)
+ local args=(
+ "BORDER_ROUTING=${BORDER_ROUTING}"
+ "INFRA_IF_NAME=eth0"
+ "BACKBONE_ROUTER=1"
+ "REFERENCE_DEVICE=1"
+ "OT_BACKBONE_CI=1"
+ "NAT64=${NAT64}"
+ "NAT64_SERVICE=${NAT64_SERVICE}"
+ "DNS64=${NAT64}"
+ "REST_API=0"
+ "WEB_GUI=0"
+ "MDNS=${OTBR_MDNS:-mDNSResponder}"
+ )
+
+ if [[ ${NAT64} != 1 ]]; then
+ # We are testing upstream DNS forwarding in the NAT64 tests, and OPENTHREAD_CONFIG_DNSSD_SERVER_BIND_UNSPECIFIED_NETIF will block OpenThread's DNSSD server since we already have bind9 running.
+ otbr_options+=("-DCMAKE_CXX_FLAGS='-DOPENTHREAD_CONFIG_DNSSD_SERVER_BIND_UNSPECIFIED_NETIF=1'")
+ fi
if [[ ${TREL} == 1 ]]; then
otbr_options+=("-DOTBR_TREL=ON")
@@ -296,13 +351,12 @@ do_build_otbr_docker()
otbr_options+=("-DOTBR_TREL=OFF")
fi
- if [[ ${NAT64} == 1 ]]; then
- otbr_options+=("-DOTBR_BORDER_ROUTING_NAT64=ON")
- else
- otbr_options+=("-DOTBR_BORDER_ROUTING_NAT64=OFF")
- fi
-
local otbr_docker_image=${OTBR_DOCKER_IMAGE:-otbr-ot12-backbone-ci}
+ local docker_build_args=()
+
+ for arg in "${args[@]}"; do
+ docker_build_args+=("--build-arg" "$arg")
+ done
otbrdir=$(mktemp -d -t otbr_XXXXXX)
otdir=$(pwd)
@@ -311,23 +365,24 @@ do_build_otbr_docker()
if [[ -z ${LOCAL_OTBR_DIR} ]]; then
./script/git-tool clone https://github.com/openthread/ot-br-posix.git --depth 1 "${otbrdir}"
else
- cp -r "${LOCAL_OTBR_DIR}"/* "${otbrdir}"
- rm -rf "${otbrdir}"/build
+ rsync -r \
+ --exclude=third_party/openthread/repo \
+ --exclude=.git \
+ --exclude=build \
+ "${LOCAL_OTBR_DIR}/." \
+ "${otbrdir}"
fi
+
cd "${otbrdir}"
rm -rf third_party/openthread/repo
- cp -r "${otdir}" third_party/openthread/repo
+ rsync -r \
+ --exclude=build \
+ "${otdir}/." \
+ third_party/openthread/repo
rm -rf .git
+
docker build -t "${otbr_docker_image}" -f etc/docker/Dockerfile . \
- --build-arg BORDER_ROUTING="${BORDER_ROUTING}" \
- --build-arg INFRA_IF_NAME=eth0 \
- --build-arg BACKBONE_ROUTER=1 \
- --build-arg REFERENCE_DEVICE=1 \
- --build-arg OT_BACKBONE_CI=1 \
- --build-arg NAT64="${NAT64}" \
- --build-arg REST_API=0 \
- --build-arg WEB_GUI=0 \
- --build-arg MDNS="${OTBR_MDNS:-mDNSResponder}" \
+ "${docker_build_args[@]}" \
--build-arg OTBR_OPTIONS="${otbr_options[*]}"
)
@@ -336,7 +391,7 @@ do_build_otbr_docker()
do_pktverify()
{
- python3 ./tests/scripts/thread-cert/pktverify/verify.py "$1"
+ ./tests/scripts/thread-cert/pktverify/verify.py "$1"
}
ot_exec_expect_script()
diff --git a/script/update-makefiles.py b/script/update-makefiles.py
index 2cd45d3b811..bbaeca43ecc 100755
--- a/script/update-makefiles.py
+++ b/script/update-makefiles.py
@@ -147,18 +147,6 @@ def update_build_file(file_name, start_string, end_string, new_list, search_stri
print("Updated " + include_build_gn_file)
-#----------------------------------------------------------------------------------------------
-# Update Android.mk file
-
-android_mk_file = "./Android.mk"
-
-formatted_list = [" {:<63} \\\n".format(file_name) for file_name in core_cpp_files]
-start_string = "LOCAL_SRC_FILES := \\\n"
-end_string = " src/lib/hdlc/hdlc.cpp"
-update_build_file(android_mk_file, start_string, end_string, formatted_list)
-
-print("Updated " + android_mk_file)
-
#----------------------------------------------------------------------------------------------
# Update Makefile.am files
diff --git a/src/cli/BUILD.gn b/src/cli/BUILD.gn
index 2d4e8f6a019..86e06af7666 100644
--- a/src/cli/BUILD.gn
+++ b/src/cli/BUILD.gn
@@ -30,6 +30,8 @@ import("../../etc/gn/openthread.gni")
openthread_cli_sources = [
"cli.cpp",
"cli.hpp",
+ "cli_br.cpp",
+ "cli_br.hpp",
"cli_coap.cpp",
"cli_coap.hpp",
"cli_coap_secure.cpp",
diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt
index 67c8b01b833..32c9d7b34a3 100644
--- a/src/cli/CMakeLists.txt
+++ b/src/cli/CMakeLists.txt
@@ -33,6 +33,7 @@ set(COMMON_INCLUDES
set(COMMON_SOURCES
cli.cpp
+ cli_br.cpp
cli_coap.cpp
cli_coap_secure.cpp
cli_commissioner.cpp
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index f6e32d02dea..6df2c08e1be 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -65,23 +65,23 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
#
# Thus, the existing(previous) way *THIS* library was compiled is
# exactly the FTD path. Meaning the "cli" library always sees
-# the FTD varients of various headers/classes.
+# the FTD variants of various headers/classes.
#
# The same is true of the "ncp" library.
#
-# HOWEVER there are two varients of the CLI application, CLI-MTD
-# and CLI-FTD (and likewise, two varients of the ncp application)
+# HOWEVER there are two variants of the CLI application, CLI-MTD
+# and CLI-FTD (and likewise, two variants of the ncp application)
# These applications link against two different OpenThread libraries.
#
# Which flavor, you get depends upon which library: "mtd" or "ftd" is linked.
#
# Which on the surface appear to link fine against the MTD/FTD library.
#
-# In this description/example we focus on the "nework_data_leader"
-# header file. The FTD varient has many private variables, functions
+# In this description/example we focus on the "network_data_leader"
+# header file. The FTD variant has many private variables, functions
# and other things of "FTD" (ie: full) implementation items.
#
-# In contrast the MTD is generaly stubbed out with stub-functions
+# In contrast the MTD is generally stubbed out with stub-functions
# inlined in the header that return "error not implemented" or similar.
#
# Thus it works... here ... With this file and this example.
@@ -92,20 +92,20 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
# Is this true always? Is this robust?
# Or is there a hidden "got-ya" that will snag the next person?
#
-# This also fails static analisys, checks.
+# This also fails static analysis, checks.
# Application - with MTD vrs FTD class.
# Library #1 (cli-lib) with FTD selected.
# Library #2 (openthread) with two different class flavors.
#
-# The static analisys tools will say: "NOPE" different classes!
+# The static analysis tools will say: "NOPE" different classes!
# Perhaps this will change if/when nothing is implemented in the 'mtd-header'
#
# Additionally, tools that perform "whole program optimization" will
-# throw errors becuase the data structures differ greatly.
+# throw errors because the data structures differ greatly.
#
# Hence, CLI library (and NCP) must exist in two flavors.
#
-# Unless and until these libraries do not "accidently" suck in
+# Unless and until these libraries do not "accidentally" suck in
# a "flavored" header file somewhere.
lib_LIBRARIES = $(NULL)
@@ -153,6 +153,7 @@ libopenthread_cli_radio_a_CPPFLAGS = \
SOURCES_COMMON = \
cli.cpp \
+ cli_br.cpp \
cli_coap.cpp \
cli_coap_secure.cpp \
cli_commissioner.cpp \
@@ -182,6 +183,7 @@ libopenthread_cli_radio_a_SOURCES = \
noinst_HEADERS = \
cli.hpp \
+ cli_br.hpp \
cli_coap.hpp \
cli_coap_secure.hpp \
cli_commissioner.hpp \
diff --git a/src/cli/README.md b/src/cli/README.md
index c088da47494..bdc405b437b 100644
--- a/src/cli/README.md
+++ b/src/cli/README.md
@@ -23,7 +23,7 @@ Done
- [ba](#ba)
- [bbr](#bbr)
-- [br](#br)
+- [br](README_BR.md)
- [bufferinfo](#bufferinfo)
- [ccathreshold](#ccathreshold)
- [channel](#channel)
@@ -34,12 +34,14 @@ Done
- [childtimeout](#childtimeout)
- [coap](README_COAP.md)
- [coaps](README_COAPS.md)
+- [coex](#coex)
- [commissioner](README_COMMISSIONER.md)
- [contextreusedelay](#contextreusedelay)
- [counters](#counters)
- [csl](#csl)
- [dataset](README_DATASET.md)
- [delaytimermin](#delaytimermin)
+- [deviceprops](#deviceprops)
- [diag](#diag)
- [discover](#discover-channel)
- [dns](#dns-config)
@@ -66,10 +68,12 @@ Done
- [log](#log-filename-filename)
- [mac](#mac-retries-direct)
- [macfilter](#macfilter)
+- [meshdiag](#meshdiag-topology)
- [mliid](#mliid-iid)
- [mlr](#mlr-reg-ipaddr--timeout)
- [mode](#mode)
- [multiradio](#multiradio)
+- [nat64](#nat64-cidr)
- [neighbor](#neighbor-list)
- [netdata](README_NETDATA.md)
- [netstat](#netstat)
@@ -82,12 +86,14 @@ Done
- [parent](#parent)
- [parentpriority](#parentpriority)
- [partitionid](#partitionid)
-- [ping](#ping--i-source-ipaddr-size-count-interval-hoplimit-timeout)
+- [ping](#ping-async--i-source-ipaddr-size-count-interval-hoplimit-timeout)
+- [platform](#platform)
- [pollperiod](#pollperiod-pollperiod)
- [preferrouterid](#preferrouterid-routerid)
- [prefix](#prefix)
- [promiscuous](#promiscuous)
-- [pskc](#pskc--p-keypassphrase)
+- [pskc](#pskc)
+- [pskcref](#pskcref)
- [radiofilter](#radiofilter)
- [rcp](#rcp)
- [region](#region)
@@ -100,6 +106,7 @@ Done
- [routereligible](#routereligible)
- [routerselectionjitter](#routerselectionjitter)
- [routerupgradethreshold](#routerupgradethreshold)
+- [childrouterlinks](#childrouterlinks)
- [scan](#scan-channel)
- [service](#service)
- [singleton](#singleton)
@@ -114,6 +121,7 @@ Done
- [udp](README_UDP.md)
- [unsecureport](#unsecureport-add-port)
- [uptime](#uptime)
+- [vendor](#vendor-name)
- [version](#version)
## OpenThread Command Details
@@ -247,7 +255,7 @@ Done
### bbr enable
-Enable Backbone Router Service for Thread 1.2 FTD. `SRV_DATA.ntf` would be triggerred for attached device if there is no Backbone Router Service in Thread Network Data.
+Enable Backbone Router Service for Thread 1.2 FTD. `SRV_DATA.ntf` would be triggered for attached device if there is no Backbone Router Service in Thread Network Data.
`OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is required.
@@ -258,7 +266,7 @@ Done
### bbr disable
-Disable Backbone Router Service for Thread 1.2 FTD. `SRV_DATA.ntf` would be triggerred if Backbone Router is Primary state. o `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is required.
+Disable Backbone Router Service for Thread 1.2 FTD. `SRV_DATA.ntf` would be triggered if Backbone Router is Primary state. o `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is required.
```bash
> bbr disable
@@ -267,7 +275,7 @@ Done
### bbr register
-Register Backbone Router Service for Thread 1.2 FTD. `SRV_DATA.ntf` would be triggerred for attached device.
+Register Backbone Router Service for Thread 1.2 FTD. `SRV_DATA.ntf` would be triggered for attached device.
`OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is required.
@@ -348,77 +356,13 @@ Started
Done
```
-### br
-
-Enbale/disable the Border Routing functionality.
-
-```bash
-> br enable
-Done
-```
-
-```bash
-> br disable
-Done
-```
-
-### br omrprefix
-
-Get the randomly generated off-mesh-routable prefix of the Border Router.
-
-```bash
-> br omrprefix
-fdfc:1ff5:1512:5622::/64
-Done
-```
-
-### br onlinkprefix
-
-Get the randomly generated on-link prefix of the Border Router.
-
-```bash
-> br onlinkprefix
-fd41:2650:a6f5:0::/64
-Done
-```
-
-### br nat64prefix
-
-Get the local NAT64 prefix of the Border Router.
-
-`OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE` is required.
-
-```bash
-> br nat64prefix
-fd14:1078:b3d5:b0b0:0:0::/96
-Done
-```
-
-### br rioprf
-
-Get the preference used when advertising Route Info Options (e.g., for discovered OMR prefixes) in emitted Router Advertisement message.
-
-```bash
-> br rioprf
-med
-Done
-```
-
-### br rioprf \
-
-Set the preference (which may be 'high', 'med', or 'low') to use when advertising Route Info Options (e.g., for discovered OMR prefixes) in emitted Router Advertisement message.
-
-```bash
-> br rioprf low
-Done
-```
-
### bufferinfo
Show the current message buffer information.
- The `total` shows total number of message buffers in pool.
- The `free` shows the number of free message buffers.
+- The `max-used` shows the maximum number of used buffers at the same time since OT stack initialization or last `bufferinfo reset`.
- This is then followed by info about different queues used by OpenThread stack, each line representing info about a queue.
- The first number shows number messages in the queue.
- The second number shows number of buffers used by all messages in the queue.
@@ -428,6 +372,7 @@ Show the current message buffer information.
> bufferinfo
total: 40
free: 40
+max-used: 5
6lo send: 0 0 0
6lo reas: 0 0 0
ip6: 0 0 0
@@ -439,6 +384,15 @@ application coap: 0 0 0
Done
```
+### bufferinfo reset
+
+Reset the message buffer counter tracking maximum number buffers in use at the same time.
+
+```bash
+> bufferinfo reset
+Done
+```
+
### ccathreshold
Get the CCA threshold in dBm measured at antenna connector per IEEE 802.15.4 - 2015 section 10.1.4.
@@ -672,10 +626,10 @@ Print table of attached children.
```bash
> child table
-| ID | RLOC16 | Timeout | Age | LQ In | C_VN |R|D|N|Ver|CSL|QMsgCnt| Extended MAC |
-+-----+--------+------------+------------+-------+------+-+-+-+---+---+-------+------------------+
-| 1 | 0xc801 | 240 | 24 | 3 | 131 |1|0|0| 3| 0 | 0 | 4ecede68435358ac |
-| 2 | 0xc802 | 240 | 2 | 3 | 131 |0|0|0| 3| 1 | 0 | a672a601d2ce37d8 |
+| ID | RLOC16 | Timeout | Age | LQ In | C_VN |R|D|N|Ver|CSL|QMsgCnt|Suprvsn| Extended MAC |
++-----+--------+------------+------------+-------+------+-+-+-+---+---+-------+-------+------------------+
+| 1 | 0xc801 | 240 | 24 | 3 | 131 |1|0|0| 3| 0 | 0 | 129 | 4ecede68435358ac |
+| 2 | 0xc802 | 240 | 2 | 3 | 131 |0|0|0| 3| 1 | 0 | 0 | a672a601d2ce37d8 |
Done
```
@@ -689,11 +643,13 @@ Child ID: 1
Rloc: 9c01
Ext Addr: e2b3540590b0fd87
Mode: rn
+CSL Synchronized: 1
Net Data: 184
Timeout: 100
Age: 0
Link Quality In: 3
RSSI: -20
+Supervision Interval: 129
Done
```
@@ -789,6 +745,27 @@ Set the Child Supervision Check Timeout value.
Done
```
+### childsupervision failcounter
+
+Get the current value of supervision check timeout failure counter.
+
+The counter tracks the number of supervision check failures on the child. It is incremented when the child does not hear from its parent within the specified check timeout interval.
+
+```bash
+> childsupervision failcounter
+0
+Done
+```
+
+### childsupervision failcounter reset
+
+Reset the supervision check timeout failure counter to zero.
+
+```bash
+> childsupervision failcounter reset
+Done
+```
+
### childtimeout
Get the Thread Child Timeout value.
@@ -808,6 +785,72 @@ Set the Thread Child Timeout value.
Done
```
+### coex
+
+Get the coex status.
+
+`OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE` is required.
+
+```bash
+> coex
+Enabled
+Done
+```
+
+### coex disable
+
+Disable coex.
+
+`OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE` is required.
+
+```bash
+> coex disable
+Done
+```
+
+### coex enable
+
+Enable coex.
+
+`OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE` is required.
+
+```bash
+> coex enable
+Done
+```
+
+### coex metrics
+
+Show coex metrics.
+
+`OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE` is required.
+
+```bash
+> coex metrics
+Stopped: false
+Grant Glitch: 0
+Transmit metrics
+ Request: 0
+ Grant Immediate: 0
+ Grant Wait: 0
+ Grant Wait Activated: 0
+ Grant Wait Timeout: 0
+ Grant Deactivated During Request: 0
+ Delayed Grant: 0
+ Average Request To Grant Time: 0
+Receive metrics
+ Request: 0
+ Grant Immediate: 0
+ Grant Wait: 0
+ Grant Wait Activated: 0
+ Grant Wait Timeout: 0
+ Grant Deactivated During Request: 0
+ Delayed Grant: 0
+ Average Request To Grant Time: 0
+ Grant None: 0
+Done
+```
+
### contextreusedelay
Get the CONTEXT_ID_REUSE_DELAY value.
@@ -833,6 +876,7 @@ Get the supported counter names.
```bash
> counters
+br
ip
mac
mle
@@ -843,6 +887,11 @@ Done
Get the counter value.
+Note:
+
+- `OPENTHREAD_CONFIG_UPTIME_ENABLE` is required for MLE role time tracking in `counters mle`
+- `OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE` is required for `counters br`
+
```bash
> counters mac
TxTotal: 10
@@ -887,6 +936,12 @@ Attach Attempts: 1
Partition Id Changes: 1
Better Partition Attach Attempts: 0
Parent Changes: 0
+Time Disabled Milli: 10026
+Time Detached Milli: 6852
+Time Child Milli: 0
+Time Router Milli: 0
+Time Leader Milli: 16195
+Time Tracked Milli: 33073
Done
> counters ip
TxSuccess: 10
@@ -894,6 +949,18 @@ TxFailed: 0
RxSuccess: 5
RxFailed: 0
Done
+> counters br
+Inbound Unicast: Packets 4 Bytes 320
+Inbound Multicast: Packets 0 Bytes 0
+Outbound Unicast: Packets 2 Bytes 160
+Outbound Multicast: Packets 0 Bytes 0
+RA Rx: 4
+RA TxSuccess: 2
+RA TxFailed: 0
+RS Rx: 0
+RS TxSuccess: 2
+RS TxFailed: 0
+Done
```
### counters \ reset
@@ -991,6 +1058,44 @@ Set the minimal delay timer (in seconds).
Done
```
+### deviceprops
+
+Get the current device properties.
+
+```bash
+> deviceprops
+PowerSupply : external
+IsBorderRouter : yes
+SupportsCcm : no
+IsUnstable : no
+WeightAdjustment : 0
+Done
+```
+
+### deviceprops \ \ \ \ \
+
+Set the device properties which are then used to determine and set the Leader Weight.
+
+- power-supply: `battery`, `external`, `external-stable`, or `external-unstable`.
+- weight-adjustment: Valid range is from -16 to +16. Clamped if not within the range.
+
+```bash
+> deviceprops battery 0 0 0 -5
+Done
+
+> deviceprops
+PowerSupply : battery
+IsBorderRouter : no
+SupportsCcm : no
+IsUnstable : no
+WeightAdjustment : -5
+Done
+
+> leaderweight
+51
+Done
+```
+
### discover \[channel\]
Perform an MLE Discovery operation.
@@ -1009,7 +1114,20 @@ Done
Get the default query config used by DNS client.
-The config includes the server IPv6 address and port, response timeout in msec (wait time to rx response), maximum tx attempts before reporting failure, boolean flag to indicate whether the server can resolve the query recursively or not.
+The config includes
+
+- Server IPv6 address and port
+- Response timeout in msec (wait time to rx response)
+- Maximum tx attempts before reporting failure
+- Boolean flag to indicate whether the server can resolve the query recursively or not.
+- Service resolution mode which specifies which records to query. Possible options are:
+ - `srv` : Query for SRV record only.
+ - `txt` : Query for TXT record only.
+ - `srv_txt` : Query for both SRV and TXT records in the same message.
+ - `srv_txt_sep`: Query in parallel for SRV and TXT using separate messages.
+ - `srv_txt_opt`: Query for TXT/SRV together first, if it fails then query separately.
+- Whether to allow/disallow NAT64 address translation during address resolution (requires `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE`)
+- Transport protocol UDP or TCP (requires `OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE`)
```bash
> dns config
@@ -1017,16 +1135,30 @@ Server: [fd00:0:0:0:0:0:0:1]:1234
ResponseTimeout: 5000 ms
MaxTxAttempts: 2
RecursionDesired: no
+ServiceMode: srv_txt_opt
+Nat64Mode: allow
+TransportProtocol: udp
Done
>
```
-### dns config \[DNS server IP\] \[DNS server port\] \[response timeout (ms)\] \[max tx attempts\] \[recursion desired (boolean)\]
+### dns config \[DNS server IP\] \[DNS server port\] \[response timeout (ms)\] \[max tx attempts\] \[recursion desired (boolean)\] \[service mode]
Set the default query config.
+Service mode specifies which records to query. Possible options are:
+
+- `def` : Use default option.
+- `srv` : Query for SRV record only.
+- `txt` : Query for TXT record only.
+- `srv_txt` : Query for both SRV and TXT records in the same message.
+- `srv_txt_sep`: Query in parallel for SRV and TXT using separate messages.
+- `srv_txt_opt`: Query for TXT/SRV together first, if it fails then query separately.
+
+To set protocol effectively to tcp `OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE` is required.
+
```bash
-> dns config fd00::1 1234 5000 2 0
+> dns config fd00::1 1234 5000 2 0 srv_txt_sep tcp
Done
> dns config
@@ -1034,6 +1166,9 @@ Server: [fd00:0:0:0:0:0:0:1]:1234
ResponseTimeout: 5000 ms
MaxTxAttempts: 2
RecursionDesired: no
+ServiceMode: srv_txt_sep
+Nat64Mode: allow
+TransportProtocol: tcp
Done
```
@@ -1051,17 +1186,47 @@ RecursionDesired: yes
Done
```
-### dns resolve \ \[DNS server IP\] \[DNS server port\] \[response timeout (ms)\] \[max tx attempts\] \[recursion desired (boolean)\]
+### dns resolve \ \[DNS server IP\] \[DNS server port\] \[response timeout (ms)\] \[max tx attempts\] \[recursion desired (boolean)\] \[transport protocol\]
Send DNS Query to obtain IPv6 address for given hostname.
The parameters after `hostname` are optional. Any unspecified (or zero) value for these optional parameters is replaced by the value from the current default config (`dns config`).
+To use tcp, `OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE` is required.
+
```bash
> dns resolve ipv6.google.com
> DNS response for ipv6.google.com - 2a00:1450:401b:801:0:0:0:200e TTL: 300
```
+The DNS server IP can be an IPv4 address, which will be synthesized to an IPv6 address using the preferred NAT64 prefix from the network data.
+
+> Note: The command will return `InvalidState` when the DNS server IP is an IPv4 address but the preferred NAT64 prefix is unavailable.
+
+```bash
+> dns resolve example.com 8.8.8.8
+Synthesized IPv6 DNS server address: fdde:ad00:beef:2:0:0:808:808
+DNS response for example.com. - fd4c:9574:3720:2:0:0:5db8:d822 TTL:20456
+Done
+```
+
+### dns resolve4 \ \[DNS server IP\] \[DNS server port\] \[response timeout (ms)\] \[max tx attempts\] \[recursion desired (boolean)\]
+
+Send DNS query to obtain IPv4 address for a given hostname and provide the NAT64 synthesized IPv6 addresses for the IPv4 addresses from the query response.
+
+Requires `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE`.
+
+The parameters after `hostname` are optional. Any unspecified (or zero) value for these optional parameters is replaced by the value from the current default config (`dns config`).
+
+This command requires a NAT64 prefix to be configured and present in Thread Network Data.
+
+For example, if a NAT64 prefix of `2001:db8:122:344::/96` is used within the Thread mesh, the outputted IPv6 address corresponds to an IPv4 address of `142.250.191.78` for the `ipv4.google.com` host:
+
+```bash
+> dns resolve4 ipv4.google.com
+> DNS response for ipv4.google.com - 2001:db8:122:344:0:0:8efa:bf4e TTL: 20456
+```
+
### dns browse \ \[DNS server IP\] \[DNS server port\] \[response timeout (ms)\] \[max tx attempts\] \[recursion desired (boolean)\]
Send a browse (service instance enumeration) DNS query to get the list of services for given service-name.
@@ -1084,12 +1249,26 @@ instance2
Done
```
+```bash
+> dns browse _airplay._tcp.default.service.arpa
+DNS browse response for _airplay._tcp.default.service.arpa.
+Gabe's Mac mini
+ Port:7000, Priority:0, Weight:0, TTL:10
+ Host:Gabes-Mac-mini.default.service.arpa.
+ HostAddress:fd97:739d:386a:1:1c2e:d83c:fcbe:9cf4 TTL:10
+Done
+```
+
+> Note: The DNS server IP can be an IPv4 address, which will be synthesized to an IPv6 address using the preferred NAT64 prefix from the network data. The command will return `InvalidState` when the DNS server IP is an IPv4 address but the preferred NAT64 prefix is unavailable. When testing DNS-SD discovery proxy, the zone is not `local` and instead should be `default.service.arpa`.
+
### dns service \ \ \[DNS server IP\] \[DNS server port\] \[response timeout (ms)\] \[max tx attempts\] \[recursion desired (boolean)\]
Send a service instance resolution DNS query for a given service instance. Service instance label is provided first, followed by the service name (note that service instance label can contain dot '.' character).
The parameters after `service-name` are optional. Any unspecified (or zero) value for these optional parameters is replaced by the value from the current default config (`dns config`).
+> Note: The DNS server IP can be an IPv4 address, which will be synthesized to an IPv6 address using the preferred NAT64 prefix from the network data. The command will return `InvalidState` when the DNS server IP is an IPv4 address but the preferred NAT64 prefix is unavailable.
+
### dns compression \[enable|disable\]
Enable/Disable the "DNS name compression" mode.
@@ -1725,6 +1904,141 @@ Set the log level.
Done
```
+### meshdiag topology [ip6-addrs][children]
+
+Discover network topology (list of routers and their connections).
+
+This command requires `OPENTHREAD_CONFIG_MESH_DIAG_ENABLE` and `OPENTHREAD_FTD`.
+
+Parameters are optional and indicate additional items to discover. Can be added in any order.
+
+- `ip6-addrs` to discover the list of IPv6 addresses of every router.
+- `children` to discover the child table of every router.
+
+Output lists all discovered routers. Information per router:
+
+- Router ID
+- RLOC16
+- Extended MAC address
+- Thread Version (if known).
+- Whether the router is this device is itself (`me`)
+- Whether the router is the parent of this device when device is a child (`parent`)
+- Whether the router is `leader`
+- Whether the router acts as a border router providing external connectivity (`br`)
+- List of routers to which this router has a link:
+ - `3-links`: Router IDs to which this router has a incoming link with link quality 3
+ - `2-links`: Router IDs to which this router has a incoming link with link quality 2
+ - `1-links`: Router IDs to which this router has a incoming link with link quality 1
+ - If a list if empty, it is omitted in the out.
+- If `ip6-addrs`, list of IPv6 addresses of the router
+- If `children`, list of all children of the router. Information per child:
+ - RLOC16
+ - Incoming Link Quality from perspective of parent to child (zero indicates unknown)
+ - Child Device mode (`r` rx-on-when-idle, `d` Full Thread Device, `n` Full Network Data, `-` no flags set)
+ - Whether the child is this device itself (`me`)
+ - Whether the child acts as a border router providing external connectivity (`br`)
+
+Discover network topology:
+
+```bash
+> meshdiag topology
+id:02 rloc16:0x0800 ext-addr:8aa57d2c603fe16c ver:4 - me - leader
+ 3-links:{ 46 }
+id:46 rloc16:0xb800 ext-addr:fe109d277e0175cc ver:4
+ 3-links:{ 02 51 57 }
+id:33 rloc16:0x8400 ext-addr:d2e511a146b9e54d ver:4
+ 3-links:{ 51 57 }
+id:51 rloc16:0xcc00 ext-addr:9aab43ababf05352 ver:4
+ 3-links:{ 33 57 }
+ 2-links:{ 46 }
+id:57 rloc16:0xe400 ext-addr:dae9c4c0e9da55ff ver:4
+ 3-links:{ 46 51 }
+ 1-links:{ 33 }
+Done
+```
+
+Discover network topology with router's IPv6 addresses and children:
+
+```bash
+> meshdiag topology children ip6-addrs
+id:62 rloc16:0xf800 ext-addr:ce349873897233a5 ver:4 - me - br
+ 3-links:{ 46 }
+ ip6-addrs:
+ fdde:ad00:beef:0:0:ff:fe00:f800
+ fdde:ad00:beef:0:211d:39e9:6b2e:4ad1
+ fe80:0:0:0:cc34:9873:8972:33a5
+ children: none
+id:02 rloc16:0x0800 ext-addr:8aa57d2c603fe16c ver:4 - leader - br
+ 3-links:{ 46 51 }
+ ip6-addrs:
+ fdde:ad00:beef:0:0:ff:fe00:fc00
+ fdde:ad00:beef:0:0:ff:fe00:800
+ fdde:ad00:beef:0:8a36:a3eb:47ae:a9b0
+ fe80:0:0:0:88a5:7d2c:603f:e16c
+ children:
+ rloc16:0x0803 lq:3, mode:rn
+ rloc16:0x0804 lq:3, mode:rdn
+id:33 rloc16:0x8400 ext-addr:d2e511a146b9e54d ver:4
+ 3-links:{ 57 }
+ ip6-addrs:
+ fdde:ad00:beef:0:0:ff:fe00:8400
+ fdde:ad00:beef:0:824:a126:cf19:a9f4
+ fe80:0:0:0:d0e5:11a1:46b9:e54d
+ children: none
+id:51 rloc16:0xcc00 ext-addr:9aab43ababf05352 ver:4
+ 3-links:{ 02 46 57 }
+ ip6-addrs:
+ fdde:ad00:beef:0:0:ff:fe00:cc00
+ fdde:ad00:beef:0:2986:bba3:12d0:1dd2
+ fe80:0:0:0:98ab:43ab:abf0:5352
+ children: none
+id:57 rloc16:0xe400 ext-addr:dae9c4c0e9da55ff ver:4
+ 3-links:{ 33 51 }
+ ip6-addrs:
+ fdde:ad00:beef:0:0:ff:fe00:e400
+ fdde:ad00:beef:0:87d0:550:bc18:9920
+ fe80:0:0:0:d8e9:c4c0:e9da:55ff
+ children:
+ rloc16:0xe402 lq:3, mode:rn - br
+ rloc16:0xe403 lq:3, mode:rn
+id:46 rloc16:0xb800 ext-addr:fe109d277e0175cc ver:4
+ 3-links:{ 02 51 62 }
+ ip6-addrs:
+ fdde:ad00:beef:0:0:ff:fe00:b800
+ fdde:ad00:beef:0:df4d:2994:d85c:c337
+ fe80:0:0:0:fc10:9d27:7e01:75cc
+ children: none
+Done
+```
+
+Discover network topology with children:
+
+```bash
+> meshdiag topology children
+id:02 rloc16:0x0800 ext-addr:8aa57d2c603fe16c ver:4 - parent - leader - br
+ 3-links:{ 46 51 }
+ children:
+ rloc16:0x0803 lq:0, mode:rn
+ rloc16:0x0804 lq:0, mode:rdn - me
+id:46 rloc16:0xb800 ext-addr:fe109d277e0175cc ver:4
+ 3-links:{ 02 51 62 }
+ children: none
+id:33 rloc16:0x8400 ext-addr:d2e511a146b9e54d ver:4
+ 3-links:{ 57 }
+ children: none
+id:51 rloc16:0xcc00 ext-addr:9aab43ababf05352 ver:4
+ 3-links:{ 02 46 57 }
+ children: none
+id:57 rloc16:0xe400 ext-addr:dae9c4c0e9da55ff ver:4
+ 3-links:{ 33 51 }
+ children:
+ rloc16:0xe402 lq:3, mode:rn - br
+ rloc16:0xe403 lq:3, mode:rn
+id:62 rloc16:0xf800 ext-addr:ce349873897233a5 ver:4 - br
+ 3-links:{ 46 }
+ children: none
+```
+
### mliid \
Set the Mesh Local IID.
@@ -1835,6 +2149,136 @@ This command is only available when device supports more than one radio link.
Done
```
+### nat64 cidr
+
+Gets the IPv4 configured CIDR in the NAT64 translator.
+
+`OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is required.
+
+```bash
+> nat64 cidr
+192.168.255.0/24
+Done
+```
+
+### nat64 disable
+
+Disable NAT64 functions, including the translator and the prefix publishing.
+
+This command will reset the mapping table in the translator (if NAT64 translator is enabled in the build).
+
+`OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` or `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` are required.
+
+```bash
+> nat64 disable
+Done
+```
+
+### nat64 enable
+
+Enable NAT64 functions, including the translator and the prefix publishing.
+
+This command can be called anytime.
+
+`OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` or `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` are required.
+
+```bash
+> nat64 enable
+Done
+```
+
+### nat64 state
+
+Gets the state of NAT64 functions.
+
+Possible results for prefix manager are (`OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is required):
+
+- `Disabled`: NAT64 prefix manager is disabled.
+- `NotRunning`: NAT64 prefix manager is enabled, but is not running, probably bacause the routing manager is disabled.
+- `Idle`: NAT64 prefix manager is enabled and is running, but is not publishing a NAT64 prefix. Usually when there is another border router publishing a NAT64 prefix with higher priority.
+- `Active`: NAT64 prefix manager is enabled, running and publishing a NAT64 prefix.
+
+Possible results for NAT64 translator are (`OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is required):
+
+- `Disabled`: NAT64 translator is disabled.
+- `NotRunning`: NAT64 translator is enabled, but is not translating packets, probably bacause it is not configued with a NAT64 prefix or a CIDR for NAT64.
+- `Active`: NAT64 translator is enabled and is translating packets.
+
+`OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` or `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` are required.
+
+```bash
+> nat64 state
+PrefixManager: NotRunning
+Translator: NotRunning
+Done
+
+> nat64 state
+PrefixManager: Idle
+Translator: NotRunning
+Done
+
+> nat64 state
+PrefixManager: Active
+Translator: Active
+Done
+```
+
+### nat64 mappings
+
+Get the NAT64 translator mappings.
+
+`OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is required.
+
+```bash
+> nat64 mappings
+| | Address | | 4 to 6 | 6 to 4 |
++----------+---------------------------+--------+--------------+--------------+
+| ID | IPv6 | IPv4 | Expiry | Pkts | Bytes | Pkts | Bytes |
++----------+------------+--------------+--------+------+-------+------+-------+
+| 00021cb9 | fdc7::df79 | 192.168.64.2 | 7196s | 6 | 456 | 11 | 1928 |
+| | TCP | 0 | 0 | 0 | 0 |
+| | UDP | 1 | 136 | 16 | 1608 |
+| | ICMP | 5 | 320 | 5 | 320 |
+```
+
+### nat64 counters
+
+Get the NAT64 translator packet and error counters.
+
+`OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is required.
+
+```bash
+> nat64 counters
+| | 4 to 6 | 6 to 4 |
++---------------+-------------------------+-------------------------+
+| Protocol | Pkts | Bytes | Pkts | Bytes |
++---------------+----------+--------------+----------+--------------+
+| Total | 11 | 704 | 11 | 704 |
+| TCP | 0 | 0 | 0 | 0 |
+| UDP | 0 | 0 | 0 | 0 |
+| ICMP | 11 | 704 | 11 | 704 |
+| Errors | Pkts | Pkts |
++---------------+-------------------------+-------------------------+
+| Total | 8 | 4 |
+| Illegal Pkt | 0 | 0 |
+| Unsup Proto | 0 | 0 |
+| No Mapping | 2 | 0 |
+Done
+```
+
+### neighbor linkquality
+
+Print link quality info for all neighbors.
+
+```bash
+> neighbor linkquality
+| RLOC16 | Extended MAC | Frame Error | Msg Error | Avg RSS | Last RSS | Age |
++--------+------------------+-------------+-----------+---------+----------+-------+
+| 0xe800 | 9e2fa4e1b84f92db | 0.00 % | 0.00 % | -46 | -48 | 1 |
+| 0xc001 | 0ad7ed6beaa6016d | 4.67 % | 0.08 % | -68 | -72 | 10 |
+Done
+```
+
### neighbor list
List RLOC16 of neighbors.
@@ -1859,6 +2303,43 @@ Print table of neighbors.
Done
```
+### neighbor conntime
+
+Print connection time and age of neighbors.
+
+The table provides the following info per neighbor:
+
+- RLOC16
+- Extended MAC address
+- Age (seconds since last heard from neighbor)
+- Connection time (seconds since link establishment with neighbor)
+
+Duration intervals are formatted as `::` for hours, minutes, and seconds if the duration is less than one day. If the duration is longer than one day, the format is `d.::`.
+
+```bash
+> neighbor conntime
+| RLOC16 | Extended MAC | Last Heard (Age) | Connection Time |
++--------+------------------+------------------+------------------+
+| 0x8401 | 1a28be396a14a318 | 00:00:13 | 00:07:59 |
+| 0x5c00 | 723ebf0d9eba3264 | 00:00:03 | 00:11:27 |
+| 0xe800 | ce53628a1e3f5b3c | 00:00:02 | 00:00:15 |
+Done
+```
+
+### neighbor conntime list
+
+Print connection time and age of neighbors.
+
+This command is similar to `neighbor conntime`, but it displays the information in a list format. The age and connection time are both displayed in seconds.
+
+```bash
+> neighbor conntime list
+0x8401 1a28be396a14a318 age:63 conn-time:644
+0x5c00 723ebf0d9eba3264 age:23 conn-time:852
+0xe800 ce53628a1e3f5b3c age:23 conn-time:180
+Done
+```
+
### netstat
List all UDP sockets.
@@ -1995,7 +2476,7 @@ Done
Get the diagnostic information for a Thread Router as parent.
-Note: When operating as a Thread Router, this command will return the cached information from when the device was previously attached as a Thread Child. Returning cached information is necessary to support the Thread Test Harness - Test Scenario 8.2.x requests the former parent (i.e. Joiner Router's) MAC address even if the device has already promoted to a router.
+Note: When operating as a Thread Router when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled, this command will return the cached information from when the device was previously attached as a Thread Child. Returning cached information is necessary to support the Thread Test Harness - Test Scenario 8.2.x requests the former parent (i.e. Joiner Router's) MAC address even if the device has already promoted to a router.
```bash
> parent
@@ -2004,9 +2485,17 @@ Rloc: 5c00
Link Quality In: 3
Link Quality Out: 3
Age: 20
+Version: 4
Done
```
+Note: When `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE` is enabled, this command will return two extra lines with information relevant for CSL Receiver operation.
+
+```bash
+CSL clock accuracy: 20
+CSL uncertainty: 5
+```
+
### parentpriority
Get the assigned parent priority value, -2 means not assigned.
@@ -2059,10 +2548,11 @@ Set the preferred Thread Leader Partition ID.
Done
```
-### ping \[-I source\] \ \[size\] \[count\] \[interval\] \[hoplimit\] \[timeout\]
+### ping \[async\] \[-I source\] \ \[size\] \[count\] \[interval\] \[hoplimit\] \[timeout\]
Send an ICMPv6 Echo Request.
+- async: Use the non-blocking mode. New commands are allowed before the ping process terminates.
- source: The source IPv6 address of the echo request.
- size: The number of data bytes to be sent.
- count: The number of ICMPv6 Echo Requests to be sent.
@@ -2082,6 +2572,18 @@ Done
Done
```
+The address can be an IPv4 address, which will be synthesized to an IPv6 address using the preferred NAT64 prefix from the network data.
+
+> Note: The command will return `InvalidState` when the preferred NAT64 prefix is unavailable.
+
+```bash
+> ping 172.17.0.1
+Pinging synthesized IPv6 address: fdde:ad00:beef:2:0:0:ac11:1
+> 16 bytes from fdde:ad00:beef:2:0:0:ac11:1: icmp_seq=5 hlim=64 time=0ms
+1 packets transmitted, 1 packets received. Packet loss = 0.0%. Round-trip min/avg/max = 0/0.0/0 ms.
+Done
+```
+
### ping stop
Stop sending ICMPv6 Echo Requests.
@@ -2091,9 +2593,19 @@ Stop sending ICMPv6 Echo Requests.
Done
```
+### platform
+
+Print the current platform
+
+```bash
+> platform
+NRF52840
+Done
+```
+
### pollperiod
-Get the customized data poll period of sleepy end device (milliseconds). Only for certification test
+Get the customized data poll period of sleepy end device (milliseconds). Only for certification test.
```bash
> pollperiod
@@ -2103,13 +2615,23 @@ Done
### pollperiod \
-Set the customized data poll period for sleepy end device (milliseconds >= 10ms). Only for certification test
+Set the customized data poll period for sleepy end device (milliseconds >= 10ms). Only for certification test.
```bash
> pollperiod 10
Done
```
+### pskc
+
+Get pskc in hex format.
+
+```bash
+> pskc
+00000000000000000000000000000000
+Done
+```
+
### pskc [-p] \|\
With `-p` generate pskc from \ (UTF-8 encoded) together with **current** network name and extended PAN ID, otherwise set pskc as \ (hex format).
@@ -2121,6 +2643,29 @@ Done
Done
```
+### pskcref
+
+Get pskc key reference.
+
+`OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is required.
+
+```bash
+> pskcref
+0x80000000
+Done
+```
+
+### pskcref \
+
+Set pskc key reference as \.
+
+`OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is required.
+
+```bash
+> pskcref 0x20017
+Done
+```
+
### preferrouterid \
Prefer a Router ID when solicit router id from Leader.
@@ -2487,6 +3032,25 @@ Set the ROUTER_UPGRADE_THRESHOLD value.
Done
```
+### childrouterlinks
+
+Get the MLE_CHILD_ROUTER_LINKS value.
+
+```bash
+> childrouterlinks
+16
+Done
+```
+
+### childrouterlinks \
+
+Set the MLE_CHILD_ROUTER_LINKS value.
+
+```bash
+> childrouterlinks 16
+Done
+```
+
### scan \[channel\]
Perform an IEEE 802.15.4 Active Scan.
@@ -2834,6 +3398,63 @@ Done
>
```
+### vendor name
+
+This command requires `OPENTHREAD_FTD` or `OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE`.
+
+Get the vendor name.
+
+```bash
+> vendor name
+nest
+Done
+```
+
+Set the vendor name (requires `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE`).
+
+```bash
+> vendor name nest
+Done
+```
+
+### vendor model
+
+This command requires `OPENTHREAD_FTD` or `OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE`.
+
+Get the vendor model.
+
+```bash
+> vendor model
+Hub Max
+Done
+```
+
+Set the vendor model (requires `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE`).
+
+```bash
+> vendor model Hub\ Max
+Done
+```
+
+### vendor swversion
+
+This command requires `OPENTHREAD_FTD` or `OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE`.
+
+Get the vendor SW version.
+
+```bash
+> vendor swversion
+Marble3.5.1
+Done
+```
+
+Set the vendor SW version (requires `OPENTHREAD_CONFIG_NET_DIAG_VENDOR_INFO_SET_API_ENABLE`).
+
+```bash
+> vendor swversion Marble3.5.1
+Done
+```
+
### version
Print the build version information.
diff --git a/src/cli/README_BR.md b/src/cli/README_BR.md
new file mode 100644
index 00000000000..90a50b6197d
--- /dev/null
+++ b/src/cli/README_BR.md
@@ -0,0 +1,208 @@
+# OpenThread CLI - Border Router (BR)
+
+## Command List
+
+Usage : `br [command] ...`
+
+- [counters](#counters)
+- [disable](#disable)
+- [enable](#enable)
+- [help](#help)
+- [nat64prefix](#nat64prefix)
+- [omrprefix](#omrprefix)
+- [onlinkprefix](#onlinkprefix)
+- [prefixtable](#prefixtable)
+- [rioprf](#rioprf)
+- [state](#state)
+
+## Command Details
+
+### help
+
+Usage: `br help`
+
+Print BR command help menu.
+
+```bash
+> br help
+counters
+disable
+enable
+omrprefix
+onlinkprefix
+prefixtable
+rioprf
+state
+Done
+```
+
+### enable
+
+Usage: `br enable`
+
+Enable the Border Routing functionality.
+
+```bash
+> br enable
+Done
+```
+
+### disable
+
+Usage: `br disable`
+
+Disable the Border Routing functionality.
+
+```bash
+> br disable
+Done
+```
+
+### state
+
+Usage: `br state`
+
+Get the Border Routing state:
+
+- `uninitialized`: Routing Manager is uninitialized.
+- `disabled`: Routing Manager is initialized but disabled.
+- `stopped`: Routing Manager in initialized and enabled but currently stopped.
+- `running`: Routing Manager is initialized, enabled, and running.
+
+```bash
+> br state
+running
+```
+
+### counters
+
+Usage : `br counters`
+
+Get the Border Router counter.
+
+```bash
+> br counters
+Inbound Unicast: Packets 4 Bytes 320
+Inbound Multicast: Packets 0 Bytes 0
+Outbound Unicast: Packets 2 Bytes 160
+Outbound Multicast: Packets 0 Bytes 0
+RA Rx: 4
+RA TxSuccess: 2
+RA TxFailed: 0
+RS Rx: 0
+RS TxSuccess: 2
+RS TxFailed: 0
+Done
+```
+
+### omrprefix
+
+Usage: `br omrprefix [local|favored]`
+
+Get local or favored or both off-mesh-routable prefixes of the Border Router.
+
+```bash
+> br omrprefix
+Local: fdfc:1ff5:1512:5622::/64
+Favored: fdfc:1ff5:1512:5622::/64 prf:low
+Done
+
+> br omrprefix favored
+fdfc:1ff5:1512:5622::/64 prf:low
+Done
+
+> br omrprefix local
+fdfc:1ff5:1512:5622::/64
+Done
+```
+
+### onlinkprefix
+
+Usage: `br onlinkprefix [local|favored]`
+
+Get local or favored or both on-link prefixes of the Border Router.
+
+```bash
+> br onlinkprefix
+Local: fd41:2650:a6f5:0::/64
+Favored: 2600::0:1234:da12::/64
+Done
+
+> br onlinkprefix favored
+2600::0:1234:da12::/64
+Done
+
+> br onlinkprefix local
+fd41:2650:a6f5:0::/64
+Done
+```
+
+### nat64prefix
+
+Usage: `br nat64prefix [local|favored]`
+
+Get local or favored or both NAT64 prefixes of the Border Router.
+
+`OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is required.
+
+```bash
+> br nat64prefix
+Local: fd14:1078:b3d5:b0b0:0:0::/96
+Favored: fd14:1078:b3d5:b0b0:0:0::/96 prf:low
+Done
+
+> br nat64prefix favored
+fd14:1078:b3d5:b0b0:0:0::/96 prf:low
+Done
+
+> br nat64prefix
+fd14:1078:b3d5:b0b0:0:0::/96
+Done
+```
+
+### prefixtable
+
+Usage: `br prefixtable`
+
+Get the discovered prefixes by Border Routing Manager on the infrastructure link.
+
+```bash
+> br prefixtable
+prefix:fd00:1234:5678:0::/64, on-link:no, ms-since-rx:29526, lifetime:1800, route-prf:med, router:ff02:0:0:0:0:0:0:1
+prefix:1200:abba:baba:0::/64, on-link:yes, ms-since-rx:29527, lifetime:1800, preferred:1800, router:ff02:0:0:0:0:0:0:1
+Done
+```
+
+### rioprf
+
+Usage: `br rioprf`
+
+Get the preference used when advertising Route Info Options (e.g., for discovered OMR prefixes) in emitted Router Advertisement message.
+
+```bash
+> br rioprf
+med
+Done
+```
+
+### rioprf \
+
+Usage: `br rioprf high|med|low`
+
+Set the preference (which may be 'high', 'med', or 'low') to use when advertising Route Info Options (e.g., for discovered OMR prefixes) in emitted Router Advertisement message.
+
+```bash
+> br rioprf low
+Done
+```
+
+### rioprf clear
+
+Usage: `br rioprf clear`
+
+Clear a previously set preference value for advertising Route Info Options (e.g., for discovered OMR prefixes) in emitted Router Advertisement message. When cleared BR will use device's role to determine the RIO preference: Medium preference when in router/leader role and low preference when in child role.
+
+```bash
+> br rioprf clear
+Done
+```
diff --git a/src/cli/README_DATASET.md b/src/cli/README_DATASET.md
index 87cd4d21c08..df1b274c8a1 100644
--- a/src/cli/README_DATASET.md
+++ b/src/cli/README_DATASET.md
@@ -36,15 +36,15 @@ The Pending Operational Dataset is used to communicate changes to the Active Ope
Done
> dataset
Active Timestamp: 1
- Channel: 13
+ Channel: 15
Channel Mask: 0x07fff800
- Ext PAN ID: d63e8e3e495ebbc3
- Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
- Network Key: dfd34f0f05cad978ec4e32b0413038ff
- Network Name: OpenThread-8f28
- PAN ID: 0x8f28
- PSKc: c23a76e98f1a6483639b1ac1271e2e27
- Security Policy: 0, onrc
+ Ext PAN ID: 39758ec8144b07fb
+ Mesh Local Prefix: fdf1:f1ad:d079:7dc0::/64
+ Network Key: f366cec7a446bab978d90d27abe38f23
+ Network Name: OpenThread-5938
+ PAN ID: 0x5938
+ PSKc: 3ca67c969efb0d0c74a4d8ee923b576c
+ Security Policy: 672 onrc
Done
```
@@ -95,15 +95,15 @@ After the device successfully attaches to a Thread network, the device will retr
```bash
> dataset active
Active Timestamp: 1
- Channel: 13
+ Channel: 15
Channel Mask: 0x07fff800
- Ext PAN ID: d63e8e3e495ebbc3
- Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
- Network Key: dfd34f0f05cad978ec4e32b0413038ff
- Network Name: OpenThread-8f28
- PAN ID: 0x8f28
- PSKc: c23a76e98f1a6483639b1ac1271e2e27
- Security Policy: 0, onrc
+ Ext PAN ID: 39758ec8144b07fb
+ Mesh Local Prefix: fdf1:f1ad:d079:7dc0::/64
+ Network Key: f366cec7a446bab978d90d27abe38f23
+ Network Name: OpenThread-5938
+ PAN ID: 0x5938
+ PSKc: 3ca67c969efb0d0c74a4d8ee923b576c
+ Security Policy: 672 onrc
Done
```
@@ -129,6 +129,7 @@ After the device successfully attaches to a Thread network, the device will retr
- [pendingtimestamp](#pendingtimestamp)
- [pskc](#pskc)
- [securitypolicy](#securitypolicy)
+- [tlvs](#tlvs)
## Command Details
@@ -160,6 +161,8 @@ pending
pendingtimestamp
pskc
securitypolicy
+set
+tlvs
Done
```
@@ -172,15 +175,15 @@ Print Active Operational Dataset in human-readable form.
```bash
> dataset active
Active Timestamp: 1
-Channel: 13
+Channel: 15
Channel Mask: 0x07fff800
-Ext PAN ID: d63e8e3e495ebbc3
-Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
-Network Key: dfd34f0f05cad978ec4e32b0413038ff
-Network Name: OpenThread-8f28
-PAN ID: 0x8f28
-PSKc: c23a76e98f1a6483639b1ac1271e2e27
-Security Policy: 0, onrc
+Ext PAN ID: 39758ec8144b07fb
+Mesh Local Prefix: fdf1:f1ad:d079:7dc0::/64
+Network Key: f366cec7a446bab978d90d27abe38f23
+Network Name: OpenThread-5938
+PAN ID: 0x5938
+PSKc: 3ca67c969efb0d0c74a4d8ee923b576c
+Security Policy: 672 onrc
Done
```
@@ -188,7 +191,7 @@ Print Active Operational Dataset as hex-encoded TLVs.
```bash
> dataset active -x
-0e080000000000010000000300001035060004001fffe002084eb74ab03c56e6d00708fdc7fe165c83a67805108e2104f183e698da87e96efc1e45aa51030f4f70656e5468726561642d383631310102861104108d6273023d82c841eff0e68db86f35740c030000ff
+0e080000000000010000000300000f35060004001fffe0020839758ec8144b07fb0708fdf1f1add0797dc00510f366cec7a446bab978d90d27abe38f23030f4f70656e5468726561642d353933380102593804103ca67c969efb0d0c74a4d8ee923b576c0c0402a0f7f8
Done
```
@@ -431,17 +434,17 @@ Print Pending Operational Dataset in human-readable form.
```bash
> dataset pending
Pending Timestamp: 2
-Active Timestamp: 15
-Channel: 16
+Active Timestamp: 1
+Channel: 26
Channel Mask: 0x07fff800
Delay: 58706
-Ext PAN ID: d63e8e3e495ebbc3
-Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
-Network Key: dfd34f0f05cad978ec4e32b0413038ff
-Network Name: OpenThread-8f28
-PAN ID: 0x8f28
-PSKc: c23a76e98f1a6483639b1ac1271e2e27
-Security Policy: 0, onrc
+Ext PAN ID: a74182f4d3f4de41
+Mesh Local Prefix: fd46:c1b9:e159:5574::/64
+Network Key: ed916e454d96fd00184f10a6f5c9e1d3
+Network Name: OpenThread-bff8
+PAN ID: 0xbff8
+PSKc: 264f78414adc683191863d968f72d1b7
+Security Policy: 672 onrc
Done
```
@@ -449,7 +452,7 @@ Print Pending Operational Dataset as hex-encoded TLVs.
```bash
> dataset pending -x
-0e080000000000010000000300001035060004001fffe002084eb74ab03c56e6d00708fdc7fe165c83a67805108e2104f183e698da87e96efc1e45aa51030f4f70656e5468726561642d383631310102861104108d6273023d82c841eff0e68db86f35740c030000ff
+0e0800000000000100003308000000000002000034040000b512000300001a35060004001fffe00208a74182f4d3f4de410708fd46c1b9e15955740510ed916e454d96fd00184f10a6f5c9e1d3030f4f70656e5468726561642d626666380102bff80410264f78414adc683191863d968f72d1b70c0402a0f7f8
Done
```
@@ -530,13 +533,38 @@ Usage: `dataset set `
Set the Active Operational Dataset using hex-encoded TLVs.
```bash
-dataset set active 0e080000000000010000000300001035060004001fffe002084eb74ab03c56e6d00708fdc7fe165c83a67805108e2104f183e698da87e96efc1e45aa51030f4f70656e5468726561642d383631310102861104108d6273023d82c841eff0e68db86f35740c030000ff
+> dataset set active 0e080000000000010000000300000f35060004001fffe0020839758ec8144b07fb0708fdf1f1add0797dc00510f366cec7a446bab978d90d27abe38f23030f4f70656e5468726561642d353933380102593804103ca67c969efb0d0c74a4d8ee923b576c0c0402a0f7f8
Done
```
Set the Pending Operational Dataset using hex-encoded TLVs.
```bash
-dataset set pending 0e080000000000010000000300001035060004001fffe002084eb74ab03c56e6d00708fdc7fe165c83a67805108e2104f183e698da87e96efc1e45aa51030f4f70656e5468726561642d383631310102861104108d6273023d82c841eff0e68db86f35740c030000ff
+> dataset set pending 0e0800000000000100003308000000000002000034040000b512000300001a35060004001fffe00208a74182f4d3f4de410708fd46c1b9e15955740510ed916e454d96fd00184f10a6f5c9e1d3030f4f70656e5468726561642d626666380102bff80410264f78414adc683191863d968f72d1b70c0402a0f7f8
+Done
+```
+
+### tlvs
+
+Usage: `dataset tlvs`
+
+Convert the Operational Dataset to hex-encoded TLVs.
+
+```bash
+> dataset
+Active Timestamp: 1
+Channel: 22
+Channel Mask: 0x07fff800
+Ext PAN ID: d196fa2040e973b6
+Mesh Local Prefix: fdbb:c310:c48f:3a39::/64
+Network Key: 9929154dbc363218bcd22f907caf5c15
+Network Name: OpenThread-de2b
+PAN ID: 0xde2b
+PSKc: 15b2c16f7ba92ed4bc7b1ee054f1553f
+Security Policy: 672 onrc
+Done
+
+> dataset tlvs
+0e080000000000010000000300001635060004001fffe00208d196fa2040e973b60708fdbbc310c48f3a3905109929154dbc363218bcd22f907caf5c15030f4f70656e5468726561642d646532620102de2b041015b2c16f7ba92ed4bc7b1ee054f1553f0c0402a0f7f8
Done
```
diff --git a/src/cli/README_HISTORY.md b/src/cli/README_HISTORY.md
index e3ea55dc801..268cf7d242d 100644
--- a/src/cli/README_HISTORY.md
+++ b/src/cli/README_HISTORY.md
@@ -17,6 +17,7 @@ Usage : `history [command] ...`
- [netinfo](#netinfo)
- [prefix](#prefix)
- [route](#route)
+- [router](#router)
- [rx](#rx)
- [rxtx](#rxtx)
- [tx](#tx)
@@ -56,6 +57,7 @@ neighbor
netinfo
prefix
route
+router
rx
rxtx
tx
@@ -298,7 +300,7 @@ Print the history as a list.
00:06:01.711 -> event:Added prefix:fd00:dead:beef:1::/64 flags:paros pref:med rloc16:0x8800
```
-### prefix
+### route
Usage `history route [list] []`
@@ -337,6 +339,82 @@ Print the history as a list (last two entries).
Done
```
+### router
+
+Usage `history router [list] []`
+
+Print the route table history. Each item provides:
+
+- Event (`Added`, `Removed`, `NextHopChnaged`, `CostChanged`)
+- Router ID and RLOC16 of router
+- Next Hop (Router ID and RLOC16) - `none` if no next hop.
+- Path cost (old `->` new) - `inf` to indicate infinite path cost.
+
+Print the history as a table.
+
+```bash
+> history router
+| Age | Event | ID (RLOC16) | Next Hop | Path Cost |
++----------------------+----------------+-------------+-------------+------------+
+| 00:00:05.258 | NextHopChanged | 7 (0x1c00) | 34 (0x8800) | inf -> 3 |
+| 00:00:08.604 | NextHopChanged | 34 (0x8800) | 34 (0x8800) | inf -> 2 |
+| 00:00:08.604 | Added | 7 (0x1c00) | none | inf -> inf |
+| 00:00:11.931 | Added | 34 (0x8800) | none | inf -> inf |
+| 00:00:14.948 | Removed | 59 (0xec00) | none | inf -> inf |
+| 00:00:14.948 | Removed | 54 (0xd800) | none | inf -> inf |
+| 00:00:14.948 | Removed | 34 (0x8800) | none | inf -> inf |
+| 00:00:14.948 | Removed | 7 (0x1c00) | none | inf -> inf |
+| 00:00:54.795 | NextHopChanged | 59 (0xec00) | 34 (0x8800) | 1 -> 5 |
+| 00:02:33.735 | NextHopChanged | 54 (0xd800) | none | 15 -> inf |
+| 00:03:10.915 | CostChanged | 54 (0xd800) | 34 (0x8800) | 13 -> 15 |
+| 00:03:45.716 | NextHopChanged | 54 (0xd800) | 34 (0x8800) | 15 -> 13 |
+| 00:03:46.188 | CostChanged | 54 (0xd800) | 59 (0xec00) | 13 -> 15 |
+| 00:04:19.124 | CostChanged | 54 (0xd800) | 59 (0xec00) | 11 -> 13 |
+| 00:04:52.008 | CostChanged | 54 (0xd800) | 59 (0xec00) | 9 -> 11 |
+| 00:05:23.176 | CostChanged | 54 (0xd800) | 59 (0xec00) | 7 -> 9 |
+| 00:05:51.081 | CostChanged | 54 (0xd800) | 59 (0xec00) | 5 -> 7 |
+| 00:06:48.721 | CostChanged | 54 (0xd800) | 59 (0xec00) | 3 -> 5 |
+| 00:07:13.792 | NextHopChanged | 54 (0xd800) | 59 (0xec00) | 1 -> 3 |
+| 00:09:28.681 | NextHopChanged | 7 (0x1c00) | 34 (0x8800) | inf -> 3 |
+| 00:09:31.882 | Added | 7 (0x1c00) | none | inf -> inf |
+| 00:09:51.240 | NextHopChanged | 54 (0xd800) | 54 (0xd800) | inf -> 1 |
+| 00:09:54.204 | Added | 54 (0xd800) | none | inf -> inf |
+| 00:10:20.645 | NextHopChanged | 34 (0x8800) | 34 (0x8800) | inf -> 2 |
+| 00:10:24.242 | NextHopChanged | 59 (0xec00) | 59 (0xec00) | inf -> 1 |
+| 00:10:24.242 | Added | 34 (0x8800) | none | inf -> inf |
+| 00:10:41.900 | NextHopChanged | 59 (0xec00) | none | 1 -> inf |
+| 00:10:42.480 | Added | 3 (0x0c00) | 3 (0x0c00) | inf -> inf |
+| 00:10:43.614 | Added | 59 (0xec00) | 59 (0xec00) | inf -> 1 |
+Done
+```
+
+Print the history as a list (last 20 entries).
+
+```bash
+> history router list 20
+00:00:06.959 -> event:NextHopChanged router:7(0x1c00) nexthop:34(0x8800) old-cost:inf new-cost:3
+00:00:10.305 -> event:NextHopChanged router:34(0x8800) nexthop:34(0x8800) old-cost:inf new-cost:2
+00:00:10.305 -> event:Added router:7(0x1c00) nexthop:none old-cost:inf new-cost:inf
+00:00:13.632 -> event:Added router:34(0x8800) nexthop:none old-cost:inf new-cost:inf
+00:00:16.649 -> event:Removed router:59(0xec00) nexthop:none old-cost:inf new-cost:inf
+00:00:16.649 -> event:Removed router:54(0xd800) nexthop:none old-cost:inf new-cost:inf
+00:00:16.649 -> event:Removed router:34(0x8800) nexthop:none old-cost:inf new-cost:inf
+00:00:16.649 -> event:Removed router:7(0x1c00) nexthop:none old-cost:inf new-cost:inf
+00:00:56.496 -> event:NextHopChanged router:59(0xec00) nexthop:34(0x8800) old-cost:1 new-cost:5
+00:02:35.436 -> event:NextHopChanged router:54(0xd800) nexthop:none old-cost:15 new-cost:inf
+00:03:12.616 -> event:CostChanged router:54(0xd800) nexthop:34(0x8800) old-cost:13 new-cost:15
+00:03:47.417 -> event:NextHopChanged router:54(0xd800) nexthop:34(0x8800) old-cost:15 new-cost:13
+00:03:47.889 -> event:CostChanged router:54(0xd800) nexthop:59(0xec00) old-cost:13 new-cost:15
+00:04:20.825 -> event:CostChanged router:54(0xd800) nexthop:59(0xec00) old-cost:11 new-cost:13
+00:04:53.709 -> event:CostChanged router:54(0xd800) nexthop:59(0xec00) old-cost:9 new-cost:11
+00:05:24.877 -> event:CostChanged router:54(0xd800) nexthop:59(0xec00) old-cost:7 new-cost:9
+00:05:52.782 -> event:CostChanged router:54(0xd800) nexthop:59(0xec00) old-cost:5 new-cost:7
+00:06:50.422 -> event:CostChanged router:54(0xd800) nexthop:59(0xec00) old-cost:3 new-cost:5
+00:07:15.493 -> event:NextHopChanged router:54(0xd800) nexthop:59(0xec00) old-cost:1 new-cost:3
+00:09:30.382 -> event:NextHopChanged router:7(0x1c00) nexthop:34(0x8800) old-cost:inf new-cost:3
+Done
+```
+
### rx
Usage `history rx [list] []`
diff --git a/src/cli/README_NETDATA.md b/src/cli/README_NETDATA.md
index 68c3b43f78e..5fff19f09ea 100644
--- a/src/cli/README_NETDATA.md
+++ b/src/cli/README_NETDATA.md
@@ -142,6 +142,8 @@ After the device successfully attaches to a Thread network, the device will retr
## Command List
- [help](#help)
+- [length](#length)
+- [maxlength](#maxlength)
- [publish](#publish)
- [register](#register)
- [show](#show)
@@ -158,7 +160,8 @@ Print netdata help menu.
```bash
> netdata help
-help
+length
+maxlength
publish
register
show
@@ -167,6 +170,41 @@ unpublish
Done
```
+### length
+
+Usage: `netdata length`
+
+Get the current length of (number of bytes) Partition's Thread Network Data.
+
+```bash
+> netdata length
+23
+Done
+```
+
+### maxlength
+
+Usage: `netdata maxlength`
+
+Get the maximum observed length of the Thread Network Data since OT stack initialization or since the last call to `netdata maxlength reset`.
+
+```bash
+> netdata maxlength
+40
+Done
+```
+
+### maxlength reset
+
+Usage: `netdata maxlength reset`
+
+Reset the tracked maximum length of the Thread Network Data.
+
+```bash
+> netdata maxlength reset
+Done
+```
+
### publish
The Network Data Publisher provides mechanisms to limit the number of similar Service and/or Prefix (on-mesh prefix or external route) entries in the Thread Network Data by monitoring the Network Data and managing if or when to add or remove entries.
@@ -231,6 +269,21 @@ Publish an external route entry.
Done
```
+### publish replace \ \ [sn][prf]
+
+Replace a previously published external route entry.
+
+If there is no previously published external route matching old prefix, this command behaves similarly to `netdata publish route`. If there is a previously published route entry, it will be replaced with the new prefix. In particular, if the old prefix was already added in the Network Data, the change to the new prefix is immediately reflected in the Network Data (i.e., old prefix is removed and the new prefix is added in the same Network Data registration request to leader). This ensures that route entries in the Network Data are not abruptly removed.
+
+- s: Stable flag
+- n: NAT64 flag
+- prf: Preference, which may be: 'high', 'med', or 'low'.
+
+```bash
+> netdata publish replace ::/0 fd00:1234:5678::/64 s high
+Done
+```
+
### register
Usage: `netdata register`
@@ -246,14 +299,61 @@ Done
Usage: `netdata show [local] [-x]`
+Print entries in Network Data, on-mesh prefixes, external routes, services, and 6LoWPAN context information.
+
+On-mesh prefixes are listed under `Prefixes` header:
+
+- The on-mesh prefix
+- Flags
+ - p: Preferred flag
+ - a: Stateless IPv6 Address Autoconfiguration flag
+ - d: DHCPv6 IPv6 Address Configuration flag
+ - c: DHCPv6 Other Configuration flag
+ - r: Default Route flag
+ - o: On Mesh flag
+ - s: Stable flag
+ - n: Nd Dns flag
+ - D: Domain Prefix flag (only available for Thread 1.2).
+- Preference `high`, `med`, or `low`
+- RLOC16 of device which added the on-mesh prefix
+
+External Routes are listed under `Routes` header:
+
+- The route prefix
+- Flags
+ - s: Stable flag
+ - n: NAT64 flag
+- Preference `high`, `med`, or `low`
+- RLOC16 of device which added the route prefix
+
+Service entries are listed under `Services` header:
+
+- Enterprise number
+- Service data (as hex bytes)
+- Server data (as hex bytes)
+- Flags
+ - s: Stable flag
+- RLOC16 of devices which added the service entry
+
+6LoWPAN Context IDs are listed under `Contexts` header:
+
+- The prefix
+- Context ID
+- Compress flag (`c` if marked or `-` otherwise).
+
Print Network Data received from the Leader.
```bash
> netdata show
Prefixes:
-fd00:dead:beef:cafe::/64 paros med dc00
+fd00:dead:beef:cafe::/64 paros med a000
Routes:
+fd00:1234:0:0::/64 s med a000
+fd00:4567:0:0::/64 s med 8000
Services:
+44970 5d fddead00beef00007bad0069ce45948504d2 s a000
+Contexts:
+fd00:dead:beef:cafe::/64 1 c
Done
```
diff --git a/src/cli/README_SRP.md b/src/cli/README_SRP.md
index a0ab5ba81e4..ce2139fb7b1 100644
--- a/src/cli/README_SRP.md
+++ b/src/cli/README_SRP.md
@@ -131,7 +131,10 @@ my-service._ipps._tcp.default.service.arpa.
port: 12345
priority: 0
weight: 0
- TXT: 00
+ ttl: 7200
+ lease: 7200
+ key-lease: 1209600
+ TXT: []
host: my-host.default.service.arpa.
addresses: [fded:5114:8263:1fe1:44f9:cc06:4a2d:534]
Done
diff --git a/src/cli/README_SRP_SERVER.md b/src/cli/README_SRP_SERVER.md
index 05cb9bc7629..ad87182590f 100644
--- a/src/cli/README_SRP_SERVER.md
+++ b/src/cli/README_SRP_SERVER.md
@@ -170,6 +170,8 @@ Usage: `srp server service`
Print information of all registered services.
+The TXT record is displayed as an array of entries. If an entry has a key, the key will be printed in ASCII format. The value portion will always be printed as hex bytes.
+
```bash
> srp server service
srp-api-test-1._ipps._tcp.default.service.arpa.
@@ -178,7 +180,10 @@ srp-api-test-1._ipps._tcp.default.service.arpa.
port: 49152
priority: 0
weight: 0
- TXT: 0130
+ ttl: 7200
+ lease: 7200
+ key-lease: 1209600
+ TXT: [616263, xyz=585960]
host: srp-api-test-1.default.service.arpa.
addresses: [fdde:ad00:beef:0:0:ff:fe00:fc10]
srp-api-test-0._ipps._tcp.default.service.arpa.
@@ -187,7 +192,10 @@ srp-api-test-0._ipps._tcp.default.service.arpa.
port: 49152
priority: 0
weight: 0
- TXT: 0130
+ ttl: 3600
+ lease: 3600
+ key-lease: 1209600
+ TXT: [616263, xyz=585960]
host: srp-api-test-0.default.service.arpa.
addresses: [fdde:ad00:beef:0:0:ff:fe00:fc10]
Done
diff --git a/src/cli/README_TCP.md b/src/cli/README_TCP.md
index c1aba71d05c..3869570b814 100644
--- a/src/cli/README_TCP.md
+++ b/src/cli/README_TCP.md
@@ -109,7 +109,7 @@ Establishes a connection with the specified peer.
If the connection establishment is successful, the resulting TCP connection is associated with the example TCP endpoint.
-- ip: the peer's IPv6 address.
+- ip: the peer's IP address.
- port: the peer's TCP port.
```bash
@@ -118,6 +118,16 @@ Done
TCP: Connection established
```
+The address can be an IPv4 address, which will be synthesized to an IPv6 address using the preferred NAT64 prefix from the network data.
+
+> Note: The command will return `InvalidState` when the preferred NAT64 prefix is unavailable.
+
+```bash
+> tcp connect 172.17.0.1 1234
+Connecting to synthesized IPv6 address: fdde:ad00:beef:2:0:0:ac11:1
+Done
+```
+
### deinit
Deinitializes the example TCP listener and the example TCP endpoint.
@@ -147,14 +157,19 @@ stoplistening
Done
```
-### init [\]
+### init [\] [\]
Initializes the example TCP listener and the example TCP endpoint.
+- mode: this specifies the buffering strategy and whether to use TLS. The possible values are "linked", "circular" (default), and "tls".
- size: the size of the receive buffer to associate with the example TCP endpoint. If left unspecified, the maximum size is used.
+If "tls" is used, then the TLS protocol will be used for the connection (on top of TCP). When communicating over TCP between two nodes, either both should use TLS or neither should (a non-TLS endpoint cannot communicate with a TLS endpoint). The first two options, "linked" and "circular", specify that TLS should not be used and specify a buffering strategy to use with TCP; two endpoints of a TCP connection may use different buffering strategies.
+
+The behaviors of "linked" and "circular" buffering are identical, but the option is provided so that users of TCP can inspect the code to see an example of using the two buffering strategies.
+
```bash
-> tcp init
+> tcp init tls
Done
```
diff --git a/src/cli/README_UDP.md b/src/cli/README_UDP.md
index 51cd8cc5b1f..14444cdaf14 100644
--- a/src/cli/README_UDP.md
+++ b/src/cli/README_UDP.md
@@ -96,7 +96,7 @@ Done
Specifies the peer with which the socket is to be associated.
-- ip: the peer's IPv6 address.
+- ip: the peer's IP address.
- port: the peer's UDP port.
```bash
@@ -104,6 +104,16 @@ Specifies the peer with which the socket is to be associated.
Done
```
+The address can be an IPv4 address, which will be synthesized to an IPv6 address using the preferred NAT64 prefix from the network data.
+
+> Note: The command will return `InvalidState` when the preferred NAT64 prefix is unavailable.
+
+```bash
+> udp connect 172.17.0.1 1234
+Connecting to synthesized IPv6 address: fdde:ad00:beef:2:0:0:ac11:1
+Done
+```
+
### linksecurity
Indicates whether the link security is enabled or disabled.
@@ -145,7 +155,7 @@ Done
Send a UDP message.
-- ip: the IPv6 destination address.
+- ip: the destination address.
- port: the UDP destination port.
- message: the message to send.
@@ -154,6 +164,16 @@ Send a UDP message.
Done
```
+The address can be an IPv4 address, which will be synthesized to an IPv6 address using the preferred NAT64 prefix from the network data.
+
+> Note: The command will return `InvalidState` when the preferred NAT64 prefix is unavailable.
+
+```bash
+> udp send 172.17.0.1 1234
+Sending to synthesized IPv6 address: fdde:ad00:beef:2:0:0:ac11:1
+Done
+```
+
### send \ \ \ \
Send a few bytes over UDP.
diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp
index 71785276b56..6d1102358e2 100644
--- a/src/cli/cli.cpp
+++ b/src/cli/cli.cpp
@@ -37,6 +37,7 @@
#include
#include
+#include
#include
#include
#include
@@ -44,6 +45,7 @@
#include
#include
#include
+#include "common/num_utils.hpp"
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
#include
#endif
@@ -57,9 +59,6 @@
#if OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE
#include
#endif
-#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
-#include
-#endif
#if OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE
#include
#endif
@@ -84,6 +83,9 @@
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
#include
#endif
+#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE || OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
+#include
+#endif
#include "common/new.hpp"
#include "common/string.hpp"
@@ -96,50 +98,56 @@ Interpreter *Interpreter::sInterpreter = nullptr;
static OT_DEFINE_ALIGNED_VAR(sInterpreterRaw, sizeof(Interpreter), uint64_t);
Interpreter::Interpreter(Instance *aInstance, otCliOutputCallback aCallback, void *aContext)
- : Output(aInstance, aCallback, aContext)
- , mUserCommands(nullptr)
- , mUserCommandsLength(0)
+ : OutputImplementer(aCallback, aContext)
+ , Output(aInstance, *this)
, mCommandIsPending(false)
, mTimer(*aInstance, HandleTimer, this)
#if OPENTHREAD_FTD || OPENTHREAD_MTD
#if OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE
, mSntpQueryingInProgress(false)
#endif
- , mDataset(*this)
- , mNetworkData(*this)
- , mUdp(*this)
+ , mDataset(aInstance, *this)
+ , mNetworkData(aInstance, *this)
+ , mUdp(aInstance, *this)
+#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
+ , mBr(aInstance, *this)
+#endif
#if OPENTHREAD_CONFIG_TCP_ENABLE && OPENTHREAD_CONFIG_CLI_TCP_ENABLE
- , mTcp(*this)
+ , mTcp(aInstance, *this)
#endif
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
- , mCoap(*this)
+ , mCoap(aInstance, *this)
#endif
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
- , mCoapSecure(*this)
+ , mCoapSecure(aInstance, *this)
#endif
#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD
- , mCommissioner(*this)
+ , mCommissioner(aInstance, *this)
#endif
#if OPENTHREAD_CONFIG_JOINER_ENABLE
- , mJoiner(*this)
+ , mJoiner(aInstance, *this)
#endif
#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
- , mSrpClient(*this)
+ , mSrpClient(aInstance, *this)
#endif
#if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
- , mSrpServer(*this)
+ , mSrpServer(aInstance, *this)
#endif
#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE
- , mHistory(*this)
+ , mHistory(aInstance, *this)
#endif
#if OPENTHREAD_CONFIG_TMF_ANYCAST_LOCATOR_ENABLE
, mLocateInProgress(false)
#endif
+#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
+ , mLinkMetricsQueryInProgress(false)
+#endif
#endif // OPENTHREAD_FTD || OPENTHREAD_MTD
{
-#if OPENTHREAD_FTD
- otThreadSetDiscoveryRequestCallback(GetInstancePtr(), &Interpreter::HandleDiscoveryRequest, this);
+#if (OPENTHREAD_FTD || OPENTHREAD_MTD) && OPENTHREAD_CONFIG_CLI_REGISTER_IP6_RECV_CALLBACK
+ otIp6SetReceiveCallback(GetInstancePtr(), &Interpreter::HandleIp6Receive, this);
#endif
+ memset(&mUserCommands, 0, sizeof(mUserCommands));
OutputPrompt();
}
@@ -156,7 +164,7 @@ void Interpreter::OutputResult(otError aError)
}
else
{
- OutputLine("Error %d: %s", aError, otThreadErrorToString(aError));
+ OutputLine("Error %u: %s", aError, otThreadErrorToString(aError));
}
mCommandIsPending = false;
@@ -200,7 +208,7 @@ const char *Interpreter::LinkModeToString(const otLinkModeConfig &aLinkMode, cha
template <> otError Interpreter::Process(Arg aArgs[])
{
otError error;
- char * args[kMaxArgs];
+ char *args[kMaxArgs];
char output[OPENTHREAD_CONFIG_DIAG_OUTPUT_BUFFER_SIZE];
// all diagnostics related features are processed within diagnostics module
@@ -224,7 +232,7 @@ template <> otError Interpreter::Process(Arg aArgs[])
}
else if (aArgs[0] == "api")
{
- OutputLine("%d", OPENTHREAD_API_VERSION);
+ OutputLine("%u", OPENTHREAD_API_VERSION);
}
else
{
@@ -286,27 +294,42 @@ otError Interpreter::ProcessUserCommands(Arg aArgs[])
{
otError error = OT_ERROR_INVALID_COMMAND;
- for (uint8_t i = 0; i < mUserCommandsLength; i++)
+ for (const UserCommandsEntry &entry : mUserCommands)
{
- if (aArgs[0] == mUserCommands[i].mName)
+ for (uint8_t i = 0; i < entry.mLength; i++)
{
- char *args[kMaxArgs];
+ if (aArgs[0] == entry.mCommands[i].mName)
+ {
+ char *args[kMaxArgs];
- Arg::CopyArgsToStringArray(aArgs, args);
- mUserCommands[i].mCommand(mUserCommandsContext, Arg::GetArgsLength(aArgs) - 1, args + 1);
- error = OT_ERROR_NONE;
- break;
+ Arg::CopyArgsToStringArray(aArgs, args);
+ error = entry.mCommands[i].mCommand(entry.mContext, Arg::GetArgsLength(aArgs) - 1, args + 1);
+ break;
+ }
}
}
return error;
}
-void Interpreter::SetUserCommands(const otCliCommand *aCommands, uint8_t aLength, void *aContext)
+otError Interpreter::SetUserCommands(const otCliCommand *aCommands, uint8_t aLength, void *aContext)
{
- mUserCommands = aCommands;
- mUserCommandsLength = aLength;
- mUserCommandsContext = aContext;
+ otError error = OT_ERROR_FAILED;
+
+ for (UserCommandsEntry &entry : mUserCommands)
+ {
+ if (entry.mCommands == nullptr)
+ {
+ entry.mCommands = aCommands;
+ entry.mLength = aLength;
+ entry.mContext = aContext;
+
+ error = OT_ERROR_NONE;
+ break;
+ }
+ }
+
+ return error;
}
#if OPENTHREAD_FTD || OPENTHREAD_MTD
@@ -333,7 +356,7 @@ otError Interpreter::ParseEnableOrDisable(const Arg &aArg, bool &aEnable)
otError Interpreter::ParseJoinerDiscerner(Arg &aArg, otJoinerDiscerner &aDiscerner)
{
otError error;
- char * separator;
+ char *separator;
VerifyOrExit(!aArg.IsEmpty(), error = OT_ERROR_INVALID_ARGS);
@@ -355,7 +378,7 @@ otError Interpreter::ParseJoinerDiscerner(Arg &aArg, otJoinerDiscerner &aDiscern
otError Interpreter::ParsePingInterval(const Arg &aArg, uint32_t &aInterval)
{
otError error = OT_ERROR_NONE;
- const char * string = aArg.GetCString();
+ const char *string = aArg.GetCString();
const uint32_t msFactor = 1000;
uint32_t factor = msFactor;
@@ -450,11 +473,33 @@ const char *Interpreter::PreferenceToString(signed int aPreference)
return str;
}
-#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE
-template <> otError Interpreter::Process(Arg aArgs[])
+otError Interpreter::ParseToIp6Address(otInstance *aInstance,
+ const Arg &aArg,
+ otIp6Address &aAddress,
+ bool &aSynthesized)
{
- return mHistory.Process(aArgs);
+ Error error = kErrorNone;
+
+ VerifyOrExit(!aArg.IsEmpty(), error = OT_ERROR_INVALID_ARGS);
+ error = aArg.ParseAsIp6Address(aAddress);
+ aSynthesized = false;
+ if (error != kErrorNone)
+ {
+ // It might be an IPv4 address, let's have a try.
+ otIp4Address ip4Address;
+
+ // Do not touch the error value if we failed to parse it as an IPv4 address.
+ SuccessOrExit(aArg.ParseAsIp4Address(ip4Address));
+ SuccessOrExit(error = otNat64SynthesizeIp6Address(aInstance, &ip4Address, &aAddress));
+ aSynthesized = true;
+ }
+
+exit:
+ return error;
}
+
+#if OPENTHREAD_CONFIG_HISTORY_TRACKER_ENABLE
+template <> otError Interpreter::Process(Arg aArgs[]) { return mHistory.Process(aArgs); }
#endif
#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
@@ -510,181 +555,304 @@ template <> otError Interpreter::Process(Arg aArgs[])
#endif // OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
-template <> otError Interpreter::Process(Arg aArgs[])
+template <> otError Interpreter::Process(Arg aArgs[]) { return mBr.Process(aArgs); }
+#endif
+
+#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE || OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
+template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
bool enable;
- /**
- * @cli br (enable,disable)
- * @code
- * br enable
- * Done
- * @endcode
- * @code
- * br disable
- * Done
- * @endcode
- * @par api_copy
- * #otBorderRoutingSetEnabled
- */
- if (ParseEnableOrDisable(aArgs[0], enable) == OT_ERROR_NONE)
+ if (aArgs[0].IsEmpty())
{
- SuccessOrExit(error = otBorderRoutingSetEnabled(GetInstancePtr(), enable));
+ ExitNow(error = OT_ERROR_INVALID_COMMAND);
}
/**
- * @cli br omrprefix
+ * @cli nat64 (enable,disable)
* @code
- * br omrprefix
- * fdfc:1ff5:1512:5622::/64
+ * nat64 enable
* Done
* @endcode
- * @par api_copy
- * #otBorderRoutingGetOmrPrefix
- */
- else if (aArgs[0] == "omrprefix")
- {
- otIp6Prefix omrPrefix;
-
- SuccessOrExit(error = otBorderRoutingGetOmrPrefix(GetInstancePtr(), &omrPrefix));
- OutputIp6PrefixLine(omrPrefix);
- }
- /**
- * @cli br favoredomrprefix
* @code
- * br favoredomrprefix
- * fdfc:1ff5:1512:5622::/64 prf:low
+ * nat64 disable
* Done
* @endcode
+ * @cparam nat64 @ca{enable|disable}
* @par api_copy
- * #otBorderRoutingGetFavoredOmrPrefix
+ * #otNat64SetEnabled
+ *
*/
- else if (aArgs[0] == "favoredomrprefix")
+ if (ParseEnableOrDisable(aArgs[0], enable) == OT_ERROR_NONE)
{
- otIp6Prefix prefix;
- otRoutePreference preference;
-
- SuccessOrExit(error = otBorderRoutingGetFavoredOmrPrefix(GetInstancePtr(), &prefix, &preference));
- OutputIp6Prefix(prefix);
- OutputLine(" prf:%s", PreferenceToString(preference));
+ otNat64SetEnabled(GetInstancePtr(), enable);
}
/**
- * @cli br onlinkprefix
+ * @cli nat64 state
* @code
- * br onlinkprefix
- * fd41:2650:a6f5:0::/64
+ * nat64 state
+ * PrefixManager: Active
+ * Translator: Active
* Done
* @endcode
- * @par api_copy
- * #otBorderRoutingGetOnLinkPrefix
+ * @par
+ * Gets the state of NAT64 functions.
+ * @par
+ * `PrefixManager` state is available when `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is enabled.
+ * `Translator` state is available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
+ * @par
+ * When `OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE` is enabled, `PrefixManager` returns one of the following
+ * states:
+ * - `Disabled`: NAT64 prefix manager is disabled.
+ * - `NotRunning`: NAT64 prefix manager is enabled, but is not running. This could mean that the routing manager is
+ * disabled.
+ * - `Idle`: NAT64 prefix manager is enabled and is running, but is not publishing a NAT64 prefix. This can happen
+ * when there is another border router publishing a NAT64 prefix with a higher priority.
+ * - `Active`: NAT64 prefix manager is enabled, running, and publishing a NAT64 prefix.
+ * @par
+ * When `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled, `Translator` returns one of the following states:
+ * - `Disabled`: NAT64 translator is disabled.
+ * - `NotRunning`: NAT64 translator is enabled, but is not translating packets. This could mean that the Translator
+ * is not configured with a NAT64 prefix or a CIDR for NAT64.
+ * - `Active`: NAT64 translator is enabled and is translating packets.
+ * @sa otNat64GetPrefixManagerState
+ * @sa otNat64GetTranslatorState
+ *
*/
- else if (aArgs[0] == "onlinkprefix")
+ else if (aArgs[0] == "state")
{
- otIp6Prefix onLinkPrefix;
+ static const char *const kNat64State[] = {"Disabled", "NotRunning", "Idle", "Active"};
- SuccessOrExit(error = otBorderRoutingGetOnLinkPrefix(GetInstancePtr(), &onLinkPrefix));
- OutputIp6PrefixLine(onLinkPrefix);
+ static_assert(0 == OT_NAT64_STATE_DISABLED, "OT_NAT64_STATE_DISABLED value is incorrect");
+ static_assert(1 == OT_NAT64_STATE_NOT_RUNNING, "OT_NAT64_STATE_NOT_RUNNING value is incorrect");
+ static_assert(2 == OT_NAT64_STATE_IDLE, "OT_NAT64_STATE_IDLE value is incorrect");
+ static_assert(3 == OT_NAT64_STATE_ACTIVE, "OT_NAT64_STATE_ACTIVE value is incorrect");
+
+#if OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
+ OutputLine("PrefixManager: %s", kNat64State[otNat64GetPrefixManagerState(GetInstancePtr())]);
+#endif
+#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE
+ OutputLine("Translator: %s", kNat64State[otNat64GetTranslatorState(GetInstancePtr())]);
+#endif
}
-#if OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE
+#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE
/**
- * @cli br nat64prefix
+ * @cli nat64 cidr
* @code
- * br nat64prefix
- * fd14:1078:b3d5:b0b0:0:0::/96
+ * nat64 cidr
+ * 192.168.255.0/24
* Done
* @endcode
* @par api_copy
- * #otBorderRoutingGetNat64Prefix
+ * #otNat64GetCidr
+ *
*/
- else if (aArgs[0] == "nat64prefix")
+ else if (aArgs[0] == "cidr")
{
- otIp6Prefix nat64Prefix;
+ otIp4Cidr cidr;
+ char cidrString[OT_IP4_CIDR_STRING_SIZE];
- SuccessOrExit(error = otBorderRoutingGetNat64Prefix(GetInstancePtr(), &nat64Prefix));
- OutputIp6PrefixLine(nat64Prefix);
+ SuccessOrExit(error = otNat64GetCidr(GetInstancePtr(), &cidr));
+ otIp4CidrToString(&cidr, cidrString, sizeof(cidrString));
+ OutputLine("%s", cidrString);
}
-#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE
/**
- * @cli br rioprf (high,med,low)
- * @code
- * br rioprf
- * med
- * Done
- * @endcode
+ * @cli nat64 mappings
* @code
- * br rioprf low
- * Done
+ * nat64 mappings
+ * | | Address | | 4 to 6 | 6 to 4 |
+ * +----------+---------------------------+--------+--------------+--------------+
+ * | ID | IPv6 | IPv4 | Expiry | Pkts | Bytes | Pkts | Bytes |
+ * +----------+------------+--------------+--------+------+-------+------+-------+
+ * | 00021cb9 | fdc7::df79 | 192.168.64.2 | 7196s | 6 | 456 | 11 | 1928 |
+ * | | TCP | 0 | 0 | 0 | 0 |
+ * | | UDP | 1 | 136 | 16 | 1608 |
+ * | | ICMP | 5 | 320 | 5 | 320 |
* @endcode
- * @cparam br rioprf [@ca{high}|@ca{med}|@ca{low}]
* @par api_copy
- * #otBorderRoutingSetRouteInfoOptionPreference
+ * #otNat64GetNextAddressMapping
*
*/
- else if (aArgs[0] == "rioprf")
+ else if (aArgs[0] == "mappings")
{
- if (aArgs[1].IsEmpty())
- {
- OutputLine("%s", PreferenceToString(otBorderRoutingGetRouteInfoOptionPreference(GetInstancePtr())));
- }
- else
- {
- otRoutePreference preference;
+ otNat64AddressMappingIterator iterator;
+ otNat64AddressMapping mapping;
+
+ static const char *const kNat64StatusLevel1Title[] = {"", "Address", "", "4 to 6", "6 to 4"};
- SuccessOrExit(error = ParsePreference(aArgs[1], preference));
- otBorderRoutingSetRouteInfoOptionPreference(GetInstancePtr(), preference);
+ static const uint8_t kNat64StatusLevel1ColumnWidths[] = {
+ 18, 61, 8, 25, 25,
+ };
+
+ static const char *const kNat64StatusTableHeader[] = {
+ "ID", "IPv6", "IPv4", "Expiry", "Pkts", "Bytes", "Pkts", "Bytes",
+ };
+
+ static const uint8_t kNat64StatusTableColumnWidths[] = {
+ 18, 42, 18, 8, 10, 14, 10, 14,
+ };
+
+ OutputTableHeader(kNat64StatusLevel1Title, kNat64StatusLevel1ColumnWidths);
+ OutputTableHeader(kNat64StatusTableHeader, kNat64StatusTableColumnWidths);
+
+ otNat64InitAddressMappingIterator(GetInstancePtr(), &iterator);
+ while (otNat64GetNextAddressMapping(GetInstancePtr(), &iterator, &mapping) == OT_ERROR_NONE)
+ {
+ char ip4AddressString[OT_IP4_ADDRESS_STRING_SIZE];
+ char ip6AddressString[OT_IP6_PREFIX_STRING_SIZE];
+ Uint64StringBuffer u64StringBuffer;
+
+ otIp6AddressToString(&mapping.mIp6, ip6AddressString, sizeof(ip6AddressString));
+ otIp4AddressToString(&mapping.mIp4, ip4AddressString, sizeof(ip4AddressString));
+
+ OutputFormat("| %08lx%08lx ", ToUlong(static_cast(mapping.mId >> 32)),
+ ToUlong(static_cast(mapping.mId & 0xffffffff)));
+ OutputFormat("| %40s ", ip6AddressString);
+ OutputFormat("| %16s ", ip4AddressString);
+ OutputFormat("| %5lus ", ToUlong(mapping.mRemainingTimeMs / 1000));
+ OutputFormat("| %8s ", Uint64ToString(mapping.mCounters.mTotal.m4To6Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(mapping.mCounters.mTotal.m4To6Bytes, u64StringBuffer));
+ OutputFormat("| %8s ", Uint64ToString(mapping.mCounters.mTotal.m6To4Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(mapping.mCounters.mTotal.m6To4Bytes, u64StringBuffer));
+
+ OutputLine("|");
+
+ OutputFormat("| %16s ", "");
+ OutputFormat("| %68s ", "TCP");
+ OutputFormat("| %8s ", Uint64ToString(mapping.mCounters.mTcp.m4To6Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(mapping.mCounters.mTcp.m4To6Bytes, u64StringBuffer));
+ OutputFormat("| %8s ", Uint64ToString(mapping.mCounters.mTcp.m6To4Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(mapping.mCounters.mTcp.m6To4Bytes, u64StringBuffer));
+ OutputLine("|");
+
+ OutputFormat("| %16s ", "");
+ OutputFormat("| %68s ", "UDP");
+ OutputFormat("| %8s ", Uint64ToString(mapping.mCounters.mUdp.m4To6Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(mapping.mCounters.mUdp.m4To6Bytes, u64StringBuffer));
+ OutputFormat("| %8s ", Uint64ToString(mapping.mCounters.mUdp.m6To4Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(mapping.mCounters.mUdp.m6To4Bytes, u64StringBuffer));
+ OutputLine("|");
+
+ OutputFormat("| %16s ", "");
+ OutputFormat("| %68s ", "ICMP");
+ OutputFormat("| %8s ", Uint64ToString(mapping.mCounters.mIcmp.m4To6Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(mapping.mCounters.mIcmp.m4To6Bytes, u64StringBuffer));
+ OutputFormat("| %8s ", Uint64ToString(mapping.mCounters.mIcmp.m6To4Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(mapping.mCounters.mIcmp.m6To4Bytes, u64StringBuffer));
+ OutputLine("|");
}
}
/**
- * @cli br prefixtable
+ * @cli nat64 counters
* @code
- * br prefixtable
- * prefix:fd00:1234:5678:0::/64, on-link:no, ms-since-rx:29526, lifetime:1800, route-prf:med,
- * router:ff02:0:0:0:0:0:0:1
- * prefix:1200:abba:baba:0::/64, on-link:yes, ms-since-rx:29527, lifetime:1800, preferred:1800,
- * router:ff02:0:0:0:0:0:0:1
+ * nat64 counters
+ * | | 4 to 6 | 6 to 4 |
+ * +---------------+-------------------------+-------------------------+
+ * | Protocol | Pkts | Bytes | Pkts | Bytes |
+ * +---------------+----------+--------------+----------+--------------+
+ * | Total | 11 | 704 | 11 | 704 |
+ * | TCP | 0 | 0 | 0 | 0 |
+ * | UDP | 0 | 0 | 0 | 0 |
+ * | ICMP | 11 | 704 | 11 | 704 |
+ * | Errors | Pkts | Pkts |
+ * +---------------+-------------------------+-------------------------+
+ * | Total | 8 | 4 |
+ * | Illegal Pkt | 0 | 0 |
+ * | Unsup Proto | 0 | 0 |
+ * | No Mapping | 2 | 0 |
* Done
* @endcode
- * @par api_copy
- * #otBorderRoutingGetNextPrefixTableEntry
+ * @par
+ * Gets the NAT64 translator packet and error counters.
+ * @par
+ * Available when `OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE` is enabled.
+ * @sa otNat64GetCounters
+ * @sa otNat64GetErrorCounters
*
*/
- else if (aArgs[0] == "prefixtable")
+ else if (aArgs[0] == "counters")
{
- otBorderRoutingPrefixTableIterator iterator;
- otBorderRoutingPrefixTableEntry entry;
+ static const char *const kNat64CounterTableHeader[] = {
+ "",
+ "4 to 6",
+ "6 to 4",
+ };
+ static const uint8_t kNat64CounterTableHeaderColumns[] = {15, 25, 25};
+ static const char *const kNat64CounterTableSubHeader[] = {
+ "Protocol", "Pkts", "Bytes", "Pkts", "Bytes",
+ };
+ static const uint8_t kNat64CounterTableSubHeaderColumns[] = {
+ 15, 10, 14, 10, 14,
+ };
+ static const char *const kNat64CounterTableErrorSubHeader[] = {
+ "Errors",
+ "Pkts",
+ "Pkts",
+ };
+ static const uint8_t kNat64CounterTableErrorSubHeaderColumns[] = {
+ 15,
+ 25,
+ 25,
+ };
+ static const char *const kNat64CounterErrorType[] = {
+ "Unknown",
+ "Illegal Pkt",
+ "Unsup Proto",
+ "No Mapping",
+ };
- otBorderRoutingPrefixTableInitIterator(GetInstancePtr(), &iterator);
+ otNat64ProtocolCounters counters;
+ otNat64ErrorCounters errorCounters;
+ Uint64StringBuffer u64StringBuffer;
- while (otBorderRoutingGetNextPrefixTableEntry(GetInstancePtr(), &iterator, &entry) == OT_ERROR_NONE)
- {
- char string[OT_IP6_PREFIX_STRING_SIZE];
+ OutputTableHeader(kNat64CounterTableHeader, kNat64CounterTableHeaderColumns);
+ OutputTableHeader(kNat64CounterTableSubHeader, kNat64CounterTableSubHeaderColumns);
- otIp6PrefixToString(&entry.mPrefix, string, sizeof(string));
- OutputFormat("prefix:%s, on-link:%s, ms-since-rx:%u, lifetime:%u, ", string, entry.mIsOnLink ? "yes" : "no",
- entry.mMsecSinceLastUpdate, entry.mValidLifetime);
+ otNat64GetCounters(GetInstancePtr(), &counters);
+ otNat64GetErrorCounters(GetInstancePtr(), &errorCounters);
- if (entry.mIsOnLink)
- {
- OutputFormat("preferred:%u, ", entry.mPreferredLifetime);
- }
- else
- {
- OutputFormat("route-prf:%s, ", PreferenceToString(entry.mRoutePreference));
- }
+ OutputFormat("| %13s ", "Total");
+ OutputFormat("| %8s ", Uint64ToString(counters.mTotal.m4To6Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(counters.mTotal.m4To6Bytes, u64StringBuffer));
+ OutputFormat("| %8s ", Uint64ToString(counters.mTotal.m6To4Packets, u64StringBuffer));
+ OutputLine("| %12s |", Uint64ToString(counters.mTotal.m6To4Bytes, u64StringBuffer));
+
+ OutputFormat("| %13s ", "TCP");
+ OutputFormat("| %8s ", Uint64ToString(counters.mTcp.m4To6Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(counters.mTcp.m4To6Bytes, u64StringBuffer));
+ OutputFormat("| %8s ", Uint64ToString(counters.mTcp.m6To4Packets, u64StringBuffer));
+ OutputLine("| %12s |", Uint64ToString(counters.mTcp.m6To4Bytes, u64StringBuffer));
+
+ OutputFormat("| %13s ", "UDP");
+ OutputFormat("| %8s ", Uint64ToString(counters.mUdp.m4To6Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(counters.mUdp.m4To6Bytes, u64StringBuffer));
+ OutputFormat("| %8s ", Uint64ToString(counters.mUdp.m6To4Packets, u64StringBuffer));
+ OutputLine("| %12s |", Uint64ToString(counters.mUdp.m6To4Bytes, u64StringBuffer));
+
+ OutputFormat("| %13s ", "ICMP");
+ OutputFormat("| %8s ", Uint64ToString(counters.mIcmp.m4To6Packets, u64StringBuffer));
+ OutputFormat("| %12s ", Uint64ToString(counters.mIcmp.m4To6Bytes, u64StringBuffer));
+ OutputFormat("| %8s ", Uint64ToString(counters.mIcmp.m6To4Packets, u64StringBuffer));
+ OutputLine("| %12s |", Uint64ToString(counters.mIcmp.m6To4Bytes, u64StringBuffer));
- otIp6AddressToString(&entry.mRouterAddress, string, sizeof(string));
- OutputLine("router:%s", string);
+ OutputTableHeader(kNat64CounterTableErrorSubHeader, kNat64CounterTableErrorSubHeaderColumns);
+ for (uint8_t i = 0; i < OT_NAT64_DROP_REASON_COUNT; i++)
+ {
+ OutputFormat("| %13s | %23s ", kNat64CounterErrorType[i],
+ Uint64ToString(errorCounters.mCount4To6[i], u64StringBuffer));
+ OutputLine("| %23s |", Uint64ToString(errorCounters.mCount6To4[i], u64StringBuffer));
}
}
+#endif // OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE
else
{
- error = OT_ERROR_INVALID_COMMAND;
+ ExitNow(error = OT_ERROR_INVALID_COMMAND);
}
exit:
return error;
}
-#endif // OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
+#endif // OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE || OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
#if (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
template <> otError Interpreter::Process(Arg aArgs[])
@@ -692,15 +860,34 @@ template <> otError Interpreter::Process(Arg aArgs[])
otError error = OT_ERROR_INVALID_COMMAND;
otBackboneRouterConfig config;
+ /**
+ * @cli bbr
+ * @code
+ * bbr
+ * BBR Primary:
+ * server16: 0xE400
+ * seqno: 10
+ * delay: 120 secs
+ * timeout: 300 secs
+ * Done
+ * @endcode
+ * @code
+ * bbr
+ * BBR Primary: None
+ * Done
+ * @endcode
+ * @par
+ * Returns the current Primary Backbone Router information for the Thread device.
+ */
if (aArgs[0].IsEmpty())
{
if (otBackboneRouterGetPrimary(GetInstancePtr(), &config) == OT_ERROR_NONE)
{
OutputLine("BBR Primary:");
OutputLine("server16: 0x%04X", config.mServer16);
- OutputLine("seqno: %d", config.mSequenceNumber);
- OutputLine("delay: %d secs", config.mReregistrationDelay);
- OutputLine("timeout: %d secs", config.mMlrTimeout);
+ OutputLine("seqno: %u", config.mSequenceNumber);
+ OutputLine("delay: %u secs", config.mReregistrationDelay);
+ OutputLine("timeout: %lu secs", ToUlong(config.mMlrTimeout));
}
else
{
@@ -719,6 +906,34 @@ template <> otError Interpreter::Process(Arg aArgs[])
ExitNow(error = OT_ERROR_INVALID_COMMAND);
}
#if OPENTHREAD_CONFIG_BACKBONE_ROUTER_DUA_NDPROXYING_ENABLE && OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
+ /**
+ * @cli bbr mgmt dua
+ * @code
+ * bbr mgmt dua 1 2f7c235e5025a2fd
+ * Done
+ * @endcode
+ * @code
+ * bbr mgmt dua 160
+ * Done
+ * @endcode
+ * @cparam bbr mgmt dua @ca{status|coap-code} [@ca{meshLocalIid}]
+ * For `status` or `coap-code`, use:
+ * * 0: ST_DUA_SUCCESS
+ * * 1: ST_DUA_REREGISTER
+ * * 2: ST_DUA_INVALID
+ * * 3: ST_DUA_DUPLICATE
+ * * 4: ST_DUA_NO_RESOURCES
+ * * 5: ST_DUA_BBR_NOT_PRIMARY
+ * * 6: ST_DUA_GENERAL_FAILURE
+ * * 160: COAP code 5.00
+ * @par
+ * With the `meshLocalIid` included, this command configures the response status
+ * for the next DUA registration. Without `meshLocalIid`, respond to the next
+ * DUA.req with the specified `status` or `coap-code`.
+ * @par
+ * Available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled.
+ * @sa otBackboneRouterConfigNextDuaRegistrationResponse
+ */
else if (aArgs[1] == "dua")
{
uint8_t status;
@@ -761,6 +976,22 @@ otError Interpreter::ProcessBackboneRouterMgmtMlr(Arg aArgs[])
{
otError error = OT_ERROR_INVALID_COMMAND;
+ /**
+ * @cli bbr mgmt mlr listener
+ * @code
+ * bbr mgmt mlr listener
+ * ff04:0:0:0:0:0:0:abcd 3534000
+ * ff04:0:0:0:0:0:0:eeee 3537610
+ * Done
+ * @endcode
+ * @par
+ * Returns the Multicast Listeners with the #otBackboneRouterMulticastListenerInfo
+ * `mTimeout` in seconds.
+ * @par
+ * Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` and
+ * `OPENTHREAD_CONFIG_BACKBONE_ROUTER_MULTICAST_ROUTING_ENABLE` are enabled.
+ * @sa otBackboneRouterMulticastListenerGetNext
+ */
if (aArgs[0] == "listener")
{
if (aArgs[1].IsEmpty())
@@ -770,11 +1001,34 @@ otError Interpreter::ProcessBackboneRouterMgmtMlr(Arg aArgs[])
}
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
+ /**
+ * @cli bbr mgmt mlr listener clear
+ * @code
+ * bbr mgmt mlr listener clear
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otBackboneRouterMulticastListenerClear
+ */
if (aArgs[1] == "clear")
{
otBackboneRouterMulticastListenerClear(GetInstancePtr());
error = OT_ERROR_NONE;
}
+ /**
+ * @cli bbr mgmt mlr listener add
+ * @code
+ * bbr mgmt mlr listener add ff04::1
+ * Done
+ * @endcode
+ * @code
+ * bbr mgmt mlr listener add ff04::2 300
+ * Done
+ * @endcode
+ * @cparam bbr mgmt mlr listener add @ca{ipaddress} [@ca{timeout-seconds}]
+ * @par api_copy
+ * #otBackboneRouterMulticastListenerAdd
+ */
else if (aArgs[1] == "add")
{
otIp6Address address;
@@ -791,6 +1045,23 @@ otError Interpreter::ProcessBackboneRouterMgmtMlr(Arg aArgs[])
error = otBackboneRouterMulticastListenerAdd(GetInstancePtr(), &address, timeout);
}
}
+ /**
+ * @cli bbr mgmt mlr response
+ * @code
+ * bbr mgmt mlr response 2
+ * Done
+ * @endcode
+ * @cparam bbr mgmt mlr response @ca{status-code}
+ * For `status-code`, use:
+ * * 0: ST_MLR_SUCCESS
+ * * 2: ST_MLR_INVALID
+ * * 3: ST_MLR_NO_PERSISTENT
+ * * 4: ST_MLR_NO_RESOURCES
+ * * 5: ST_MLR_BBR_NOT_PRIMARY
+ * * 6: ST_MLR_GENERAL_FAILURE
+ * @par api_copy
+ * #otBackboneRouterConfigNextMulticastListenerRegistrationResponse
+ */
else if (aArgs[0] == "response")
{
error = ProcessSet(aArgs + 1, otBackboneRouterConfigNextMulticastListenerRegistrationResponse);
@@ -809,7 +1080,7 @@ void Interpreter::PrintMulticastListenersTable(void)
while (otBackboneRouterMulticastListenerGetNext(GetInstancePtr(), &iter, &listenerInfo) == OT_ERROR_NONE)
{
OutputIp6Address(listenerInfo.mAddress);
- OutputLine(" %u", listenerInfo.mTimeout);
+ OutputLine(" %lu", ToUlong(listenerInfo.mTimeout));
}
}
@@ -821,18 +1092,81 @@ otError Interpreter::ProcessBackboneRouterLocal(Arg aArgs[])
otBackboneRouterConfig config;
bool enable;
+ /**
+ * @cli bbr (enable,disable)
+ * @code
+ * bbr enable
+ * Done
+ * @endcode
+ * @code
+ * bbr disable
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otBackboneRouterSetEnabled
+ */
if (ParseEnableOrDisable(aArgs[0], enable) == OT_ERROR_NONE)
{
otBackboneRouterSetEnabled(GetInstancePtr(), enable);
}
+ /**
+ * @cli bbr jitter (get,set)
+ * @code
+ * bbr jitter
+ * 20
+ * Done
+ * @endcode
+ * @code
+ * bbr jitter 10
+ * Done
+ * @endcode
+ * @cparam bbr jitter [@ca{jitter}]
+ * @par
+ * Gets or sets jitter (in seconds) for Backbone Router registration.
+ * @par
+ * Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is enabled.
+ * @sa otBackboneRouterGetRegistrationJitter
+ * @sa otBackboneRouterSetRegistrationJitter
+ */
else if (aArgs[0] == "jitter")
{
error = ProcessGetSet(aArgs + 1, otBackboneRouterGetRegistrationJitter, otBackboneRouterSetRegistrationJitter);
}
+ /**
+ * @cli bbr register
+ * @code
+ * bbr register
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otBackboneRouterRegister
+ */
else if (aArgs[0] == "register")
{
SuccessOrExit(error = otBackboneRouterRegister(GetInstancePtr()));
}
+ /**
+ * @cli bbr state
+ * @code
+ * bbr state
+ * Disabled
+ * Done
+ * @endcode
+ * @code
+ * bbr state
+ * Primary
+ * Done
+ * @endcode
+ * @code
+ * bbr state
+ * Secondary
+ * Done
+ * @endcode
+ * @par
+ * Available when `OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE` is enabled.
+ * @par api_copy
+ * #otBackboneRouterGetState
+ */
else if (aArgs[0] == "state")
{
static const char *const kStateStrings[] = {
@@ -847,19 +1181,44 @@ otError Interpreter::ProcessBackboneRouterLocal(Arg aArgs[])
OutputLine("%s", Stringify(otBackboneRouterGetState(GetInstancePtr()), kStateStrings));
}
+ /**
+ * @cli bbr config
+ * @code
+ * bbr config
+ * seqno: 10
+ * delay: 120 secs
+ * timeout: 300 secs
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otBackboneRouterGetConfig
+ */
else if (aArgs[0] == "config")
{
otBackboneRouterGetConfig(GetInstancePtr(), &config);
if (aArgs[1].IsEmpty())
{
- OutputLine("seqno: %d", config.mSequenceNumber);
- OutputLine("delay: %d secs", config.mReregistrationDelay);
- OutputLine("timeout: %d secs", config.mMlrTimeout);
+ OutputLine("seqno: %u", config.mSequenceNumber);
+ OutputLine("delay: %u secs", config.mReregistrationDelay);
+ OutputLine("timeout: %lu secs", ToUlong(config.mMlrTimeout));
}
else
{
// Set local Backbone Router configuration.
+ /**
+ * @cli bbr config (set)
+ * @code
+ * bbr config seqno 20 delay 30
+ * Done
+ * @endcode
+ * @cparam bbr config [seqno @ca{seqno}] [delay @ca{delay}] [timeout @ca{timeout}]
+ * @par
+ * `bbr register` should be issued explicitly to register Backbone Router service to Leader
+ * for Secondary Backbone Router.
+ * @par api_copy
+ * #otBackboneRouterSetConfig
+ */
for (Arg *arg = &aArgs[1]; !arg->IsEmpty(); arg++)
{
if (*arg == "seqno")
@@ -896,21 +1255,30 @@ otError Interpreter::ProcessBackboneRouterLocal(Arg aArgs[])
}
#endif // OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE
+/**
+ * @cli domainname
+ * @code
+ * domainname
+ * Thread
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetDomainName
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
- otError error = OT_ERROR_NONE;
-
- if (aArgs[0].IsEmpty())
- {
- OutputLine("%s", otThreadGetDomainName(GetInstancePtr()));
- }
- else
- {
- SuccessOrExit(error = otThreadSetDomainName(GetInstancePtr(), aArgs[0].GetCString()));
- }
-
-exit:
- return error;
+ /**
+ * @cli domainname (set)
+ * @code
+ * domainname Test\ Thread
+ * Done
+ * @endcode
+ * @cparam domainname @ca{name}
+ * Use a `backslash` to escape spaces.
+ * @par api_copy
+ * #otThreadSetDomainName
+ */
+ return ProcessGetSet(aArgs, otThreadGetDomainName, otThreadSetDomainName);
}
#if OPENTHREAD_CONFIG_DUA_ENABLE
@@ -918,6 +1286,16 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+ /**
+ * @cli dua iid
+ * @code
+ * dua iid
+ * 0004000300020001
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetFixedDuaInterfaceIdentifier
+ */
if (aArgs[0] == "iid")
{
if (aArgs[1].IsEmpty())
@@ -929,6 +1307,22 @@ template <> otError Interpreter::Process(Arg aArgs[])
OutputBytesLine(iid->mFields.m8);
}
}
+ /**
+ * @cli dua iid (set,clear)
+ * @code
+ * dua iid 0004000300020001
+ * Done
+ * @endcode
+ * @code
+ * dua iid clear
+ * Done
+ * @endcode
+ * @cparam dua iid @ca{iid|clear}
+ * `dua iid clear` passes a `nullptr` to #otThreadSetFixedDuaInterfaceIdentifier.
+ * Otherwise, you can pass the `iid`.
+ * @par api_copy
+ * #otThreadSetFixedDuaInterfaceIdentifier
+ */
else if (aArgs[1] == "clear")
{
error = otThreadSetFixedDuaInterfaceIdentifier(GetInstancePtr(), nullptr);
@@ -953,14 +1347,43 @@ template <> otError Interpreter::Process(Arg aArgs[])
#endif // (OPENTHREAD_CONFIG_THREAD_VERSION >= OT_THREAD_VERSION_1_2)
+/**
+ * @cli bufferinfo
+ * @code
+ * bufferinfo
+ * total: 40
+ * free: 40
+ * max-used: 5
+ * 6lo send: 0 0 0
+ * 6lo reas: 0 0 0
+ * ip6: 0 0 0
+ * mpl: 0 0 0
+ * mle: 0 0 0
+ * coap: 0 0 0
+ * coap secure: 0 0 0
+ * application coap: 0 0 0
+ * Done
+ * @endcode
+ * @par
+ * Gets the current message buffer information.
+ * * `total` displays the total number of message buffers in pool.
+ * * `free` displays the number of free message buffers.
+ * * `max-used` displays max number of used buffers at the same time since OT stack
+ * initialization or last `bufferinfo reset`.
+ * @par
+ * Next, the CLI displays info about different queues used by the OpenThread stack,
+ * for example `6lo send`. Each line after the queue represents info about a queue:
+ * * The first number shows number messages in the queue.
+ * * The second number shows number of buffers used by all messages in the queue.
+ * * The third number shows total number of bytes of all messages in the queue.
+ * @sa otMessageGetBufferInfo
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
- OT_UNUSED_VARIABLE(aArgs);
-
struct BufferInfoName
{
const otMessageQueueInfo otBufferInfo::*mQueuePtr;
- const char * mName;
+ const char *mName;
};
static const BufferInfoName kBufferInfoNames[] = {
@@ -974,22 +1397,64 @@ template <> otError Interpreter::Process(Arg aArgs[])
{&otBufferInfo::mApplicationCoapQueue, "application coap"},
};
- otBufferInfo bufferInfo;
+ otError error = OT_ERROR_NONE;
+
+ if (aArgs[0].IsEmpty())
+ {
+ otBufferInfo bufferInfo;
- otMessageGetBufferInfo(GetInstancePtr(), &bufferInfo);
+ otMessageGetBufferInfo(GetInstancePtr(), &bufferInfo);
- OutputLine("total: %d", bufferInfo.mTotalBuffers);
- OutputLine("free: %d", bufferInfo.mFreeBuffers);
+ OutputLine("total: %u", bufferInfo.mTotalBuffers);
+ OutputLine("free: %u", bufferInfo.mFreeBuffers);
+ OutputLine("max-used: %u", bufferInfo.mMaxUsedBuffers);
- for (const BufferInfoName &info : kBufferInfoNames)
+ for (const BufferInfoName &info : kBufferInfoNames)
+ {
+ OutputLine("%s: %u %u %lu", info.mName, (bufferInfo.*info.mQueuePtr).mNumMessages,
+ (bufferInfo.*info.mQueuePtr).mNumBuffers, ToUlong((bufferInfo.*info.mQueuePtr).mTotalBytes));
+ }
+ }
+ /**
+ * @cli bufferinfo reset
+ * @code
+ * bufferinfo reset
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otMessageResetBufferInfo
+ */
+ else if (aArgs[0] == "reset")
+ {
+ otMessageResetBufferInfo(GetInstancePtr());
+ }
+ else
{
- OutputLine("%s: %u %u %u", info.mName, (bufferInfo.*info.mQueuePtr).mNumMessages,
- (bufferInfo.*info.mQueuePtr).mNumBuffers, (bufferInfo.*info.mQueuePtr).mTotalBytes);
+ error = OT_ERROR_INVALID_ARGS;
}
- return OT_ERROR_NONE;
+ return error;
}
+/**
+ * @cli ccathreshold (get,set)
+ * @code
+ * ccathreshold
+ * -75 dBm
+ * Done
+ * @endcode
+ * @code
+ * ccathreshold -62
+ * Done
+ * @endcode
+ * @cparam ccathreshold [@ca{CCA-threshold-dBm}]
+ * Use the optional `CCA-threshold-dBm` argument to set the CCA threshold.
+ * @par
+ * Gets or sets the CCA threshold in dBm measured at the antenna connector per
+ * IEEE 802.15.4 - 2015 section 10.1.4.
+ * @sa otPlatRadioGetCcaEnergyDetectThreshold
+ * @sa otPlatRadioSetCcaEnergyDetectThreshold
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
@@ -1041,20 +1506,88 @@ template <> otError Interpreter::Process(Arg aArgs[])
#endif
+/**
+ * @cli channel (get,set)
+ * @code
+ * channel
+ * 11
+ * Done
+ * @endcode
+ * @code
+ * channel 11
+ * Done
+ * @endcode
+ * @cparam channel [@ca{channel-num}]
+ * Use `channel-num` to set the channel.
+ * @par
+ * Gets or sets the IEEE 802.15.4 Channel value.
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+ /**
+ * @cli channel supported
+ * @code
+ * channel supported
+ * 0x7fff800
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otPlatRadioGetSupportedChannelMask
+ */
if (aArgs[0] == "supported")
{
- OutputLine("0x%x", otPlatRadioGetSupportedChannelMask(GetInstancePtr()));
- }
- else if (aArgs[0] == "preferred")
- {
- OutputLine("0x%x", otPlatRadioGetPreferredChannelMask(GetInstancePtr()));
+ OutputLine("0x%lx", ToUlong(otPlatRadioGetSupportedChannelMask(GetInstancePtr())));
}
-#if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE
- else if (aArgs[0] == "monitor")
+ /**
+ * @cli channel preferred
+ * @code
+ * channel preferred
+ * 0x7fff800
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otPlatRadioGetPreferredChannelMask
+ */
+ else if (aArgs[0] == "preferred")
+ {
+ OutputLine("0x%lx", ToUlong(otPlatRadioGetPreferredChannelMask(GetInstancePtr())));
+ }
+#if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE
+ /**
+ * @cli channel monitor
+ * @code
+ * channel monitor
+ * enabled: 1
+ * interval: 41000
+ * threshold: -75
+ * window: 960
+ * count: 10552
+ * occupancies:
+ * ch 11 (0x0cb7) 4.96% busy
+ * ch 12 (0x2e2b) 18.03% busy
+ * ch 13 (0x2f54) 18.48% busy
+ * ch 14 (0x0fef) 6.22% busy
+ * ch 15 (0x1536) 8.28% busy
+ * ch 16 (0x1746) 9.09% busy
+ * ch 17 (0x0b8b) 4.50% busy
+ * ch 18 (0x60a7) 37.75% busy
+ * ch 19 (0x0810) 3.14% busy
+ * ch 20 (0x0c2a) 4.75% busy
+ * ch 21 (0x08dc) 3.46% busy
+ * ch 22 (0x101d) 6.29% busy
+ * ch 23 (0x0092) 0.22% busy
+ * ch 24 (0x0028) 0.06% busy
+ * ch 25 (0x0063) 0.15% busy
+ * ch 26 (0x058c) 2.16% busy
+ * Done
+ * @endcode
+ * @par
+ * Get the current channel monitor state and channel occupancy.
+ * `OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE` is required.
+ */
+ else if (aArgs[0] == "monitor")
{
if (aArgs[1].IsEmpty())
{
@@ -1064,15 +1597,17 @@ template <> otError Interpreter::Process(Arg aArgs[])
uint32_t channelMask = otLinkGetSupportedChannelMask(GetInstancePtr());
uint8_t channelNum = sizeof(channelMask) * CHAR_BIT;
- OutputLine("interval: %u", otChannelMonitorGetSampleInterval(GetInstancePtr()));
+ OutputLine("interval: %lu", ToUlong(otChannelMonitorGetSampleInterval(GetInstancePtr())));
OutputLine("threshold: %d", otChannelMonitorGetRssiThreshold(GetInstancePtr()));
- OutputLine("window: %u", otChannelMonitorGetSampleWindow(GetInstancePtr()));
- OutputLine("count: %u", otChannelMonitorGetSampleCount(GetInstancePtr()));
+ OutputLine("window: %lu", ToUlong(otChannelMonitorGetSampleWindow(GetInstancePtr())));
+ OutputLine("count: %lu", ToUlong(otChannelMonitorGetSampleCount(GetInstancePtr())));
OutputLine("occupancies:");
+
for (uint8_t channel = 0; channel < channelNum; channel++)
{
- uint32_t occupancy = 0;
+ uint16_t occupancy;
+ PercentageStringBuffer stringBuffer;
if (!((1UL << channel) & channelMask))
{
@@ -1081,17 +1616,43 @@ template <> otError Interpreter::Process(Arg aArgs[])
occupancy = otChannelMonitorGetChannelOccupancy(GetInstancePtr(), channel);
- OutputFormat("ch %d (0x%04x) ", channel, occupancy);
- occupancy = (occupancy * 10000) / 0xffff;
- OutputLine("%2d.%02d%% busy", occupancy / 100, occupancy % 100);
+ OutputLine("ch %u (0x%04x) %6s%% busy", channel, occupancy,
+ PercentageToString(occupancy, stringBuffer));
}
- OutputLine("");
+
+ OutputNewLine();
}
}
+ /**
+ * @cli channel monitor start
+ * @code
+ * channel monitor start
+ * channel monitor start
+ * Done
+ * @endcode
+ * @par
+ * Start the channel monitor.
+ * OT CLI sends a boolean value of `true` to #otChannelMonitorSetEnabled.
+ * `OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE` is required.
+ * @sa otChannelMonitorSetEnabled
+ */
else if (aArgs[1] == "start")
{
error = otChannelMonitorSetEnabled(GetInstancePtr(), true);
}
+ /**
+ * @cli channel monitor stop
+ * @code
+ * channel monitor stop
+ * channel monitor stop
+ * Done
+ * @endcode
+ * @par
+ * Stop the channel monitor.
+ * OT CLI sends a boolean value of `false` to #otChannelMonitorSetEnabled.
+ * `OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE` is required.
+ * @sa otChannelMonitorSetEnabled
+ */
else if (aArgs[1] == "stop")
{
error = otChannelMonitorSetEnabled(GetInstancePtr(), false);
@@ -1105,9 +1666,26 @@ template <> otError Interpreter::Process(Arg aArgs[])
#if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE && OPENTHREAD_FTD
else if (aArgs[0] == "manager")
{
+ /**
+ * @cli channel manager
+ * @code
+ * channel manager
+ * channel: 11
+ * auto: 1
+ * delay: 120
+ * interval: 10800
+ * supported: { 11-26}
+ * favored: { 11-26}
+ * Done
+ * @endcode
+ * @par
+ * Get the channel manager state.
+ * `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` is required.
+ * @sa otChannelManagerGetRequestedChannel
+ */
if (aArgs[1].IsEmpty())
{
- OutputLine("channel: %d", otChannelManagerGetRequestedChannel(GetInstancePtr()));
+ OutputLine("channel: %u", otChannelManagerGetRequestedChannel(GetInstancePtr()));
OutputLine("auto: %d", otChannelManagerGetAutoChannelSelectionEnabled(GetInstancePtr()));
if (otChannelManagerGetAutoChannelSelectionEnabled(GetInstancePtr()))
@@ -1115,18 +1693,45 @@ template <> otError Interpreter::Process(Arg aArgs[])
Mac::ChannelMask supportedMask(otChannelManagerGetSupportedChannels(GetInstancePtr()));
Mac::ChannelMask favoredMask(otChannelManagerGetFavoredChannels(GetInstancePtr()));
- OutputLine("delay: %d", otChannelManagerGetDelay(GetInstancePtr()));
- OutputLine("interval: %u", otChannelManagerGetAutoChannelSelectionInterval(GetInstancePtr()));
+ OutputLine("delay: %u", otChannelManagerGetDelay(GetInstancePtr()));
+ OutputLine("interval: %lu", ToUlong(otChannelManagerGetAutoChannelSelectionInterval(GetInstancePtr())));
OutputLine("cca threshold: 0x%04x", otChannelManagerGetCcaFailureRateThreshold(GetInstancePtr()));
OutputLine("supported: %s", supportedMask.ToString().AsCString());
- OutputLine("favored: %s", supportedMask.ToString().AsCString());
+ OutputLine("favored: %s", favoredMask.ToString().AsCString());
}
}
+ /**
+ * @cli channel manager change
+ * @code
+ * channel manager change 11
+ * channel manager change 11
+ * Done
+ * @endcode
+ * @cparam channel manager change @ca{channel-num}
+ * @par
+ * `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` is required.
+ * @par api_copy
+ * #otChannelManagerRequestChannelChange
+ */
else if (aArgs[1] == "change")
{
error = ProcessSet(aArgs + 2, otChannelManagerRequestChannelChange);
}
#if OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE
+ /**
+ * @cli channel manager select
+ * @code
+ * channel manager select 1
+ * channel manager select 1
+ * Done
+ * @endcode
+ * @cparam channel manager select @ca{skip-quality-check}
+ * Use a `1` or `0` for the boolean `skip-quality-check`.
+ * @par
+ * `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` and `OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE` are required.
+ * @par api_copy
+ * #otChannelManagerRequestChannelSelect
+ */
else if (aArgs[1] == "select")
{
bool enable;
@@ -1135,6 +1740,20 @@ template <> otError Interpreter::Process(Arg aArgs[])
error = otChannelManagerRequestChannelSelect(GetInstancePtr(), enable);
}
#endif
+ /**
+ * @cli channel manager auto
+ * @code
+ * channel manager auto 1
+ * channel manager auto 1
+ * Done
+ * @endcode
+ * @cparam channel manager auto @ca{enable}
+ * `1` is a boolean to `enable`.
+ * @par
+ * `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` and `OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE` are required.
+ * @par api_copy
+ * #otChannelManagerSetAutoChannelSelectionEnabled
+ */
else if (aArgs[1] == "auto")
{
bool enable;
@@ -1142,22 +1761,88 @@ template <> otError Interpreter::Process(Arg aArgs[])
SuccessOrExit(error = aArgs[2].ParseAsBool(enable));
otChannelManagerSetAutoChannelSelectionEnabled(GetInstancePtr(), enable);
}
+ /**
+ * @cli channel manager delay
+ * @code
+ * channel manager delay 120
+ * channel manager delay 120
+ * Done
+ * @endcode
+ * @cparam channel manager delay @ca{delay-seconds}
+ * @par
+ * `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` and `OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE` are required.
+ * @par api_copy
+ * #otChannelManagerSetDelay
+ */
else if (aArgs[1] == "delay")
{
- error = ProcessSet(aArgs + 2, otChannelManagerSetDelay);
- }
+ error = ProcessGetSet(aArgs + 2, otChannelManagerGetDelay, otChannelManagerSetDelay);
+ }
+ /**
+ * @cli channel manager interval
+ * @code
+ * channel manager interval 10800
+ * channel manager interval 10800
+ * Done
+ * @endcode
+ * @cparam channel manager interval @ca{interval-seconds}
+ * @par
+ * `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` and `OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE` are required.
+ * @par api_copy
+ * #otChannelManagerSetAutoChannelSelectionInterval
+ */
else if (aArgs[1] == "interval")
{
error = ProcessSet(aArgs + 2, otChannelManagerSetAutoChannelSelectionInterval);
}
+ /**
+ * @cli channel manager supported
+ * @code
+ * channel manager supported 0x7fffc00
+ * channel manager supported 0x7fffc00
+ * Done
+ * @endcode
+ * @cparam channel manager supported @ca{mask}
+ * @par
+ * `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` and `OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE` are required.
+ * @par api_copy
+ * #otChannelManagerSetSupportedChannels
+ */
else if (aArgs[1] == "supported")
{
error = ProcessSet(aArgs + 2, otChannelManagerSetSupportedChannels);
}
+ /**
+ * @cli channel manager favored
+ * @code
+ * channel manager favored 0x7fffc00
+ * channel manager favored 0x7fffc00
+ * Done
+ * @endcode
+ * @cparam channel manager favored @ca{mask}
+ * @par
+ * `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` and `OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE` are required.
+ * @par api_copy
+ * #otChannelManagerSetFavoredChannels
+ */
else if (aArgs[1] == "favored")
{
error = ProcessSet(aArgs + 2, otChannelManagerSetFavoredChannels);
}
+ /**
+ * @cli channel manager threshold
+ * @code
+ * channel manager threshold 0xffff
+ * channel manager threshold 0xffff
+ * Done
+ * @endcode
+ * @cparam channel manager threshold @ca{threshold-percent}
+ * Use a hex value for `threshold-percent`. `0` maps to 0% and `0xffff` maps to 100%.
+ * @par
+ * `OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE` and `OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE` are required.
+ * @par api_copy
+ * #otChannelManagerSetCcaFailureRateThreshold
+ */
else if (aArgs[1] == "threshold")
{
error = ProcessSet(aArgs + 2, otChannelManagerSetCcaFailureRateThreshold);
@@ -1193,15 +1878,29 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
uint16_t maxChildren;
+ /**
+ * @cli child table
+ * @code
+ * child table
+ * | ID | RLOC16 | Timeout | Age | LQ In | C_VN |R|D|N|Ver|CSL|QMsgCnt| Extended MAC |
+ * +-----+--------+------------+------------+-------+------+-+-+-+---+---+-------+------------------+
+ * | 1 | 0xc801 | 240 | 24 | 3 | 131 |1|0|0| 3| 0 | 0 | 4ecede68435358ac |
+ * | 2 | 0xc802 | 240 | 2 | 3 | 131 |0|0|0| 3| 1 | 0 | a672a601d2ce37d8 |
+ * Done
+ * @endcode
+ * @par
+ * Prints a table of the attached children.
+ * @sa otThreadGetChildInfoByIndex
+ */
if (isTable)
{
static const char *const kChildTableTitles[] = {
- "ID", "RLOC16", "Timeout", "Age", "LQ In", "C_VN", "R",
- "D", "N", "Ver", "CSL", "QMsgCnt", "Extended MAC",
+ "ID", "RLOC16", "Timeout", "Age", "LQ In", "C_VN", "R",
+ "D", "N", "Ver", "CSL", "QMsgCnt", "Suprvsn", "Extended MAC",
};
static const uint8_t kChildTableColumnWidths[] = {
- 5, 8, 12, 12, 7, 6, 1, 1, 1, 3, 3, 7, 18,
+ 5, 8, 12, 12, 7, 6, 1, 1, 1, 3, 3, 7, 7, 18,
};
OutputTableHeader(kChildTableTitles, kChildTableColumnWidths);
@@ -1219,36 +1918,68 @@ template <> otError Interpreter::Process(Arg aArgs[])
if (isTable)
{
- OutputFormat("| %3d ", childInfo.mChildId);
+ OutputFormat("| %3u ", childInfo.mChildId);
OutputFormat("| 0x%04x ", childInfo.mRloc16);
- OutputFormat("| %10d ", childInfo.mTimeout);
- OutputFormat("| %10d ", childInfo.mAge);
- OutputFormat("| %5d ", childInfo.mLinkQualityIn);
- OutputFormat("| %4d ", childInfo.mNetworkDataVersion);
+ OutputFormat("| %10lu ", ToUlong(childInfo.mTimeout));
+ OutputFormat("| %10lu ", ToUlong(childInfo.mAge));
+ OutputFormat("| %5u ", childInfo.mLinkQualityIn);
+ OutputFormat("| %4u ", childInfo.mNetworkDataVersion);
OutputFormat("|%1d", childInfo.mRxOnWhenIdle);
OutputFormat("|%1d", childInfo.mFullThreadDevice);
OutputFormat("|%1d", childInfo.mFullNetworkData);
- OutputFormat("|%3d", childInfo.mVersion);
+ OutputFormat("|%3u", childInfo.mVersion);
OutputFormat("| %1d ", childInfo.mIsCslSynced);
- OutputFormat("| %5d ", childInfo.mQueuedMessageCnt);
+ OutputFormat("| %5u ", childInfo.mQueuedMessageCnt);
+ OutputFormat("| %5u ", childInfo.mSupervisionInterval);
OutputFormat("| ");
OutputExtAddress(childInfo.mExtAddress);
OutputLine(" |");
}
+ /**
+ * @cli child list
+ * @code
+ * child list
+ * 1 2 3 6 7 8
+ * Done
+ * @endcode
+ * @par
+ * Returns a list of attached Child IDs.
+ * @sa otThreadGetChildInfoByIndex
+ */
else
{
- OutputFormat("%d ", childInfo.mChildId);
+ OutputFormat("%u ", childInfo.mChildId);
}
}
- OutputLine("");
+ OutputNewLine();
ExitNow();
}
SuccessOrExit(error = aArgs[0].ParseAsUint16(childId));
SuccessOrExit(error = otThreadGetChildInfoById(GetInstancePtr(), childId, &childInfo));
- OutputLine("Child ID: %d", childInfo.mChildId);
+ /**
+ * @cli child (id)
+ * @code
+ * child 1
+ * Child ID: 1
+ * Rloc: 9c01
+ * Ext Addr: e2b3540590b0fd87
+ * Mode: rn
+ * CSL Synchronized: 1
+ * Net Data: 184
+ * Timeout: 100
+ * Age: 0
+ * Link Quality In: 3
+ * RSSI: -20
+ * Done
+ * @endcode
+ * @cparam child @ca{child-id}
+ * @par api_copy
+ * #otThreadGetChildInfoById
+ */
+ OutputLine("Child ID: %u", childInfo.mChildId);
OutputLine("Rloc: %04x", childInfo.mRloc16);
OutputFormat("Ext Addr: ");
OutputExtAddressLine(childInfo.mExtAddress);
@@ -1256,11 +1987,13 @@ template <> otError Interpreter::Process(Arg aArgs[])
linkMode.mDeviceType = childInfo.mFullThreadDevice;
linkMode.mNetworkData = childInfo.mFullThreadDevice;
OutputLine("Mode: %s", LinkModeToString(linkMode, linkModeString));
- OutputLine("Net Data: %d", childInfo.mNetworkDataVersion);
- OutputLine("Timeout: %d", childInfo.mTimeout);
- OutputLine("Age: %d", childInfo.mAge);
- OutputLine("Link Quality In: %d", childInfo.mLinkQualityIn);
+ OutputLine("CSL Synchronized: %d ", childInfo.mIsCslSynced);
+ OutputLine("Net Data: %u", childInfo.mNetworkDataVersion);
+ OutputLine("Timeout: %lu", ToUlong(childInfo.mTimeout));
+ OutputLine("Age: %lu", ToUlong(childInfo.mAge));
+ OutputLine("Link Quality In: %u", childInfo.mLinkQualityIn);
OutputLine("RSSI: %d", childInfo.mAverageRssi);
+ OutputLine("Supervision Interval: %d", childInfo.mSupervisionInterval);
exit:
return error;
@@ -1270,6 +2003,17 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+ /**
+ * @cli childip
+ * @code
+ * childip
+ * 3401: fdde:ad00:beef:0:3037:3e03:8c5f:bc0c
+ * Done
+ * @endcode
+ * @par
+ * Gets a list of IP addresses stored for MTD children.
+ * @sa otThreadGetChildNextIp6Address
+ */
if (aArgs[0].IsEmpty())
{
uint16_t maxChildren = otThreadGetMaxAllowedChildren(GetInstancePtr());
@@ -1296,11 +2040,31 @@ template <> otError Interpreter::Process(Arg aArgs[])
}
}
}
+ /**
+ * @cli childip max
+ * @code
+ * childip max
+ * 4
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetMaxChildIpAddresses
+ */
else if (aArgs[0] == "max")
{
#if !OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
error = ProcessGet(aArgs + 1, otThreadGetMaxChildIpAddresses);
#else
+ /**
+ * @cli childip max (set)
+ * @code
+ * childip max 2
+ * Done
+ * @endcode
+ * @cparam childip max @ca{count}
+ * @par api_copy
+ * #otThreadSetMaxChildIpAddresses
+ */
error = ProcessGetSet(aArgs + 1, otThreadGetMaxChildIpAddresses, otThreadSetMaxChildIpAddresses);
#endif
}
@@ -1312,49 +2076,129 @@ template <> otError Interpreter::Process(Arg aArgs[])
return error;
}
+/**
+ * @cli childmax
+ * @code
+ * childmax
+ * 5
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetMaxAllowedChildren
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
+ /**
+ * @cli childmax (set)
+ * @code
+ * childmax 2
+ * Done
+ * @endcode
+ * @cparam childmax @ca{count}
+ * @par api_copy
+ * #otThreadSetMaxAllowedChildren
+ */
return ProcessGetSet(aArgs, otThreadGetMaxAllowedChildren, otThreadSetMaxAllowedChildren);
}
#endif // OPENTHREAD_FTD
-#if OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_INVALID_ARGS;
+ /**
+ * @cli childsupervision checktimeout
+ * @code
+ * childsupervision checktimeout
+ * 30
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otChildSupervisionGetCheckTimeout
+ */
if (aArgs[0] == "checktimeout")
{
+ /** @cli childsupervision checktimeout (set)
+ * @code
+ * childsupervision checktimeout 30
+ * Done
+ * @endcode
+ * @cparam childsupervision checktimeout @ca{timeout-seconds}
+ * @par api_copy
+ * #otChildSupervisionSetCheckTimeout
+ */
error = ProcessGetSet(aArgs + 1, otChildSupervisionGetCheckTimeout, otChildSupervisionSetCheckTimeout);
}
-#if OPENTHREAD_FTD
+ /**
+ * @cli childsupervision interval
+ * @code
+ * childsupervision interval
+ * 30
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otChildSupervisionGetInterval
+ */
else if (aArgs[0] == "interval")
{
+ /**
+ * @cli childsupervision interval (set)
+ * @code
+ * childsupervision interval 30
+ * Done
+ * @endcode
+ * @cparam childsupervision interval @ca{interval-seconds}
+ * @par api_copy
+ * #otChildSupervisionSetInterval
+ */
error = ProcessGetSet(aArgs + 1, otChildSupervisionGetInterval, otChildSupervisionSetInterval);
}
-#endif
+ else if (aArgs[0] == "failcounter")
+ {
+ if (aArgs[1].IsEmpty())
+ {
+ OutputLine("%u", otChildSupervisionGetCheckFailureCounter(GetInstancePtr()));
+ error = OT_ERROR_NONE;
+ }
+ else if (aArgs[1] == "reset")
+ {
+ otChildSupervisionResetCheckFailureCounter(GetInstancePtr());
+ error = OT_ERROR_NONE;
+ }
+ }
return error;
}
-#endif // OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE
+/** @cli childtimeout
+ * @code
+ * childtimeout
+ * 300
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetChildTimeout
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
+ /** @cli childtimeout (set)
+ * @code
+ * childtimeout 300
+ * Done
+ * @endcode
+ * @cparam childtimeout @ca{timeout-seconds}
+ * @par api_copy
+ * #otThreadSetChildTimeout
+ */
return ProcessGetSet(aArgs, otThreadGetChildTimeout, otThreadSetChildTimeout);
}
#if OPENTHREAD_CONFIG_COAP_API_ENABLE
-template <> otError Interpreter::Process(Arg aArgs[])
-{
- return mCoap.Process(aArgs);
-}
+template <> otError Interpreter::Process(Arg aArgs[]) { return mCoap.Process(aArgs); }
#endif
#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE
-template <> otError Interpreter::Process(Arg aArgs[])
-{
- return mCoapSecure.Process(aArgs);
-}
+template <> otError Interpreter::Process(Arg aArgs[]) { return mCoapSecure.Process(aArgs); }
#endif
#if OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE
@@ -1376,7 +2220,7 @@ template <> otError Interpreter::Process(Arg aArgs[])
struct RadioCoexMetricName
{
const uint32_t otRadioCoexMetrics::*mValuePtr;
- const char * mName;
+ const char *mName;
};
static const RadioCoexMetricName kTxMetricNames[] = {
@@ -1407,19 +2251,19 @@ template <> otError Interpreter::Process(Arg aArgs[])
SuccessOrExit(error = otPlatRadioGetCoexMetrics(GetInstancePtr(), &metrics));
OutputLine("Stopped: %s", metrics.mStopped ? "true" : "false");
- OutputLine("Grant Glitch: %u", metrics.mNumGrantGlitch);
+ OutputLine("Grant Glitch: %lu", ToUlong(metrics.mNumGrantGlitch));
OutputLine("Transmit metrics");
for (const RadioCoexMetricName &metric : kTxMetricNames)
{
- OutputLine(kIndentSize, "%s: %u", metric.mName, metrics.*metric.mValuePtr);
+ OutputLine(kIndentSize, "%s: %lu", metric.mName, ToUlong(metrics.*metric.mValuePtr));
}
OutputLine("Receive metrics");
for (const RadioCoexMetricName &metric : kRxMetricNames)
{
- OutputLine(kIndentSize, "%s: %u", metric.mName, metrics.*metric.mValuePtr);
+ OutputLine(kIndentSize, "%s: %lu", metric.mName, ToUlong(metrics.*metric.mValuePtr));
}
}
else
@@ -1433,22 +2277,177 @@ template <> otError Interpreter::Process(Arg aArgs[])
#endif // OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE
#if OPENTHREAD_FTD
+/**
+ * @cli contextreusedelay (get,set)
+ * @code
+ * contextreusedelay
+ * 11
+ * Done
+ * @endcode
+ * @code
+ * contextreusedelay 11
+ * Done
+ * @endcode
+ * @cparam contextreusedelay @ca{delay}
+ * Use the optional `delay` argument to set the `CONTEXT_ID_REUSE_DELAY`.
+ * @par
+ * Gets or sets the `CONTEXT_ID_REUSE_DELAY` value.
+ * @sa otThreadGetContextIdReuseDelay
+ * @sa otThreadSetContextIdReuseDelay
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
return ProcessGetSet(aArgs, otThreadGetContextIdReuseDelay, otThreadSetContextIdReuseDelay);
}
#endif
+#if OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE
+void Interpreter::OutputBorderRouterCounters(void)
+{
+ struct BrCounterName
+ {
+ const otPacketsAndBytes otBorderRoutingCounters::*mPacketsAndBytes;
+ const char *mName;
+ };
+
+ static const BrCounterName kCounterNames[] = {
+ {&otBorderRoutingCounters::mInboundUnicast, "Inbound Unicast"},
+ {&otBorderRoutingCounters::mInboundMulticast, "Inbound Multicast"},
+ {&otBorderRoutingCounters::mOutboundUnicast, "Outbound Unicast"},
+ {&otBorderRoutingCounters::mOutboundMulticast, "Outbound Multicast"},
+ };
+
+ const otBorderRoutingCounters *brCounters = otIp6GetBorderRoutingCounters(GetInstancePtr());
+ Uint64StringBuffer uint64StringBuffer;
+
+ for (const BrCounterName &counter : kCounterNames)
+ {
+ OutputFormat("%s:", counter.mName);
+ OutputFormat(" Packets %s",
+ Uint64ToString((brCounters->*counter.mPacketsAndBytes).mPackets, uint64StringBuffer));
+ OutputLine(" Bytes %s", Uint64ToString((brCounters->*counter.mPacketsAndBytes).mBytes, uint64StringBuffer));
+ }
+
+ OutputLine("RA Rx: %lu", ToUlong(brCounters->mRaRx));
+ OutputLine("RA TxSuccess: %lu", ToUlong(brCounters->mRaTxSuccess));
+ OutputLine("RA TxFailed: %lu", ToUlong(brCounters->mRaTxFailure));
+ OutputLine("RS Rx: %lu", ToUlong(brCounters->mRsRx));
+ OutputLine("RS TxSuccess: %lu", ToUlong(brCounters->mRsTxSuccess));
+ OutputLine("RS TxFailed: %lu", ToUlong(brCounters->mRsTxFailure));
+}
+#endif // OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE
+
template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+ /**
+ * @cli counters
+ * @code
+ * counters
+ * ip
+ * mac
+ * mle
+ * Done
+ * @endcode
+ * @par
+ * Gets the supported counter names.
+ */
if (aArgs[0].IsEmpty())
{
+#if OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE
+ OutputLine("br");
+#endif
OutputLine("ip");
OutputLine("mac");
OutputLine("mle");
}
+#if OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE
+ /**
+ * @cli counters br
+ * @code
+ * counters br
+ * Inbound Unicast: Packets 4 Bytes 320
+ * Inbound Multicast: Packets 0 Bytes 0
+ * Outbound Unicast: Packets 2 Bytes 160
+ * Outbound Multicast: Packets 0 Bytes 0
+ * RA Rx: 4
+ * RA TxSuccess: 2
+ * RA TxFailed: 0
+ * RS Rx: 0
+ * RS TxSuccess: 2
+ * RS TxFailed: 0
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otIp6GetBorderRoutingCounters
+ */
+ else if (aArgs[0] == "br")
+ {
+ if (aArgs[1].IsEmpty())
+ {
+ OutputBorderRouterCounters();
+ }
+ /**
+ * @cli counters br reset
+ * @code
+ * counters br reset
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otIp6ResetBorderRoutingCounters
+ */
+ else if ((aArgs[1] == "reset") && aArgs[2].IsEmpty())
+ {
+ otIp6ResetBorderRoutingCounters(GetInstancePtr());
+ }
+ else
+ {
+ error = OT_ERROR_INVALID_ARGS;
+ }
+ }
+#endif
+ /**
+ * @cli counters (mac)
+ * @code
+ * counters mac
+ * TxTotal: 10
+ * TxUnicast: 3
+ * TxBroadcast: 7
+ * TxAckRequested: 3
+ * TxAcked: 3
+ * TxNoAckRequested: 7
+ * TxData: 10
+ * TxDataPoll: 0
+ * TxBeacon: 0
+ * TxBeaconRequest: 0
+ * TxOther: 0
+ * TxRetry: 0
+ * TxErrCca: 0
+ * TxErrBusyChannel: 0
+ * RxTotal: 2
+ * RxUnicast: 1
+ * RxBroadcast: 1
+ * RxData: 2
+ * RxDataPoll: 0
+ * RxBeacon: 0
+ * RxBeaconRequest: 0
+ * RxOther: 0
+ * RxAddressFiltered: 0
+ * RxDestAddrFiltered: 0
+ * RxDuplicated: 0
+ * RxErrNoFrame: 0
+ * RxErrNoUnknownNeighbor: 0
+ * RxErrInvalidSrcAddr: 0
+ * RxErrSec: 0
+ * RxErrFcs: 0
+ * RxErrOther: 0
+ * Done
+ * @endcode
+ * @cparam counters @ca{mac}
+ * @par api_copy
+ * #otLinkGetCounters
+ */
else if (aArgs[0] == "mac")
{
if (aArgs[1].IsEmpty())
@@ -1456,7 +2455,7 @@ template <> otError Interpreter::Process(Arg aArgs[])
struct MacCounterName
{
const uint32_t otMacCounters::*mValuePtr;
- const char * mName;
+ const char *mName;
};
static const MacCounterName kTxCounterNames[] = {
@@ -1473,6 +2472,9 @@ template <> otError Interpreter::Process(Arg aArgs[])
{&otMacCounters::mTxRetry, "TxRetry"},
{&otMacCounters::mTxErrCca, "TxErrCca"},
{&otMacCounters::mTxErrBusyChannel, "TxErrBusyChannel"},
+ {&otMacCounters::mTxErrAbort, "TxErrAbort"},
+ {&otMacCounters::mTxDirectMaxRetryExpiry, "TxDirectMaxRetryExpiry"},
+ {&otMacCounters::mTxIndirectMaxRetryExpiry, "TxIndirectMaxRetryExpiry"},
};
static const MacCounterName kRxCounterNames[] = {
@@ -1496,20 +2498,30 @@ template <> otError Interpreter::Process(Arg aArgs[])
const otMacCounters *macCounters = otLinkGetCounters(GetInstancePtr());
- OutputLine("TxTotal: %d", macCounters->mTxTotal);
+ OutputLine("TxTotal: %lu", ToUlong(macCounters->mTxTotal));
for (const MacCounterName &counter : kTxCounterNames)
{
- OutputLine(kIndentSize, "%s: %u", counter.mName, macCounters->*counter.mValuePtr);
+ OutputLine(kIndentSize, "%s: %lu", counter.mName, ToUlong(macCounters->*counter.mValuePtr));
}
- OutputLine("RxTotal: %d", macCounters->mRxTotal);
+ OutputLine("RxTotal: %lu", ToUlong(macCounters->mRxTotal));
for (const MacCounterName &counter : kRxCounterNames)
{
- OutputLine(kIndentSize, "%s: %u", counter.mName, macCounters->*counter.mValuePtr);
+ OutputLine(kIndentSize, "%s: %lu", counter.mName, ToUlong(macCounters->*counter.mValuePtr));
}
}
+ /**
+ * @cli counters mac reset
+ * @code
+ * counters mac reset
+ * Done
+ * @endcode
+ * @cparam counters @ca{mac} reset
+ * @par api_copy
+ * #otLinkResetCounters
+ */
else if ((aArgs[1] == "reset") && aArgs[2].IsEmpty())
{
otLinkResetCounters(GetInstancePtr());
@@ -1519,6 +2531,25 @@ template <> otError Interpreter::Process(Arg aArgs[])
error = OT_ERROR_INVALID_ARGS;
}
}
+ /**
+ * @cli counters (mle)
+ * @code
+ * counters mle
+ * Role Disabled: 0
+ * Role Detached: 1
+ * Role Child: 0
+ * Role Router: 0
+ * Role Leader: 1
+ * Attach Attempts: 1
+ * Partition Id Changes: 1
+ * Better Partition Attach Attempts: 0
+ * Parent Changes: 0
+ * Done
+ * @endcode
+ * @cparam counters @ca{mle}
+ * @par api_copy
+ * #otThreadGetMleCounters
+ */
else if (aArgs[0] == "mle")
{
if (aArgs[1].IsEmpty())
@@ -1526,7 +2557,7 @@ template <> otError Interpreter::Process(Arg aArgs[])
struct MleCounterName
{
const uint16_t otMleCounters::*mValuePtr;
- const char * mName;
+ const char *mName;
};
static const MleCounterName kCounterNames[] = {
@@ -1545,9 +2576,43 @@ template <> otError Interpreter::Process(Arg aArgs[])
for (const MleCounterName &counter : kCounterNames)
{
- OutputLine("%s: %d", counter.mName, mleCounters->*counter.mValuePtr);
+ OutputLine("%s: %u", counter.mName, mleCounters->*counter.mValuePtr);
}
+#if OPENTHREAD_CONFIG_UPTIME_ENABLE
+ {
+ struct MleTimeCounterName
+ {
+ const uint64_t otMleCounters::*mValuePtr;
+ const char *mName;
+ };
+
+ static const MleTimeCounterName kTimeCounterNames[] = {
+ {&otMleCounters::mDisabledTime, "Disabled"}, {&otMleCounters::mDetachedTime, "Detached"},
+ {&otMleCounters::mChildTime, "Child"}, {&otMleCounters::mRouterTime, "Router"},
+ {&otMleCounters::mLeaderTime, "Leader"},
+ };
+
+ for (const MleTimeCounterName &counter : kTimeCounterNames)
+ {
+ OutputFormat("Time %s Milli: ", counter.mName);
+ OutputUint64Line(mleCounters->*counter.mValuePtr);
+ }
+
+ OutputFormat("Time Tracked Milli: ");
+ OutputUint64Line(mleCounters->mTrackedTime);
+ }
+#endif
}
+ /**
+ * @cli counters mle reset
+ * @code
+ * counters mle reset
+ * Done
+ * @endcode
+ * @cparam counters @ca{mle} reset
+ * @par api_copy
+ * #otThreadResetMleCounters
+ */
else if ((aArgs[1] == "reset") && aArgs[2].IsEmpty())
{
otThreadResetMleCounters(GetInstancePtr());
@@ -1557,6 +2622,20 @@ template <> otError Interpreter::Process(Arg aArgs[])
error = OT_ERROR_INVALID_ARGS;
}
}
+ /**
+ * @cli counters ip
+ * @code
+ * counters ip
+ * TxSuccess: 10
+ * TxFailed: 0
+ * RxSuccess: 5
+ * RxFailed: 0
+ * Done
+ * @endcode
+ * @cparam counters @ca{ip}
+ * @par api_copy
+ * #otThreadGetIp6Counters
+ */
else if (aArgs[0] == "ip")
{
if (aArgs[1].IsEmpty())
@@ -1564,7 +2643,7 @@ template <> otError Interpreter::Process(Arg aArgs[])
struct IpCounterName
{
const uint32_t otIpCounters::*mValuePtr;
- const char * mName;
+ const char *mName;
};
static const IpCounterName kCounterNames[] = {
@@ -1578,9 +2657,19 @@ template <> otError Interpreter::Process(Arg aArgs[])
for (const IpCounterName &counter : kCounterNames)
{
- OutputLine("%s: %d", counter.mName, ipCounters->*counter.mValuePtr);
+ OutputLine("%s: %lu", counter.mName, ToUlong(ipCounters->*counter.mValuePtr));
}
}
+ /**
+ * @cli counters ip reset
+ * @code
+ * counters ip reset
+ * Done
+ * @endcode
+ * @cparam counters @ca{ip} reset
+ * @par api_copy
+ * #otThreadResetIp6Counters
+ */
else if ((aArgs[1] == "reset") && aArgs[2].IsEmpty())
{
otThreadResetIp6Counters(GetInstancePtr());
@@ -1603,21 +2692,67 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+ /**
+ * @cli csl
+ * @code
+ * csl
+ * Channel: 11
+ * Period: 1000 (in units of 10 symbols), 160ms
+ * Timeout: 1000s
+ * Done
+ * @endcode
+ * @par
+ * Gets the CSL configuration.
+ * @sa otLinkCslGetChannel
+ * @sa otLinkCslGetPeriod
+ * @sa otLinkCslGetPeriod
+ * @sa otLinkCslGetTimeout
+ */
if (aArgs[0].IsEmpty())
{
OutputLine("Channel: %u", otLinkCslGetChannel(GetInstancePtr()));
- OutputLine("Period: %u(in units of 10 symbols), %ums", otLinkCslGetPeriod(GetInstancePtr()),
- otLinkCslGetPeriod(GetInstancePtr()) * kUsPerTenSymbols / 1000);
- OutputLine("Timeout: %us", otLinkCslGetTimeout(GetInstancePtr()));
+ OutputLine("Period: %u(in units of 10 symbols), %lums", otLinkCslGetPeriod(GetInstancePtr()),
+ ToUlong(otLinkCslGetPeriod(GetInstancePtr()) * kUsPerTenSymbols / 1000));
+ OutputLine("Timeout: %lus", ToUlong(otLinkCslGetTimeout(GetInstancePtr())));
}
+ /**
+ * @cli csl channel
+ * @code
+ * csl channel 20
+ * Done
+ * @endcode
+ * @cparam csl channel @ca{channel}
+ * @par api_copy
+ * #otLinkCslSetChannel
+ */
else if (aArgs[0] == "channel")
{
error = ProcessSet(aArgs + 1, otLinkCslSetChannel);
}
+ /**
+ * @cli csl period
+ * @code
+ * csl period 3000
+ * Done
+ * @endcode
+ * @cparam csl period @ca{period}
+ * @par api_copy
+ * #otLinkCslSetPeriod
+ */
else if (aArgs[0] == "period")
{
error = ProcessSet(aArgs + 1, otLinkCslSetPeriod);
}
+ /**
+ * @cli csl timeout
+ * @code
+ * cls timeout 10
+ * Done
+ * @endcode
+ * @cparam csl timeout @ca{timeout}
+ * @par api_copy
+ * #otLinkCslSetTimeout
+ */
else if (aArgs[0] == "timeout")
{
error = ProcessSet(aArgs + 1, otLinkCslSetTimeout);
@@ -1636,10 +2771,32 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+ /**
+ * @cli delaytimermin
+ * @code
+ * delaytimermin
+ * 30
+ * Done
+ * @endcode
+ * @par
+ * Get the minimal delay timer (in seconds).
+ * @sa otDatasetGetDelayTimerMinimal
+ */
if (aArgs[0].IsEmpty())
{
- OutputLine("%d", (otDatasetGetDelayTimerMinimal(GetInstancePtr()) / 1000));
+ OutputLine("%lu", ToUlong((otDatasetGetDelayTimerMinimal(GetInstancePtr()) / 1000)));
}
+ /**
+ * @cli delaytimermin (set)
+ * @code
+ * delaytimermin 60
+ * Done
+ * @endcode
+ * @cparam delaytimermin @ca{delaytimermin}
+ * @par
+ * Sets the minimal delay timer (in seconds).
+ * @sa otDatasetSetDelayTimerMinimal
+ */
else if (aArgs[1].IsEmpty())
{
uint32_t delay;
@@ -1675,11 +2832,57 @@ template <> otError Interpreter::Process(Arg aArgs[])
return error;
}
+/**
+ * @cli discover
+ * @code
+ * discover
+ * | J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |
+ * +---+------------------+------------------+------+------------------+----+-----+-----+
+ * | 0 | OpenThread | dead00beef00cafe | ffff | f1d92a82c8d8fe43 | 11 | -20 | 0 |
+ * Done
+ * @endcode
+ * @cparam discover [@ca{channel}]
+ * `channel`: The channel to discover on. If no channel is provided, the discovery will cover all
+ * valid channels.
+ * @par
+ * Perform an MLE Discovery operation.
+ * @sa otThreadDiscover
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
uint32_t scanChannels = 0;
+#if OPENTHREAD_FTD
+ /**
+ * @cli discover reqcallback (enable,disable)
+ * @code
+ * discover reqcallback enable
+ * Done
+ * @endcode
+ * @cparam discover reqcallback @ca{enable|disable}
+ * @par api_copy
+ * #otThreadSetDiscoveryRequestCallback
+ */
+ if (aArgs[0] == "reqcallback")
+ {
+ bool enable;
+ otThreadDiscoveryRequestCallback callback = nullptr;
+ void *context = nullptr;
+
+ SuccessOrExit(error = ParseEnableOrDisable(aArgs[1], enable));
+
+ if (enable)
+ {
+ callback = &Interpreter::HandleDiscoveryRequest;
+ context = this;
+ }
+
+ otThreadSetDiscoveryRequestCallback(GetInstancePtr(), callback, context);
+ ExitNow();
+ }
+#endif // OPENTHREAD_FTD
+
if (!aArgs[0].IsEmpty())
{
uint8_t channel;
@@ -1722,9 +2925,49 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
error = OT_ERROR_INVALID_ARGS;
}
+ /**
+ * @cli dns compression
+ * @code
+ * dns compression
+ * Enabled
+ * @endcode
+ * @cparam dns compression [@ca{enable|disable}]
+ * @par api_copy
+ * #otDnsIsNameCompressionEnabled
+ * @par
+ * By default DNS name compression is enabled. When disabled,
+ * DNS names are appended as full and never compressed. This
+ * is applicable to OpenThread's DNS and SRP client/server
+ * modules."
+ * 'OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE' is required.
+ */
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
else if (aArgs[0] == "compression")
{
+ /**
+ * @cli dns compression (enable,disable)
+ * @code
+ * dns compression enable
+ * Enabled
+ * @endcode
+ * @code
+ * dns compression disable
+ * Done
+ * dns compression
+ * Disabled
+ * Done
+ * @endcode
+ * @cparam dns compression [@ca{enable|disable}]
+ * @par
+ * Set the "DNS name compression" mode.
+ * @par
+ * By default DNS name compression is enabled. When disabled,
+ * DNS names are appended as full and never compressed. This
+ * is applicable to OpenThread's DNS and SRP client/server
+ * modules."
+ * 'OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE' is required.
+ * @sa otDnsSetNameCompressionEnabled
+ */
if (aArgs[1].IsEmpty())
{
OutputEnabledDisabledStatus(otDnsIsNameCompressionEnabled());
@@ -1739,25 +2982,124 @@ template <> otError Interpreter::Process(Arg aArgs[])
}
#endif // OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
+
else if (aArgs[0] == "config")
{
+ /**
+ * @cli dns config
+ * @code
+ * dns config
+ * Server: [fd00:0:0:0:0:0:0:1]:1234
+ * ResponseTimeout: 5000 ms
+ * MaxTxAttempts: 2
+ * RecursionDesired: no
+ * ServiceMode: srv
+ * Nat64Mode: allow
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otDnsClientGetDefaultConfig
+ * @par
+ * The config includes the server IPv6 address and port, response
+ * timeout in msec (wait time to rx response), maximum tx attempts
+ * before reporting failure, boolean flag to indicate whether the server
+ * can resolve the query recursively or not.
+ * 'OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE' is required.
+ */
if (aArgs[1].IsEmpty())
{
const otDnsQueryConfig *defaultConfig = otDnsClientGetDefaultConfig(GetInstancePtr());
OutputFormat("Server: ");
OutputSockAddrLine(defaultConfig->mServerSockAddr);
- OutputLine("ResponseTimeout: %u ms", defaultConfig->mResponseTimeout);
+ OutputLine("ResponseTimeout: %lu ms", ToUlong(defaultConfig->mResponseTimeout));
OutputLine("MaxTxAttempts: %u", defaultConfig->mMaxTxAttempts);
OutputLine("RecursionDesired: %s",
(defaultConfig->mRecursionFlag == OT_DNS_FLAG_RECURSION_DESIRED) ? "yes" : "no");
+ OutputLine("ServiceMode: %s", DnsConfigServiceModeToString(defaultConfig->mServiceMode));
+#if OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE
+ OutputLine("Nat64Mode: %s", (defaultConfig->mNat64Mode == OT_DNS_NAT64_ALLOW) ? "allow" : "disallow");
+#endif
+#if OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE
+ OutputLine("TransportProtocol: %s",
+ (defaultConfig->mTransportProto == OT_DNS_TRANSPORT_UDP) ? "udp" : "tcp");
+#endif
}
+ /**
+ * @cli dns config (set)
+ * @code
+ * dns config fd00::1 1234 5000 2 0
+ * Done
+ * @endcode
+ * @code
+ * dns config
+ * Server: [fd00:0:0:0:0:0:0:1]:1234
+ * ResponseTimeout: 5000 ms
+ * MaxTxAttempts: 2
+ * RecursionDesired: no
+ * Done
+ * @endcode
+ * @code
+ * dns config fd00::2
+ * Done
+ * @endcode
+ * @code
+ * dns config
+ * Server: [fd00:0:0:0:0:0:0:2]:53
+ * ResponseTimeout: 3000 ms
+ * MaxTxAttempts: 3
+ * RecursionDesired: yes
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otDnsClientSetDefaultConfig
+ * @cparam dns config [@ca{dns-server-IP}] [@ca{dns-server-port}] [@ca{response-timeout-ms}] [@ca{max-tx-attempts}] [@ca{recursion-desired-boolean}] [@ca{service-mode}]
+ * @par
+ * We can leave some of the fields as unspecified (or use value zero). The
+ * unspecified fields are replaced by the corresponding OT config option
+ * definitions OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT to form the default
+ * query config.
+ * 'OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE' is required.
+ */
else
{
SuccessOrExit(error = GetDnsConfig(aArgs + 1, config));
otDnsClientSetDefaultConfig(GetInstancePtr(), config);
}
}
+ /**
+ * @cli dns resolve
+ * @code
+ * dns resolve ipv6.google.com
+ * DNS response for ipv6.google.com - 2a00:1450:401b:801:0:0:0:200e TTL: 300
+ * @endcode
+ * @code
+ * dns resolve example.com 8.8.8.8
+ * Synthesized IPv6 DNS server address: fdde:ad00:beef:2:0:0:808:808
+ * DNS response for example.com. - fd4c:9574:3720:2:0:0:5db8:d822 TTL:20456
+ * Done
+ * @endcode
+ * @cparam dns resolve @ca{hostname} [@ca{dns-server-IP}] [@ca{dns-server-port}] [@ca{response-timeout-ms}] [@ca{max-tx-attempts}] [@ca{recursion-desired-boolean}]
+ * @par api_copy
+ * #otDnsClientResolveAddress
+ * @par
+ * Send DNS Query to obtain IPv6 address for given hostname.
+ * @par
+ * The parameters after hostname are optional. Any unspecified (or zero) value
+ * for these optional parameters is replaced by the value from the current default
+ * config (dns config).
+ * @par
+ * The DNS server IP can be an IPv4 address, which will be synthesized to an
+ * IPv6 address using the preferred NAT64 prefix from the network data.
+ * @par
+ * Note: The command will return InvalidState when the DNS server IP is an IPv4
+ * address but the preferred NAT64 prefix is unavailable.
+ * 'OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE' is required.
+ */
else if (aArgs[0] == "resolve")
{
VerifyOrExit(!aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
@@ -1777,6 +3119,51 @@ template <> otError Interpreter::Process(Arg aArgs[])
}
#endif
#if OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE
+ /**
+ * @cli dns browse
+ * @code
+ * dns browse _service._udp.example.com
+ * DNS browse response for _service._udp.example.com.
+ * inst1
+ * Port:1234, Priority:1, Weight:2, TTL:7200
+ * Host:host.example.com.
+ * HostAddress:fd00:0:0:0:0:0:0:abcd TTL:7200
+ * TXT:[a=6531, b=6c12] TTL:7300
+ * instance2
+ * Port:1234, Priority:1, Weight:2, TTL:7200
+ * Host:host.example.com.
+ * HostAddress:fd00:0:0:0:0:0:0:abcd TTL:7200
+ * TXT:[a=1234] TTL:7300
+ * Done
+ * @endcode
+ * @code
+ * dns browse _airplay._tcp.default.service.arpa
+ * DNS browse response for _airplay._tcp.default.service.arpa.
+ * Mac mini
+ * Port:7000, Priority:0, Weight:0, TTL:10
+ * Host:Mac-mini.default.service.arpa.
+ * HostAddress:fd97:739d:386a:1:1c2e:d83c:fcbe:9cf4 TTL:10
+ * Done
+ * @endcode
+ * @cparam dns browse @ca{service-name} [@ca{dns-server-IP}] [@ca{dns-server-port}] [@ca{response-timeout-ms}] [@ca{max-tx-attempts}] [@ca{recursion-desired-boolean}]
+ * @sa otDnsClientBrowse
+ * @par
+ * Send a browse (service instance enumeration) DNS query to get the list of services for
+ * given service-name
+ * @par
+ * The parameters after `service-name` are optional. Any unspecified (or zero) value
+ * for these optional parameters is replaced by the value from the current default
+ * config (`dns config`).
+ * @par
+ * Note: The DNS server IP can be an IPv4 address, which will be synthesized to an IPv6
+ * address using the preferred NAT64 prefix from the network data. The command will return
+ * `InvalidState` when the DNS server IP is an IPv4 address but the preferred NAT64 prefix
+ * is unavailable. When testing DNS-SD discovery proxy, the zone is not `local` and
+ * instead should be `default.service.arpa`.
+ * 'OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE' is required.
+ */
else if (aArgs[0] == "browse")
{
VerifyOrExit(!aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
@@ -1785,16 +3172,88 @@ template <> otError Interpreter::Process(Arg aArgs[])
&Interpreter::HandleDnsBrowseResponse, this, config));
error = OT_ERROR_PENDING;
}
- else if (aArgs[0] == "service")
- {
- VerifyOrExit(!aArgs[2].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
- SuccessOrExit(error = GetDnsConfig(aArgs + 3, config));
+ /**
+ * @cli dns service
+ * @cparam dns service @ca{service-instance-label} @ca{service-name} [@ca{DNS-server-IP}] [@ca{DNS-server-port}] [@ca{response-timeout-ms}] [@ca{max-tx-attempts}] [@ca{recursion-desired-boolean}]
+ * @par api_copy
+ * #otDnsClientResolveService
+ * @par
+ * Send a service instance resolution DNS query for a given service instance.
+ * Service instance label is provided first, followed by the service name
+ * (note that service instance label can contain dot '.' character).
+ * @par
+ * The parameters after `service-name` are optional. Any unspecified (or zero)
+ * value for these optional parameters is replaced by the value from the
+ * current default config (`dns config`).
+ * @par
+ * Note: The DNS server IP can be an IPv4 address, which will be synthesized
+ * to an IPv6 address using the preferred NAT64 prefix from the network data.
+ * The command will return `InvalidState` when the DNS * server IP is an IPv4
+ * address but the preferred NAT64 prefix is unavailable.
+ * 'OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE' is required.
+ */
+ else if (aArgs[0] == "service")
+ {
+ VerifyOrExit(!aArgs[2].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
+ SuccessOrExit(error = GetDnsConfig(aArgs + 3, config));
SuccessOrExit(error = otDnsClientResolveService(GetInstancePtr(), aArgs[1].GetCString(), aArgs[2].GetCString(),
&Interpreter::HandleDnsServiceResponse, this, config));
error = OT_ERROR_PENDING;
}
#endif // OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE
#endif // OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
+#if OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE
+ else if (aArgs[0] == "server")
+ {
+ if (aArgs[1].IsEmpty())
+ {
+ error = OT_ERROR_INVALID_ARGS;
+ }
+#if OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE
+ else if (aArgs[1] == "upstream")
+ {
+ /**
+ * @cli dns server upstream
+ * @code
+ * dns server upstream
+ * Enabled
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otDnssdUpstreamQueryIsEnabled
+ */
+ if (aArgs[2].IsEmpty())
+ {
+ OutputEnabledDisabledStatus(otDnssdUpstreamQueryIsEnabled(GetInstancePtr()));
+ }
+ /**
+ * @cli dns server upstream {enable|disable}
+ * @code
+ * dns server upstream enable
+ * Done
+ * @endcode
+ * @cparam dns server upstream @ca{enable|disable}
+ * @par api_copy
+ * #otDnssdUpstreamQuerySetEnabled
+ */
+ else
+ {
+ bool enable;
+
+ SuccessOrExit(error = ParseEnableOrDisable(aArgs[2], enable));
+ otDnssdUpstreamQuerySetEnabled(GetInstancePtr(), enable);
+ }
+ }
+#endif // OPENTHREAD_CONFIG_DNS_UPSTREAM_QUERY_ENABLE
+ else
+ {
+ ExitNow(error = OT_ERROR_INVALID_COMMAND);
+ }
+ }
+#endif // OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE
else
{
ExitNow(error = OT_ERROR_INVALID_COMMAND);
@@ -1806,20 +3265,85 @@ template <> otError Interpreter::Process(Arg aArgs[])
#if OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE
+const char *Interpreter::DnsConfigServiceModeToString(otDnsServiceMode aMode) const
+{
+ static const char *const kServiceModeStrings[] = {
+ "unspec", // OT_DNS_SERVICE_MODE_UNSPECIFIED (0)
+ "srv", // OT_DNS_SERVICE_MODE_SRV (1)
+ "txt", // OT_DNS_SERVICE_MODE_TXT (2)
+ "srv_txt", // OT_DNS_SERVICE_MODE_SRV_TXT (3)
+ "srv_txt_sep", // OT_DNS_SERVICE_MODE_SRV_TXT_SEPARATE (4)
+ "srv_txt_opt", // OT_DNS_SERVICE_MODE_SRV_TXT_OPTIMIZE (5)
+ };
+
+ static_assert(OT_DNS_SERVICE_MODE_UNSPECIFIED == 0, "OT_DNS_SERVICE_MODE_UNSPECIFIED value is incorrect");
+ static_assert(OT_DNS_SERVICE_MODE_SRV == 1, "OT_DNS_SERVICE_MODE_SRV value is incorrect");
+ static_assert(OT_DNS_SERVICE_MODE_TXT == 2, "OT_DNS_SERVICE_MODE_TXT value is incorrect");
+ static_assert(OT_DNS_SERVICE_MODE_SRV_TXT == 3, "OT_DNS_SERVICE_MODE_SRV_TXT value is incorrect");
+ static_assert(OT_DNS_SERVICE_MODE_SRV_TXT_SEPARATE == 4, "OT_DNS_SERVICE_MODE_SRV_TXT_SEPARATE value is incorrect");
+ static_assert(OT_DNS_SERVICE_MODE_SRV_TXT_OPTIMIZE == 5, "OT_DNS_SERVICE_MODE_SRV_TXT_OPTIMIZE value is incorrect");
+
+ return Stringify(aMode, kServiceModeStrings);
+}
+
+otError Interpreter::ParseDnsServiceMode(const Arg &aArg, otDnsServiceMode &aMode) const
+{
+ otError error = OT_ERROR_NONE;
+
+ if (aArg == "def")
+ {
+ aMode = OT_DNS_SERVICE_MODE_UNSPECIFIED;
+ }
+ else if (aArg == "srv")
+ {
+ aMode = OT_DNS_SERVICE_MODE_SRV;
+ }
+ else if (aArg == "txt")
+ {
+ aMode = OT_DNS_SERVICE_MODE_TXT;
+ }
+ else if (aArg == "srv_txt")
+ {
+ aMode = OT_DNS_SERVICE_MODE_SRV_TXT;
+ }
+ else if (aArg == "srv_txt_sep")
+ {
+ aMode = OT_DNS_SERVICE_MODE_SRV_TXT_SEPARATE;
+ }
+ else if (aArg == "srv_txt_opt")
+ {
+ aMode = OT_DNS_SERVICE_MODE_SRV_TXT_OPTIMIZE;
+ }
+ else
+ {
+ error = OT_ERROR_INVALID_ARGS;
+ }
+
+ return error;
+}
+
otError Interpreter::GetDnsConfig(Arg aArgs[], otDnsQueryConfig *&aConfig)
{
// This method gets the optional DNS config from `aArgs[]`.
- // The format: `[server IPv6 address] [server port] [timeout]
- // [max tx attempt] [recursion desired]`.
+ // The format: `[server IP address] [server port] [timeout]
+ // [max tx attempt] [recursion desired] [service mode]
+ // [transport]`
otError error = OT_ERROR_NONE;
bool recursionDesired;
+ bool nat64SynthesizedAddress;
memset(aConfig, 0, sizeof(otDnsQueryConfig));
VerifyOrExit(!aArgs[0].IsEmpty(), aConfig = nullptr);
- SuccessOrExit(error = aArgs[0].ParseAsIp6Address(aConfig->mServerSockAddr.mAddress));
+ SuccessOrExit(error = Interpreter::ParseToIp6Address(GetInstancePtr(), aArgs[0], aConfig->mServerSockAddr.mAddress,
+ nat64SynthesizedAddress));
+ if (nat64SynthesizedAddress)
+ {
+ OutputFormat("Synthesized IPv6 DNS server address: ");
+ OutputIp6AddressLine(aConfig->mServerSockAddr.mAddress);
+ }
VerifyOrExit(!aArgs[1].IsEmpty());
SuccessOrExit(error = aArgs[1].ParseAsUint16(aConfig->mServerSockAddr.mPort));
@@ -1834,6 +3358,24 @@ otError Interpreter::GetDnsConfig(Arg aArgs[], otDnsQueryConfig *&aConfig)
SuccessOrExit(error = aArgs[4].ParseAsBool(recursionDesired));
aConfig->mRecursionFlag = recursionDesired ? OT_DNS_FLAG_RECURSION_DESIRED : OT_DNS_FLAG_NO_RECURSION;
+ VerifyOrExit(!aArgs[5].IsEmpty());
+ SuccessOrExit(error = ParseDnsServiceMode(aArgs[5], aConfig->mServiceMode));
+
+ VerifyOrExit(!aArgs[6].IsEmpty());
+
+ if (aArgs[6] == "tcp")
+ {
+ aConfig->mTransportProto = OT_DNS_TRANSPORT_TCP;
+ }
+ else if (aArgs[6] == "udp")
+ {
+ aConfig->mTransportProto = OT_DNS_TRANSPORT_UDP;
+ }
+ else
+ {
+ error = OT_ERROR_INVALID_ARGS;
+ }
+
exit:
return error;
}
@@ -1860,12 +3402,12 @@ void Interpreter::HandleDnsAddressResponse(otError aError, const otDnsAddressRes
while (otDnsAddressResponseGetAddress(aResponse, index, &address, &ttl) == OT_ERROR_NONE)
{
OutputIp6Address(address);
- OutputFormat(" TTL:%u ", ttl);
+ OutputFormat(" TTL:%lu ", ToUlong(ttl));
index++;
}
}
- OutputLine("");
+ OutputNewLine();
OutputResult(aError);
}
@@ -1873,15 +3415,26 @@ void Interpreter::HandleDnsAddressResponse(otError aError, const otDnsAddressRes
void Interpreter::OutputDnsServiceInfo(uint8_t aIndentSize, const otDnsServiceInfo &aServiceInfo)
{
- OutputLine(aIndentSize, "Port:%d, Priority:%d, Weight:%d, TTL:%u", aServiceInfo.mPort, aServiceInfo.mPriority,
- aServiceInfo.mWeight, aServiceInfo.mTtl);
+ OutputLine(aIndentSize, "Port:%d, Priority:%d, Weight:%d, TTL:%lu", aServiceInfo.mPort, aServiceInfo.mPriority,
+ aServiceInfo.mWeight, ToUlong(aServiceInfo.mTtl));
OutputLine(aIndentSize, "Host:%s", aServiceInfo.mHostNameBuffer);
OutputFormat(aIndentSize, "HostAddress:");
OutputIp6Address(aServiceInfo.mHostAddress);
- OutputLine(" TTL:%u", aServiceInfo.mHostAddressTtl);
+ OutputLine(" TTL:%lu", ToUlong(aServiceInfo.mHostAddressTtl));
OutputFormat(aIndentSize, "TXT:");
- OutputDnsTxtData(aServiceInfo.mTxtData, aServiceInfo.mTxtDataSize);
- OutputLine(" TTL:%u", aServiceInfo.mTxtDataTtl);
+
+ if (!aServiceInfo.mTxtDataTruncated)
+ {
+ OutputDnsTxtData(aServiceInfo.mTxtData, aServiceInfo.mTxtDataSize);
+ }
+ else
+ {
+ OutputFormat("[");
+ OutputBytes(aServiceInfo.mTxtData, aServiceInfo.mTxtDataSize);
+ OutputFormat("...]");
+ }
+
+ OutputLine(" TTL:%lu", ToUlong(aServiceInfo.mTxtDataTtl));
}
void Interpreter::HandleDnsBrowseResponse(otError aError, const otDnsBrowseResponse *aResponse, void *aContext)
@@ -1893,7 +3446,7 @@ void Interpreter::HandleDnsBrowseResponse(otError aError, const otDnsBrowseRespo
{
char name[OT_DNS_MAX_NAME_SIZE];
char label[OT_DNS_MAX_LABEL_SIZE];
- uint8_t txtBuffer[255];
+ uint8_t txtBuffer[kMaxTxtDataSize];
otDnsServiceInfo serviceInfo;
IgnoreError(otDnsBrowseResponseGetServiceName(aResponse, name, sizeof(name)));
@@ -1919,7 +3472,7 @@ void Interpreter::HandleDnsBrowseResponse(otError aError, const otDnsBrowseRespo
OutputDnsServiceInfo(kIndentSize, serviceInfo);
}
- OutputLine("");
+ OutputNewLine();
}
}
@@ -1935,7 +3488,7 @@ void Interpreter::HandleDnsServiceResponse(otError aError, const otDnsServiceRes
{
char name[OT_DNS_MAX_NAME_SIZE];
char label[OT_DNS_MAX_LABEL_SIZE];
- uint8_t txtBuffer[255];
+ uint8_t txtBuffer[kMaxTxtDataSize];
otDnsServiceInfo serviceInfo;
IgnoreError(otDnsServiceResponseGetServiceName(aResponse, label, sizeof(label), name, sizeof(name)));
@@ -1951,8 +3504,8 @@ void Interpreter::HandleDnsServiceResponse(otError aError, const otDnsServiceRes
if (otDnsServiceResponseGetServiceInfo(aResponse, &serviceInfo) == OT_ERROR_NONE)
{
- OutputDnsServiceInfo(/* aIndetSize */ 0, serviceInfo);
- OutputLine("");
+ OutputDnsServiceInfo(/* aIndentSize */ 0, serviceInfo);
+ OutputNewLine();
}
}
@@ -1986,7 +3539,7 @@ void Interpreter::OutputEidCacheEntry(const otCacheEntryInfo &aEntry)
{
if (aEntry.mValidLastTrans)
{
- OutputFormat(" transTime=%u eid=", aEntry.mLastTransTime);
+ OutputFormat(" transTime=%lu eid=", ToUlong(aEntry.mLastTransTime));
OutputIp6Address(aEntry.mMeshLocalEid);
}
}
@@ -2000,9 +3553,21 @@ void Interpreter::OutputEidCacheEntry(const otCacheEntryInfo &aEntry)
OutputFormat(" retryDelay=%u", aEntry.mRetryDelay);
}
- OutputLine("");
+ OutputNewLine();
}
+/**
+ * @cli eidcache
+ * @code
+ * eidcache
+ * fd49:caf4:a29f:dc0e:97fc:69dd:3c16:df7d 2000 cache canEvict=1 transTime=0 eid=fd49:caf4:a29f:dc0e:97fc:69dd:3c16:df7d
+ * fd49:caf4:a29f:dc0e:97fc:69dd:3c16:df7f fffe retry canEvict=1 timeout=10 retryDelay=30
+ * Done
+ * @endcode
+ * @par
+ * Returns the EID-to-RLOC cache entries.
+ * @sa otThreadGetNextCacheEntry
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
OT_UNUSED_VARIABLE(aArgs);
@@ -2012,7 +3577,7 @@ template <> otError Interpreter::Process(Arg aArgs[])
memset(&iterator, 0, sizeof(iterator));
- for (uint8_t i = 0;; i++)
+ while (true)
{
SuccessOrExit(otThreadGetNextCacheEntry(GetInstancePtr(), &entry, &iterator));
OutputEidCacheEntry(entry);
@@ -2053,10 +3618,31 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+ /**
+ * @cli extaddr
+ * @code
+ * extaddr
+ * dead00beef00cafe
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otLinkGetExtendedAddress
+ */
if (aArgs[0].IsEmpty())
{
OutputExtAddressLine(*otLinkGetExtendedAddress(GetInstancePtr()));
}
+ /**
+ * @cli extaddr (set)
+ * @code
+ * extaddr dead00beef00cafe
+ * dead00beef00cafe
+ * Done
+ * @endcode
+ * @cparam extaddr @ca{extaddr}
+ * @par api_copy
+ * #otLinkSetExtendedAddress
+ */
else
{
otExtAddress extAddress;
@@ -2095,7 +3681,7 @@ template <> otError Interpreter::Process(Arg aArgs[])
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_DEBUG_UART) && OPENTHREAD_POSIX
else if (aArgs[0] == "filename")
{
- VerifyOrExit(aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
+ VerifyOrExit(!aArgs[1].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
SuccessOrExit(error = otPlatDebugUart_logfile(aArgs[1].GetCString()));
}
#endif
@@ -2112,10 +3698,33 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+ /**
+ * @cli extpanid
+ * @code
+ * extpanid
+ * dead00beef00cafe
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetExtendedPanId
+ */
if (aArgs[0].IsEmpty())
{
OutputBytesLine(otThreadGetExtendedPanId(GetInstancePtr())->m8);
}
+ /**
+ * @cli extpanid (set)
+ * @code
+ * extpanid dead00beef00cafe
+ * Done
+ * @endcode
+ * @cparam extpanid @ca{extpanid}
+ * @par
+ * @note The current commissioning credential becomes stale after changing this value.
+ * Use `pskc` to reset.
+ * @par api_copy
+ * #otThreadSetExtendedPanId
+ */
else
{
otExtendedPanId extPanId;
@@ -2128,6 +3737,14 @@ template <> otError Interpreter::Process(Arg aArgs[])
return error;
}
+/**
+ * @cli factoryreset
+ * @code
+ * factoryreset
+ * @endcode
+ * @par api_copy
+ * #otInstanceFactoryReset
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
OT_UNUSED_VARIABLE(aArgs);
@@ -2142,6 +3759,19 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_INVALID_COMMAND;
+ /**
+ * @cli fake (a,an)
+ * @code
+ * fake /a/an fdde:ad00:beef:0:0:ff:fe00:a800 fd00:7d03:7d03:7d03:55f2:bb6a:7a43:a03b 1111222233334444
+ * Done
+ * @endcode
+ * @cparam fake /a/an @ca{dst-ipaddr} @ca{target} @ca{meshLocalIid}
+ * @par
+ * Sends fake Thread messages.
+ * @par
+ * Available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled.
+ * @sa otThreadSendAddressNotification
+ */
if (aArgs[0] == "/a/an")
{
otIp6Address destination, target;
@@ -2176,6 +3806,17 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+ /**
+ * @cli fem
+ * @code
+ * fem
+ * LNA gain 11 dBm
+ * Done
+ * @endcode
+ * @par
+ * Gets external FEM parameters.
+ * @sa otPlatRadioGetFemLnaGain
+ */
if (aArgs[0].IsEmpty())
{
int8_t lnaGain;
@@ -2183,6 +3824,16 @@ template <> otError Interpreter::Process(Arg aArgs[])
SuccessOrExit(error = otPlatRadioGetFemLnaGain(GetInstancePtr(), &lnaGain));
OutputLine("LNA gain %d dBm", lnaGain);
}
+ /**
+ * @cli fem lnagain (get)
+ * @code
+ * fem lnagain
+ * 11
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otPlatRadioGetFemLnaGain
+ */
else if (aArgs[0] == "lnagain")
{
if (aArgs[1].IsEmpty())
@@ -2192,6 +3843,15 @@ template <> otError Interpreter::Process(Arg aArgs[])
SuccessOrExit(error = otPlatRadioGetFemLnaGain(GetInstancePtr(), &lnaGain));
OutputLine("%d", lnaGain);
}
+ /**
+ * @cli fem lnagain (set)
+ * @code
+ * fem lnagain 8
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otPlatRadioSetFemLnaGain
+ */
else
{
int8_t lnaGain;
@@ -2213,6 +3873,21 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+ /**
+ * @cli ifconfig
+ * @code
+ * ifconfig
+ * down
+ * Done
+ * @endcode
+ * @code
+ * ifconfig
+ * up
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otIp6IsEnabled
+ */
if (aArgs[0].IsEmpty())
{
if (otIp6IsEnabled(GetInstancePtr()))
@@ -2224,6 +3899,20 @@ template <> otError Interpreter::Process(Arg aArgs[])
OutputLine("down");
}
}
+ /**
+ * @cli ifconfig (up,down)
+ * @code
+ * ifconfig up
+ * Done
+ * @endcode
+ * @code
+ * ifconfig down
+ * Done
+ * @endcode
+ * @cparam ifconfig @ca{up|down}
+ * @par api_copy
+ * #otIp6SetEnabled
+ */
else if (aArgs[0] == "up")
{
SuccessOrExit(error = otIp6SetEnabled(GetInstancePtr(), true));
@@ -2269,6 +3958,27 @@ template <> otError Interpreter::Process(Arg aArgs[])
verbose = true;
}
+ /**
+ * @cli ipaddr
+ * @code
+ * ipaddr
+ * fdde:ad00:beef:0:0:ff:fe00:0
+ * fdde:ad00:beef:0:558:f56b:d688:799
+ * fe80:0:0:0:f3d9:2a82:c8d8:fe43
+ * Done
+ * @endcode
+ * @code
+ * ipaddr -v
+ * fdde:ad00:beef:0:0:ff:fe00:0 origin:thread
+ * fdde:ad00:beef:0:558:f56b:d688:799 origin:thread
+ * fe80:0:0:0:f3d9:2a82:c8d8:fe43 origin:thread
+ * Done
+ * @endcode
+ * @cparam ipaddr [@ca{-v}]
+ * Use `-v` to get verbose IP Address information.
+ * @par api_copy
+ * #otIp6GetUnicastAddresses
+ */
if (aArgs[0].IsEmpty())
{
const otNetifAddress *unicastAddrs = otIp6GetUnicastAddresses(GetInstancePtr());
@@ -2282,9 +3992,19 @@ template <> otError Interpreter::Process(Arg aArgs[])
OutputFormat(" origin:%s", AddressOriginToString(addr->mAddressOrigin));
}
- OutputLine("");
+ OutputNewLine();
}
}
+ /**
+ * @cli ipaddr add
+ * @code
+ * ipaddr add 2001::dead:beef:cafe
+ * Done
+ * @endcode
+ * @cparam ipaddr add @ca{aAddress}
+ * @par api_copy
+ * #otIp6AddUnicastAddress
+ */
else if (aArgs[0] == "add")
{
otNetifAddress address;
@@ -2297,6 +4017,16 @@ template <> otError Interpreter::Process(Arg aArgs[])
error = otIp6AddUnicastAddress(GetInstancePtr(), &address);
}
+ /**
+ * @cli ipaddr del
+ * @code
+ * ipaddr del 2001::dead:beef:cafe
+ * Done
+ * @endcode
+ * @cparam ipaddr del @ca{aAddress}
+ * @par api_copy
+ * #otIp6RemoveUnicastAddress
+ */
else if (aArgs[0] == "del")
{
otIp6Address address;
@@ -2304,14 +4034,44 @@ template <> otError Interpreter::Process(Arg aArgs[])
SuccessOrExit(error = aArgs[1].ParseAsIp6Address(address));
error = otIp6RemoveUnicastAddress(GetInstancePtr(), &address);
}
+ /**
+ * @cli ipaddr linklocal
+ * @code
+ * ipaddr linklocal
+ * fe80:0:0:0:f3d9:2a82:c8d8:fe43
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetLinkLocalIp6Address
+ */
else if (aArgs[0] == "linklocal")
{
OutputIp6AddressLine(*otThreadGetLinkLocalIp6Address(GetInstancePtr()));
}
+ /**
+ * @cli ipaddr rloc
+ * @code
+ * ipaddr rloc
+ * fdde:ad00:beef:0:0:ff:fe00:0
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetRloc
+ */
else if (aArgs[0] == "rloc")
{
OutputIp6AddressLine(*otThreadGetRloc(GetInstancePtr()));
}
+ /**
+ * @cli ipaddr mleid
+ * @code
+ * ipaddr mleid
+ * fdde:ad00:beef:0:558:f56b:d688:799
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetMeshLocalEid
+ */
else if (aArgs[0] == "mleid")
{
OutputIp6AddressLine(*otThreadGetMeshLocalEid(GetInstancePtr()));
@@ -2329,6 +4089,18 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+ /**
+ * @cli ipmaddr
+ * @code
+ * ipmaddr
+ * ff05:0:0:0:0:0:0:1
+ * ff33:40:fdde:ad00:beef:0:0:1
+ * ff32:40:fdde:ad00:beef:0:0:1
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otIp6GetMulticastAddresses
+ */
if (aArgs[0].IsEmpty())
{
for (const otNetifMulticastAddress *addr = otIp6GetMulticastAddresses(GetInstancePtr()); addr;
@@ -2337,6 +4109,16 @@ template <> otError Interpreter::Process(Arg aArgs[])
OutputIp6AddressLine(addr->mAddress);
}
}
+ /**
+ * @cli ipmaddr add
+ * @code
+ * ipmaddr add ff05::1
+ * Done
+ * @endcode
+ * @cparam ipmaddr add @ca{aAddress}
+ * @par api_copy
+ * #otIp6SubscribeMulticastAddress
+ */
else if (aArgs[0] == "add")
{
otIp6Address address;
@@ -2354,6 +4136,16 @@ template <> otError Interpreter::Process(Arg aArgs[])
while (false);
#endif
}
+ /**
+ * @cli ipmaddr del
+ * @code
+ * ipmaddr del ff05::1
+ * Done
+ * @endcode
+ * @cparam ipmaddr del @ca{aAddress}
+ * @par api_copy
+ * #otIp6UnsubscribeMulticastAddress
+ */
else if (aArgs[0] == "del")
{
otIp6Address address;
@@ -2361,12 +4153,36 @@ template <> otError Interpreter::Process(Arg aArgs[])
SuccessOrExit(error = aArgs[1].ParseAsIp6Address(address));
error = otIp6UnsubscribeMulticastAddress(GetInstancePtr(), &address);
}
+ /**
+ * @cli ipmaddr promiscuous
+ * @code
+ * ipmaddr promiscuous
+ * Disabled
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otIp6IsMulticastPromiscuousEnabled
+ */
else if (aArgs[0] == "promiscuous")
{
if (aArgs[1].IsEmpty())
{
OutputEnabledDisabledStatus(otIp6IsMulticastPromiscuousEnabled(GetInstancePtr()));
}
+ /**
+ * @cli ipmaddr promiscuous (enable,disable)
+ * @code
+ * ipmaddr promiscuous enable
+ * Done
+ * @endcode
+ * @code
+ * ipmaddr promiscuous disable
+ * Done
+ * @endcode
+ * @cparam ipmaddr promiscuous @ca{enable|disable}
+ * @par api_copy
+ * #otIp6SetMulticastPromiscuousEnabled
+ */
else
{
bool enable;
@@ -2375,10 +4191,30 @@ template <> otError Interpreter::Process(Arg aArgs[])
otIp6SetMulticastPromiscuousEnabled(GetInstancePtr(), enable);
}
}
+ /**
+ * @cli ipmaddr llatn
+ * @code
+ * ipmaddr llatn
+ * ff32:40:fdde:ad00:beef:0:0:1
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetLinkLocalAllThreadNodesMulticastAddress
+ */
else if (aArgs[0] == "llatn")
{
OutputIp6AddressLine(*otThreadGetLinkLocalAllThreadNodesMulticastAddress(GetInstancePtr()));
}
+ /**
+ * @cli ipmaddr rlatn
+ * @code
+ * ipmaddr rlatn
+ * ff33:40:fdde:ad00:beef:0:0:1
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetRealmLocalAllThreadNodesMulticastAddress
+ */
else if (aArgs[0] == "rlatn")
{
OutputIp6AddressLine(*otThreadGetRealmLocalAllThreadNodesMulticastAddress(GetInstancePtr()));
@@ -2396,18 +4232,74 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_INVALID_ARGS;
+ /**
+ * @cli keysequence counter
+ * @code
+ * keysequence counter
+ * 10
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetKeySequenceCounter
+ */
if (aArgs[0] == "counter")
{
+ /**
+ * @cli keysequence counter (set)
+ * @code
+ * keysequence counter 10
+ * Done
+ * @endcode
+ * @cparam keysequence counter @ca{counter}
+ * @par api_copy
+ * #otThreadSetKeySequenceCounter
+ */
error = ProcessGetSet(aArgs + 1, otThreadGetKeySequenceCounter, otThreadSetKeySequenceCounter);
}
+ /**
+ * @cli keysequence guardtime
+ * @code
+ * keysequence guardtime
+ * 0
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetKeySwitchGuardTime
+ */
else if (aArgs[0] == "guardtime")
{
+ /**
+ * @cli keysequence guardtime (set)
+ * @code
+ * keysequence guardtime 0
+ * Done
+ * @endcode
+ * @cparam keysequence guardtime @ca{guardtime-hours}
+ * Use `0` to `Thread Key Switch` immediately if there's a key index match.
+ * @par api_copy
+ * #otThreadSetKeySwitchGuardTime
+ */
error = ProcessGetSet(aArgs + 1, otThreadGetKeySwitchGuardTime, otThreadSetKeySwitchGuardTime);
}
return error;
}
+/**
+ * @cli leaderdata
+ * @code
+ * leaderdata
+ * Partition ID: 1077744240
+ * Weighting: 64
+ * Data Version: 109
+ * Stable Data Version: 211
+ * Leader Router ID: 60
+ * Done
+ * @endcode
+ * @par
+ * Gets the Thread Leader Data.
+ * @sa otThreadGetLeaderData
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
OT_UNUSED_VARIABLE(aArgs);
@@ -2417,11 +4309,11 @@ template <> otError Interpreter::Process(Arg aArgs[])
SuccessOrExit(error = otThreadGetLeaderData(GetInstancePtr(), &leaderData));
- OutputLine("Partition ID: %u", leaderData.mPartitionId);
- OutputLine("Weighting: %d", leaderData.mWeighting);
- OutputLine("Data Version: %d", leaderData.mDataVersion);
- OutputLine("Stable Data Version: %d", leaderData.mStableDataVersion);
- OutputLine("Leader Router ID: %d", leaderData.mLeaderRouterId);
+ OutputLine("Partition ID: %lu", ToUlong(leaderData.mPartitionId));
+ OutputLine("Weighting: %u", leaderData.mWeighting);
+ OutputLine("Data Version: %u", leaderData.mDataVersion);
+ OutputLine("Stable Data Version: %u", leaderData.mStableDataVersion);
+ OutputLine("Leader Router ID: %u", leaderData.mLeaderRouterId);
exit:
return error;
@@ -2432,54 +4324,201 @@ template <> otError Interpreter::Process(Arg aArgs[])
{
otError error = OT_ERROR_INVALID_COMMAND;
+ /**
+ * @cli partitionid
+ * @code
+ * partitionid
+ * 4294967295
+ * Done
+ * @endcode
+ * @par
+ * Get the Thread Network Partition ID.
+ * @sa otThreadGetPartitionId
+ */
if (aArgs[0].IsEmpty())
{
- OutputLine("%u", otThreadGetPartitionId(GetInstancePtr()));
+ OutputLine("%lu", ToUlong(otThreadGetPartitionId(GetInstancePtr())));
error = OT_ERROR_NONE;
}
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
- else if (aArgs[0] == "preferred")
- {
- error = ProcessGetSet(aArgs + 1, otThreadGetPreferredLeaderPartitionId, otThreadSetPreferredLeaderPartitionId);
- }
-#endif
-
- return error;
-}
+ /**
+ * @cli partitionid preferred (get,set)
+ * @code
+ * partitionid preferred
+ * 4294967295
+ * Done
+ * @endcode
+ * @code
+ * partitionid preferred 0xffffffff
+ * Done
+ * @endcode
+ * @cparam partitionid preferred @ca{partitionid}
+ * @sa otThreadGetPreferredLeaderPartitionId
+ * @sa otThreadSetPreferredLeaderPartitionId
+ * @par
+ * `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is required.
+ */
+ else if (aArgs[0] == "preferred")
+ {
+ error = ProcessGetSet(aArgs + 1, otThreadGetPreferredLeaderPartitionId, otThreadSetPreferredLeaderPartitionId);
+ }
+#endif
+
+ return error;
+}
+/**
+ * @cli leaderweight
+ * @code
+ * leaderweight
+ * 128
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetLocalLeaderWeight
+ */
template <> otError Interpreter::Process(Arg aArgs[])
{
+ /**
+ * @cli leaderweight (set)
+ * @code
+ * leaderweight 128
+ * Done
+ * @endcode
+ * @cparam leaderweight @ca{weight}
+ * @par api_copy
+ * #otThreadSetLocalLeaderWeight
+ */
return ProcessGetSet(aArgs, otThreadGetLocalLeaderWeight, otThreadSetLocalLeaderWeight);
}
+
+template <> otError Interpreter::Process(Arg aArgs[])
+{
+ static const char *const kPowerSupplyStrings[4] = {
+ "battery", // (0) OT_POWER_SUPPLY_BATTERY
+ "external", // (1) OT_POWER_SUPPLY_EXTERNAL
+ "external-stable", // (2) OT_POWER_SUPPLY_EXTERNAL_STABLE
+ "external-unstable", // (3) OT_POWER_SUPPLY_EXTERNAL_UNSTABLE
+ };
+
+ static_assert(0 == OT_POWER_SUPPLY_BATTERY, "OT_POWER_SUPPLY_BATTERY value is incorrect");
+ static_assert(1 == OT_POWER_SUPPLY_EXTERNAL, "OT_POWER_SUPPLY_EXTERNAL value is incorrect");
+ static_assert(2 == OT_POWER_SUPPLY_EXTERNAL_STABLE, "OT_POWER_SUPPLY_EXTERNAL_STABLE value is incorrect");
+ static_assert(3 == OT_POWER_SUPPLY_EXTERNAL_UNSTABLE, "OT_POWER_SUPPLY_EXTERNAL_UNSTABLE value is incorrect");
+
+ otError error = OT_ERROR_NONE;
+
+ /**
+ * @cli deviceprops
+ * @code
+ * deviceprops
+ * PowerSupply : external
+ * IsBorderRouter : yes
+ * SupportsCcm : no
+ * IsUnstable : no
+ * WeightAdjustment : 0
+ * Done
+ * @endcode
+ * @par api_copy
+ * #otThreadGetDeviceProperties
+ */
+ if (aArgs[0].IsEmpty())
+ {
+ const otDeviceProperties *props = otThreadGetDeviceProperties(GetInstancePtr());
+
+ OutputLine("PowerSupply : %s", Stringify(props->mPowerSupply, kPowerSupplyStrings));
+ OutputLine("IsBorderRouter : %s", props->mIsBorderRouter ? "yes" : "no");
+ OutputLine("SupportsCcm : %s", props->mSupportsCcm ? "yes" : "no");
+ OutputLine("IsUnstable : %s", props->mIsUnstable ? "yes" : "no");
+ OutputLine("WeightAdjustment : %d", props->mLeaderWeightAdjustment);
+ }
+ /**
+ * @cli deviceprops (set)
+ * @code
+ * deviceprops battery 0 0 0 -5
+ * Done
+ * @endcode
+ * @code
+ * deviceprops
+ * PowerSupply : battery
+ * IsBorderRouter : no
+ * SupportsCcm : no
+ * IsUnstable : no
+ * WeightAdjustment : -5
+ * Done
+ * @endcode
+ * @cparam deviceprops @ca{powerSupply} @ca{isBr} @ca{supportsCcm} @ca{isUnstable} @ca{weightAdjustment}
+ * `powerSupply`: should be 'battery', 'external', 'external-stable', 'external-unstable'.
+ * @par
+ * Sets the device properties.
+ * @csa{leaderweight}
+ * @csa{leaderweight (set)}
+ * @sa #otThreadSetDeviceProperties
+ */
+ else
+ {
+ otDeviceProperties props;
+ bool value;
+ uint8_t index;
+
+ for (index = 0; index < OT_ARRAY_LENGTH(kPowerSupplyStrings); index++)
+ {
+ if (aArgs[0] == kPowerSupplyStrings[index])
+ {
+ props.mPowerSupply = static_cast(index);
+ break;
+ }
+ }
+
+ VerifyOrExit(index < OT_ARRAY_LENGTH(kPowerSupplyStrings), error = OT_ERROR_INVALID_ARGS);
+
+ SuccessOrExit(error = aArgs[1].ParseAsBool(value));
+ props.mIsBorderRouter = value;
+
+ SuccessOrExit(error = aArgs[2].ParseAsBool(value));
+ props.mSupportsCcm = value;
+
+ SuccessOrExit(error = aArgs[3].ParseAsBool(value));
+ props.mIsUnstable = value;
+
+ SuccessOrExit(error = aArgs[4].ParseAsInt8(props.mLeaderWeightAdjustment));
+
+ VerifyOrExit(aArgs[5].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
+ otThreadSetDeviceProperties(GetInstancePtr(), &props);
+ }
+
+exit:
+ return error;
+}
+
#endif // OPENTHREAD_FTD
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
-void Interpreter::HandleLinkMetricsReport(const otIp6Address * aAddress,
+void Interpreter::HandleLinkMetricsReport(const otIp6Address *aAddress,
const otLinkMetricsValues *aMetricsValues,
uint8_t aStatus,
- void * aContext)
+ void *aContext)
{
static_cast(aContext)->HandleLinkMetricsReport(aAddress, aMetricsValues, aStatus);
}
void Interpreter::PrintLinkMetricsValue(const otLinkMetricsValues *aMetricsValues)
{
- const char kLinkMetricsTypeCount[] = "(Count/Summation)";
- const char kLinkMetricsTypeAverage[] = "(Exponential Moving Average)";
+ static const char kLinkMetricsTypeAverage[] = "(Exponential Moving Average)";
if (aMetricsValues->mMetrics.mPduCount)
{
- OutputLine(" - PDU Counter: %d %s", aMetricsValues->mPduCountValue, kLinkMetricsTypeCount);
+ OutputLine(" - PDU Counter: %lu (Count/Summation)", ToUlong(aMetricsValues->mPduCountValue));
}
if (aMetricsValues->mMetrics.mLqi)
{
- OutputLine(" - LQI: %d %s", aMetricsValues->mLqiValue, kLinkMetricsTypeAverage);
+ OutputLine(" - LQI: %u %s", aMetricsValues->mLqiValue, kLinkMetricsTypeAverage);
}
if (aMetricsValues->mMetrics.mLinkMargin)
{
- OutputLine(" - Margin: %d (dB) %s", aMetricsValues->mLinkMarginValue, kLinkMetricsTypeAverage);
+ OutputLine(" - Margin: %u (dB) %s", aMetricsValues->mLinkMarginValue, kLinkMetricsTypeAverage);
}
if (aMetricsValues->mMetrics.mRssi)
@@ -2488,7 +4527,7 @@ void Interpreter::PrintLinkMetricsValue(const otLinkMetricsValues *aMetricsValue
}
}
-void Interpreter::HandleLinkMetricsReport(const otIp6Address * aAddress,
+void Interpreter::HandleLinkMetricsReport(const otIp6Address *aAddress,
const otLinkMetricsValues *aMetricsValues,
uint8_t aStatus)
{
@@ -2503,6 +4542,12 @@ void Interpreter::HandleLinkMetricsReport(const otIp6Address * aAddress,
{
OutputLine("Link Metrics Report, status: %s", LinkMetricsStatusToStr(aStatus));
}
+
+ if (mLinkMetricsQueryInProgress)
+ {
+ mLinkMetricsQueryInProgress = false;
+ OutputResult(OT_ERROR_NONE);
+ }
}
void Interpreter::HandleLinkMetricsMgmtResponse(const otIp6Address *aAddress, uint8_t aStatus, void *aContext)
@@ -2519,15 +4564,15 @@ void Interpreter::HandleLinkMetricsMgmtResponse(const otIp6Address *aAddress, ui
}
void Interpreter::HandleLinkMetricsEnhAckProbingIe(otShortAddress aShortAddress,
- const otExtAddress * aExtAddress,
+ const otExtAddress *aExtAddress,
const otLinkMetricsValues *aMetricsValues,
- void * aContext)
+ void *aContext)
{
static_cast(aContext)->HandleLinkMetricsEnhAckProbingIe(aShortAddress, aExtAddress, aMetricsValues);
}
void Interpreter::HandleLinkMetricsEnhAckProbingIe(otShortAddress aShortAddress,
- const otExtAddress * aExtAddress,
+ const otExtAddress *aExtAddress,
const otLinkMetricsValues *aMetricsValues)
{
OutputFormat("Received Link Metrics data in Enh Ack from neighbor, short address:0x%02x , extended address:",
@@ -2577,34 +4622,95 @@ template <> otError Interpreter::Process(Arg aArgs[])
if (aArgs[0] == "query")
{
otIp6Address address;
+ bool isSingle;
+ bool blocking;
+ uint8_t seriesId;
otLinkMetrics linkMetrics;
SuccessOrExit(error = aArgs[1].ParseAsIp6Address(address));
+ /**
+ * @cli linkmetrics query single
+ * @code
+ * linkmetrics query fe80:0:0:0:3092:f334:1455:1ad2 single qmr
+ * Done
+ * > Received Link Metrics Report from: fe80:0:0:0:3092:f334:1455:1ad2
+ * - LQI: 76 (Exponential Moving Average)
+ * - Margin: 82 (dB) (Exponential Moving Average)
+ * - RSSI: -18 (dBm) (Exponential Moving Average)
+ * @endcode
+ * @cparam linkmetrics query @ca{peer-ipaddr} single [@ca{pqmr}]
+ * - `peer-ipaddr`: Peer address.
+ * - [`p`, `q`, `m`, and `r`] map to #otLinkMetrics.
+ * - `p`: Layer 2 Number of PDUs received.
+ * - `q`: Layer 2 LQI.
+ * - `m`: Link Margin.
+ * - `r`: RSSI.
+ * @par
+ * Perform a Link Metrics query (Single Probe).
+ * @sa otLinkMetricsQuery
+ */
if (aArgs[2] == "single")
{
- VerifyOrExit(!aArgs[3].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
+ isSingle = true;
SuccessOrExit(error = ParseLinkMetricsFlags(linkMetrics, aArgs[3]));
- error = otLinkMetricsQuery(GetInstancePtr(), &address, /* aSeriesId */ 0, &linkMetrics,
- &Interpreter::HandleLinkMetricsReport, this);
}
+ /**
+ * @cli linkmetrics query forward
+ * @code
+ * linkmetrics query fe80:0:0:0:3092:f334:1455:1ad2 forward 1
+ * Done
+ * > Received Link Metrics Report from: fe80:0:0:0:3092:f334:1455:1ad2
+ * - PDU Counter: 2 (Count/Summation)
+ * - LQI: 76 (Exponential Moving Average)
+ * - Margin: 82 (dB) (Exponential Moving Average)
+ * - RSSI: -18 (dBm) (Exponential Moving Average)
+ * @endcode
+ * @cparam linkmetrics query @ca{peer-ipaddr} forward @ca{series-id}
+ * - `peer-ipaddr`: Peer address.
+ * - `series-id`: The Series ID.
+ * @par
+ * Perform a Link Metrics query (Forward Tracking Series).
+ * @sa otLinkMetricsQuery
+ */
else if (aArgs[2] == "forward")
{
- uint8_t seriesId;
-
+ isSingle = false;
SuccessOrExit(error = aArgs[3].ParseAsUint8(seriesId));
- error = otLinkMetricsQuery(GetInstancePtr(), &address, seriesId, nullptr,
- &Interpreter::HandleLinkMetricsReport, this);
}
else
{
- error = OT_ERROR_INVALID_ARGS;
+ ExitNow(error = OT_ERROR_INVALID_ARGS);
+ }
+
+ blocking = (aArgs[4] == "block");
+
+ SuccessOrExit(error = otLinkMetricsQuery(GetInstancePtr(), &address, isSingle ? 0 : seriesId,
+ isSingle ? &linkMetrics : nullptr, HandleLinkMetricsReport, this));
+
+ if (blocking)
+ {
+ mLinkMetricsQueryInProgress = true;
+ error = OT_ERROR_PENDING;
}
}
else if (aArgs[0] == "mgmt")
{
error = ProcessLinkMetricsMgmt(aArgs + 1);
}
+ /**
+ * @cli linkmetrics probe
+ * @code
+ * linkmetrics probe fe80:0:0:0:3092:f334:1455:1ad2 1 10
+ * Done
+ * @endcode
+ * @cparam linkmetrics probe @ca{peer-ipaddr} @ca{series-id} @ca{length}
+ * - `peer-ipaddr`: Peer address.
+ * - `series-id`: The Series ID for which this Probe message targets.
+ * - `length`: The length of the Probe message. A valid range is [0, 64].
+ * @par api_copy
+ * #otLinkMetricsSendLinkProbe
+ */
else if (aArgs[0] == "probe")
{
otIp6Address address;
@@ -2626,6 +4732,8 @@ otError Interpreter::ParseLinkMetricsFlags(otLinkMetrics &aLinkMetrics, const Ar
{
otError error = OT_ERROR_NONE;
+ VerifyOrExit(!aFlags.IsEmpty(), error = OT_ERROR_INVALID_ARGS);
+
memset(&aLinkMetrics, 0, sizeof(aLinkMetrics));
for (const char *arg = aFlags.GetCString(); *arg != '\0'; arg++)
@@ -2668,6 +4776,32 @@ otError Interpreter::ProcessLinkMetricsMgmt(Arg aArgs[])
memset(&seriesFlags, 0, sizeof(otLinkMetricsSeriesFlags));
+ /**
+ * @cli linkmetrics mgmt forward
+ * @code
+ * linkmetrics mgmt fe80:0:0:0:3092:f334:1455:1ad2 forward 1 dra pqmr
+ * Done
+ * > Received Link Metrics Management Response from: fe80:0:0:0:3092:f334:1455:1ad2
+ * Status: SUCCESS
+ * @endcode
+ * @cparam linkmetrics mgmt @ca{peer-ipaddr} forward @ca{series-id} [@ca{ldraX}][@ca{pqmr}]
+ * - `peer-ipaddr`: Peer address.
+ * - `series-id`: The Series ID.
+ * - [`l`, `d`, `r`, and `a`] map to #otLinkMetricsSeriesFlags. `X` represents none of the
+ * `otLinkMetricsSeriesFlags`, and stops the accounting and removes the series.
+ * - `l`: MLE Link Probe.
+ * - `d`: MAC Data.
+ * - `r`: MAC Data Request.
+ * - `a`: MAC Ack.
+ * - `X`: Can only be used without any other flags.
+ * - [`p`, `q`, `m`, and `r`] map to #otLinkMetricsValues.
+ * - `p`: Layer 2 Number of PDUs received.
+ * - `q`: Layer 2 LQI.
+ * - `m`: Link Margin.
+ * - `r`: RSSI.
+ * @par api_copy
+ * #otLinkMetricsConfigForwardTrackingSeries
+ */
if (aArgs[1] == "forward")
{
uint8_t seriesId;
@@ -2710,8 +4844,8 @@ otError Interpreter::ProcessLinkMetricsMgmt(Arg aArgs[])
if (!clear)
{
- VerifyOrExit(!aArgs[4].IsEmpty() && aArgs[5].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
SuccessOrExit(error = ParseLinkMetricsFlags(linkMetrics, aArgs[4]));
+ VerifyOrExit(aArgs[5].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
}
error = otLinkMetricsConfigForwardTrackingSeries(GetInstancePtr(), &address, seriesId, seriesFlags,
@@ -2722,17 +4856,59 @@ otError Interpreter::ProcessLinkMetricsMgmt(Arg aArgs[])
{
otLinkMetricsEnhAckFlags enhAckFlags;
otLinkMetrics linkMetrics;
- otLinkMetrics * pLinkMetrics = &linkMetrics;
-
+ otLinkMetrics *pLinkMetrics = &linkMetrics;
+
+ /**
+ * @cli linkmetrics mgmt enhanced-ack clear
+ * @code
+ * linkmetrics mgmt fe80:0:0:0:3092:f334:1455:1ad2 enhanced-ack clear
+ * Done
+ * > Received Link Metrics Management Response from: fe80:0:0:0:3092:f334:1455:1ad2
+ * Status: Success
+ * @endcode
+ * @cparam linkmetrics mgmt @ca{peer-ipaddr} enhanced-ack clear
+ * `peer-ipaddr` should be the Link Local address of the neighboring device.
+ * @par
+ * Sends a Link Metrics Management Request to clear an Enhanced-ACK Based Probing.
+ * @sa otLinkMetricsConfigEnhAckProbing
+ */
if (aArgs[2] == "clear")
{
enhAckFlags = OT_LINK_METRICS_ENH_ACK_CLEAR;
pLinkMetrics = nullptr;
}
+ /**
+ * @cli linkmetrics mgmt enhanced-ack register
+ * @code
+ * linkmetrics mgmt fe80:0:0:0:3092:f334:1455:1ad2 enhanced-ack register qm
+ * Done
+ * > Received Link Metrics Management Response from: fe80:0:0:0:3092:f334:1455:1ad2
+ * Status: Success
+ * @endcode
+ * @code
+ * > linkmetrics mgmt fe80:0:0:0:3092:f334:1455:1ad2 enhanced-ack register qm r
+ * Done
+ * > Received Link Metrics Management Response from: fe80:0:0:0:3092:f334:1455:1ad2
+ * Status: Cannot support new series
+ * @endcode
+ * @cparam linkmetrics mgmt @ca{peer-ipaddr} enhanced-ack register [@ca{qmr}][@ca{r}]
+ * [`q`, `m`, and `r`] map to #otLinkMetricsValues. Per spec 4.11.3.4.4.6, you can
+ * only use a maximum of two options at once, for example `q`, or `qm`.
+ * - `q`: Layer 2 LQI.
+ * - `m`: Link Margin.
+ * - `r`: RSSI.
+ * .
+ * The additional `r` is optional and only used for reference devices. When this option
+ * is specified, Type/Average Enum of each Type Id Flags is set to reserved. This is
+ * used to verify that the Probing Subject correctly handles invalid Type Id Flags, and
+ * only available when `OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE` is enabled.
+ * @par
+ * Sends a Link Metrics Management Request to register an Enhanced-ACK Based Probing.
+ * @sa otLinkMetricsConfigEnhAckProbing
+ */
else if (aArgs[2] == "register")
{
enhAckFlags = OT_LINK_METRICS_ENH_ACK_REGISTER;
- VerifyOrExit(!aArgs[3].IsEmpty(), error = OT_ERROR_INVALID_ARGS);
SuccessOrExit(error = ParseLinkMetricsFlags(linkMetrics, aArgs[3]));
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
if (aArgs[4] == "r")
@@ -2785,7 +4961,7 @@ template <> otError Interpreter::Process(Arg aArgs[])
return error;
}
-void Interpreter::HandleLocateResult(void * aContext,
+void Interpreter::HandleLocateResult(void *aContext,
otError aError,
const otIp6Address *aMeshLocalAddress,
uint16_t aRloc16)
@@ -2856,7 +5032,7 @@ template <> otError Interpreter::Process(Arg aArgs[])
if (aArgs[0].IsEmpty())
{
- OutputLine("0x%04x", otThreadGetPskcRef(GetInstancePtr()));
+ OutputLine("0x%08lx", ToUlong(otThreadGetPskcRef(GetInstancePtr())));
}
else
{
@@ -2941,7 +5117,7 @@ template <> otError Interpreter::Process